当前位置: 首页>>代码示例>>Java>>正文


Java DataItemBuffer.getCount方法代码示例

本文整理汇总了Java中com.google.android.gms.wearable.DataItemBuffer.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java DataItemBuffer.getCount方法的具体用法?Java DataItemBuffer.getCount怎么用?Java DataItemBuffer.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.wearable.DataItemBuffer的用法示例。


在下文中一共展示了DataItemBuffer.getCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResult

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
@SuppressLint("CommitPrefEdits")
@Override
public void onResult(@NonNull DataItemBuffer dataItems) {
    // This is the callback from the getDataItems() call in resyncAll()
    SharedPreferences.Editor editor;
    if (TextUtils.isEmpty(sharedPrefsName)) {
        editor = PreferenceManager.getDefaultSharedPreferences(appContext).edit();
    } else {
        editor = appContext.getSharedPreferences(sharedPrefsName, MODE_PRIVATE).edit();
    }
    try {
        if (dataItems.getStatus().isSuccess()) {
            for (int i = dataItems.getCount() - 1; i >= 0; i--) {
                Log.d("PrefSyncService", "Resync onResult: " + dataItems.get(i));
                saveItem(dataItems.get(i), editor, null);
            }
        }
    } finally {
        // We don't use apply() because we don't know what thread we're on
        editor.commit();
        dataItems.release();
    }
}
 
开发者ID:StringMon,项目名称:prefsyncservice,代码行数:24,代码来源:PrefSyncService.java

示例2: getKeySet

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
public static ArrayList<String> getKeySet(GoogleApiClient apiClient, String path) {
    final DataItemBuffer buffer = Wearable.DataApi.getDataItems(
            apiClient,
            Uri.parse("wear:" + path))
            .await();

    ArrayList<String> keySet = null;
    try {
        if (buffer.getCount() > 0) {
            final DataMap map = DataMap.fromByteArray(buffer.get(0).getData());
            keySet = map.getStringArrayList(KEY_KEY_SET);
        }
    }finally {
        buffer.release();
    }

    return keySet==null?new ArrayList<String>():keySet;
}
 
开发者ID:denley,项目名称:WearPrefs,代码行数:19,代码来源:KeySetUtil.java

示例3: retrieveRideValues

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
public Bundle retrieveRideValues() {
    Log.d();
    Uri uri = createUri(CommConstants.PATH_RIDE_VALUES);
    PendingResult<DataItemBuffer> pendingResult = Wearable.DataApi.getDataItems(mGoogleApiClient, uri);
    DataItemBuffer dataItemBuffer = pendingResult.await();
    if (dataItemBuffer.getCount() == 0) {
        Log.d("No result");
        dataItemBuffer.release();
        return null;
    }
    DataItem dataItem = dataItemBuffer.get(0);
    DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
    Bundle res = dataMap.toBundle();
    Log.d("res=" + res);
    dataItemBuffer.release();
    return res;
}
 
开发者ID:BoD,项目名称:bikey,代码行数:18,代码来源:WearCommHelper.java

示例4: retrievePreferences

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
public String retrievePreferences(String prefExtraName) {
    Log.d();
    Uri uri = new Uri.Builder().scheme("wear").path(CommConstants.PATH_PREFERENCES).build();
    PendingResult<DataItemBuffer> pendingResult = Wearable.DataApi.getDataItems(mGoogleApiClient, uri);
    DataItemBuffer dataItemBuffer = pendingResult.await();
    if (dataItemBuffer.getCount() == 0) {
        Log.d("No result");
        dataItemBuffer.release();
        return null;
    }
    DataItem dataItem = dataItemBuffer.get(0);
    DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
    String res = dataMap.getString(prefExtraName);
    Log.d("res=" + res);
    dataItemBuffer.release();
    return res;
}
 
开发者ID:BoD,项目名称:bikey,代码行数:18,代码来源:WearCommHelper.java

示例5: handleDataItemsResult

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
private void handleDataItemsResult(DataItemBuffer paramDataItemBuffer)
{
  for (;;)
  {
    try
    {
      Status localStatus = paramDataItemBuffer.zzUc;
      if (!localStatus.isSuccess())
      {
        Object[] arrayOfObject = new Object[2];
        arrayOfObject[0] = Integer.valueOf(localStatus.zzakr);
        arrayOfObject[1] = localStatus.zzanv;
        FinskyLog.w("Error %d getting data items. (%s)", arrayOfObject);
        return;
      }
      this.mPackageStates = new HashMap();
      String str = this.mNodeId + "/package_info";
      int i = 0;
      int j = paramDataItemBuffer.getCount();
      if (i < j)
      {
        DataItem localDataItem = (DataItem)paramDataItemBuffer.get(i);
        if (localDataItem.getUri().toString().contains(str))
        {
          PackageStateRepository.PackageState localPackageState = stateFromDataItem(localDataItem);
          this.mPackageStates.put(localPackageState.packageName, localPackageState);
        }
      }
      else
      {
        this.mLastUpdatedUptimeMs = SystemClock.uptimeMillis();
        continue;
      }
      i++;
    }
    finally {}
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:39,代码来源:WearPackageStateRepository.java

示例6: handleDataItemsResult

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
private static void handleDataItemsResult(GoogleApiClient paramGoogleApiClient, DataItemBuffer paramDataItemBuffer)
{
  int i;
  String str;
  WearDeviceConfigurationHelper localWearDeviceConfigurationHelper;
  try
  {
    sNodeIds = Collections.emptyList();
    sWearHelpers = Collections.emptyMap();
    Status localStatus = paramDataItemBuffer.zzUc;
    if (!localStatus.isSuccess())
    {
      Object[] arrayOfObject2 = new Object[2];
      arrayOfObject2[0] = Integer.valueOf(localStatus.zzakr);
      arrayOfObject2[1] = localStatus.zzanv;
      FinskyLog.w("Error %d getting data items. (%s)", arrayOfObject2);
    }
    int j;
    do
    {
      return;
      i = 0;
      j = paramDataItemBuffer.getCount();
    } while (i >= j);
    DataItem localDataItem = (DataItem)paramDataItemBuffer.get(i);
    str = WearskyUris.getnodeId(localDataItem.getUri());
    localWearDeviceConfigurationHelper = new WearDeviceConfigurationHelper(str, localDataItem);
    if (localWearDeviceConfigurationHelper.versionCode < 80400050)
    {
      Object[] arrayOfObject1 = new Object[2];
      arrayOfObject1[0] = str;
      arrayOfObject1[1] = Integer.valueOf(localWearDeviceConfigurationHelper.versionCode);
      FinskyLog.d("Discard wear node %s because v=%d", arrayOfObject1);
    }
    else if ("0".equals(localWearDeviceConfigurationHelper.androidId))
    {
      FinskyLog.d("Discard wear node %s because androidId is 0", new Object[] { str });
      Wearable.MessageApi.sendMessage(paramGoogleApiClient, str, "get_device_configuration", EMPTY_BYTE_ARRAY).setResultCallback(new ResultCallback() {});
    }
  }
  finally {}
  String[] arrayOfString = localWearDeviceConfigurationHelper.deviceConfigurationProto.systemAvailableFeature;
  int k = arrayOfString.length;
  for (int m = 0;; m++)
  {
    int n = 0;
    if (m < k)
    {
      if ("android.hardware.type.watch".equals(arrayOfString[m])) {
        n = 1;
      }
    }
    else
    {
      if (n == 0)
      {
        FinskyLog.d("Discard wear node %s because not watch", new Object[] { str });
      }
      else
      {
        FinskyLog.d("Found wear node %s", new Object[] { str });
        if (sNodeIds.size() == 0) {
          sNodeIds = new ArrayList();
        }
        sNodeIds.add(str);
        if (sWearHelpers.size() == 0) {
          sWearHelpers = new HashMap();
        }
        sWearHelpers.put(str, localWearDeviceConfigurationHelper);
      }
      i++;
      break;
    }
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:76,代码来源:WearDeviceConfigurationHelper.java

示例7: copyPreferenceToLocal

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
private void copyPreferenceToLocal(DataItemBuffer buffer) {
    if (buffer.getCount() > 0) {
        final DataMap map = DataMap.fromByteArray(buffer.get(0).getData());
        loadPrefFromDataMap(map);
    }
}
 
开发者ID:denley,项目名称:WearPrefs,代码行数:7,代码来源:WearPrefs.java

示例8: onHandleIntent

import com.google.android.gms.wearable.DataItemBuffer; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "FindPhoneService.onHandleIntent");
    }
    if (mGoogleApiClient.isConnected()) {
        // Set the alarm off by default.
        boolean alarmOn = false;
        if (intent.getAction().equals(ACTION_TOGGLE_ALARM)) {
            // Get current state of the alarm.
            DataItemBuffer result = Wearable.DataApi.getDataItems(mGoogleApiClient).await();
            if (result.getStatus().isSuccess()) {
                if (result.getCount() == 1) {
                    alarmOn = DataMap.fromByteArray(result.get(0).getData())
                            .getBoolean(FIELD_ALARM_ON, false);
                } else {
                    Log.e(TAG, "Unexpected number of DataItems found.\n"
                             + "\tExpected: 1\n"
                             + "\tActual: " + result.getCount());
                }
            } else if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "onHandleIntent: failed to get current alarm state");
            }
            result.close();
            // Toggle alarm.
            alarmOn = !alarmOn;
            // Change notification text based on new value of alarmOn.
            String notificationText = alarmOn ? getString(R.string.turn_alarm_off)
                                              : getString(R.string.turn_alarm_on);
            FindPhoneActivity.updateNotification(this, notificationText);
        }
        // Use alarmOn boolean to update the DataItem - phone will respond accordingly
        // when it receives the change.
        PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_SOUND_ALARM);
        putDataMapRequest.getDataMap().putBoolean(FIELD_ALARM_ON, alarmOn);
        Wearable.DataApi.putDataItem(mGoogleApiClient, putDataMapRequest.asPutDataRequest())
                .await();
    } else {
        Log.e(TAG, "Failed to toggle alarm on phone - Client disconnected from Google Play "
                 + "Services");
    }
    mGoogleApiClient.disconnect();
}
 
开发者ID:mauimauer,项目名称:AndroidWearable-Samples,代码行数:45,代码来源:FindPhoneService.java


注:本文中的com.google.android.gms.wearable.DataItemBuffer.getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。