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


Java DataItemBuffer类代码示例

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


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

示例1: populateConfigurations

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
/**
 * This method read the UART configurations from the DataApi and populates the adapter with them.
 */
private void populateConfigurations() {
	if (mGoogleApiClient.isConnected()) {
		final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX);
		results.setResultCallback(new ResultCallback<DataItemBuffer>() {
			@Override
			public void onResult(final DataItemBuffer dataItems) {
				final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount());
				for (int i = 0; i < dataItems.getCount(); ++i) {
					final DataItem item = dataItems.get(i);
					final long id = ContentUris.parseId(item.getUri());
					final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
					final UartConfiguration configuration = new UartConfiguration(dataMap, id);
					configurations.add(configuration);
				}
				mAdapter.setConfigurations(configurations);
				dataItems.release();
			}
		});
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:24,代码来源:UARTConfigurationsActivity.java

示例2: 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

示例3: getAllAvailableDataItems

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
private void getAllAvailableDataItems() {
    PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient);
    results.setResultCallback(new ResultCallback<DataItemBuffer>() {
        @Override
        public void onResult(@NonNull DataItemBuffer dataItems) {
            if (dataItems.getCount() != 0) {
                for (DataItem item : dataItems) {
                    if (item.getUri().getPath().contains(Statics.DATAIGC)) {
                        getStringFromAsset(item);
                    }
                    if (item.getUri().getPath().contains(Statics.DATATHROWABLE)) {
                        getExceptionFromWear(item);
                    }
                    if (item.getUri().getPath().contains(Statics.DATABTFAILED)) {
                        getBTFailed(item);
                    }
                }
            }
            dataItems.release();
        }
    });
}
 
开发者ID:pulce,项目名称:Wristglider,代码行数:23,代码来源:MainActivity.java

示例4: getDataItems

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
/**
 * Retrieves data items asynchronously. Caller can specify a {@link ResultCallback} or pass a
 * {@code null}; if a {@code null} is passed, a default {@link ResultCallback} will be used
 * that calls {@link DataConsumer#onGetDataItems(int, DataItemBuffer)}.
 *
 * @see DataConsumer#onGetDataItems(int, DataItemBuffer)
 */
public void getDataItems(@Nullable final ResultCallback<? super DataItemBuffer> callback) {
    assertApiConnectivity();
    Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(
            new ResultCallback<DataItemBuffer>() {
                @Override
                public void onResult(DataItemBuffer dataItems) {
                    try {
                        int statusCode = dataItems.getStatus().getStatusCode();
                        if (!dataItems.getStatus().isSuccess()) {
                            Log.e(TAG, "Failed to get items, status code: " + statusCode);
                        }
                        if (callback == null) {
                            for (DataConsumer consumer : mDataConsumers) {
                                consumer.onGetDataItems(statusCode, dataItems);
                            }
                        } else {
                            callback.onResult(dataItems);
                        }
                    } finally {
                        dataItems.release();
                    }
                }
            });
}
 
开发者ID:csarron,项目名称:GmsWear,代码行数:32,代码来源:GmsWear.java

示例5: onConnected

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
    Wearable.DataApi.addListener(mGoogleApiClient, this);

    // get existing data
    PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient);
    results.setResultCallback(new ResultCallback<DataItemBuffer>() {
        @Override
        public void onResult(@NonNull DataItemBuffer dataItems) {
            for (DataItem dataItem : dataItems) {
                switch (Message.getMessageType(dataItem)) {
                    case ACTION_TYPE:
                        int productAction = Message.decodeActionTypeMessage(dataItem);
                        onActionTypeChanged(productAction);
                        break;
                    case INTERACTION_TYPE:
                        int interactionType = Message.decodeInteractionTypeMessage(dataItem);
                        onInteractionTypeChanged(interactionType);
                        break;
                }
            }
            dataItems.release();
        }
    });
}
 
开发者ID:Parrot-Developers,项目名称:DronesWear,代码行数:26,代码来源:MainActivity.java

示例6: getDataItems

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
public final PendingResult<DataItemBuffer> getDataItems(GoogleApiClient paramGoogleApiClient, final Uri paramUri, final int paramInt)
{
  if (paramUri != null) {}
  for (boolean bool1 = true;; bool1 = false)
  {
    com.google.android.gms.common.internal.zzx.zzb(bool1, "uri must not be null");
    boolean bool2;
    if (paramInt != 0)
    {
      bool2 = false;
      if (paramInt != 1) {}
    }
    else
    {
      bool2 = true;
    }
    com.google.android.gms.common.internal.zzx.zzb(bool2, "invalid filter type");
    paramGoogleApiClient.zza(new zzi(paramGoogleApiClient) {});
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:21,代码来源:zzx.java

示例7: updateSettings

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
/**
 * Retrieve wear settings from Wear cloud storage
 */
public void updateSettings(Context context) {
    if (!googleApiClient.isConnected()) {
        if (!blockingConnect()) {
            return;
        }
    }

    ArrayList<DataMap> data;
    DataItemBuffer dataItemBuffer = Wearable.DataApi.getDataItems(googleApiClient).await();

    if (dataItemBuffer.getStatus().isSuccess()) {
        for (DataItem dataItem : dataItemBuffer) {
            DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
            data = dataMapItem.getDataMap().getDataMapArrayList(WearableConstants.EXTRA_SETTINGS);
            if (data != null) {
                ListenerService.extractSettings(data);
                break;
            }
        }
    }
    dataItemBuffer.release();
}
 
开发者ID:Power-Switch,项目名称:PowerSwitch_Android,代码行数:26,代码来源:DataApiHandler.java

示例8: populateConfigurations

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
/**
 * This method read the UART configurations from the DataApi and populates the adapter with them.
 */
private void populateConfigurations() {
	if (mGoogleApiClient.isConnected()) {
		final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX);
		results.setResultCallback(dataItems -> {
			final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount());
			for (int i = 0; i < dataItems.getCount(); ++i) {
				final DataItem item = dataItems.get(i);
				final long id = ContentUris.parseId(item.getUri());
				final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
				final UartConfiguration configuration = new UartConfiguration(dataMap, id);
				configurations.add(configuration);
			}
			mAdapter.setConfigurations(configurations);
			dataItems.release();
		});
	}
}
 
开发者ID:NordicSemiconductor,项目名称:Android-nRF-Toolbox,代码行数:21,代码来源:UARTConfigurationsActivity.java

示例9: 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

示例10: onConnected

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
@Override
public void onConnected(Bundle connectionHint) {
  Wearable.DataApi.addListener(googleApiClient, this);

  Wearable.DataApi.getDataItems(googleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() {
    @Override
    public void onResult(DataItemBuffer dataItems) {
      for (DataItem dataItem : dataItems) {
        String[] parts = dataItem.getUri().getPath().split("/");
        switch (parts[1]) {
          case "image":
            photos.put(parts[2], dataItem);
            break;
          default:
            break;
        }
      }
      invalidate();
    }
  });
}
 
开发者ID:jimblackler,项目名称:YourPhotosWatch,代码行数:22,代码来源:BaseWatchService.java

示例11: onConnected

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
  Wearable.DataApi.addListener(googleApiClient, this);

  Wearable.DataApi.getDataItems(googleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() {
    @Override
    public void onResult(DataItemBuffer dataItems) {
      for (DataItem dataItem : dataItems) {
        String[] parts = dataItem.getUri().getPath().split("/");
        switch (parts[1]) {
          case "image":
            String photoId = parts[2];
            enabledPhotos.add(photoId);
            PhotoListEntry photoListEntry = photosById.get(photoId);
            if (photoListEntry == null)
              continue;
            recyclerAdapter.notifyItemChanged(photoListEntry.getPosition());
            break;
          default:
            break;
        }
      }
    }
  });
}
 
开发者ID:jimblackler,项目名称:YourPhotosWatch,代码行数:26,代码来源:BasePhotoSelectActivity.java

示例12: reloadVehicleData

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
protected void reloadVehicleData(String dataType){
    final String dataPath = WearUtils.VEHICLE_DATA_PREFIX + dataType;
    apiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            final Uri dataItemUri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path(dataPath)
                    .build();

            Wearable.DataApi.getDataItems(getGoogleApiClient(), dataItemUri)
                    .setResultCallback(new ResultCallback<DataItemBuffer>() {
                        @Override
                        public void onResult(DataItemBuffer dataItemBuffer) {
                            final int dataCount = dataItemBuffer.getCount();
                            for(int i = 0; i < dataCount; i++) {
                                final DataItem dataItem = dataItemBuffer.get(i);
                                if (dataItem != null)
                                    onDataItemReceived(dataItem, DataEvent.TYPE_CHANGED);
                            }

                            dataItemBuffer.release();
                        }
                    });
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:26,代码来源:BaseActivity.java

示例13: updateContextStreamNotification

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
private void updateContextStreamNotification() {
    final String dataPath = WearUtils.VEHICLE_DATA_PREFIX + AttributeType.STATE;
    apiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            final Uri dataItemUri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path(dataPath).build();

            Wearable.DataApi.getDataItems(getGoogleApiClient(), dataItemUri)
                    .setResultCallback(new ResultCallback<DataItemBuffer>() {
                        @Override
                        public void onResult(DataItemBuffer dataItems) {
                            final int dataCount = dataItems.getCount();
                            for (int i = 0; i < dataCount; i++) {
                                final DataItem dataItem = dataItems.get(i);
                                handleDataItem(dataItem, DataEvent.TYPE_CHANGED);
                            }

                            dataItems.release();
                        }
                    });
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:24,代码来源:WearReceiverService.java

示例14: onDeleteEventsClicked

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
public void onDeleteEventsClicked(View v) {
    if (mGoogleApiClient.isConnected()) {
        Wearable.DataApi.getDataItems(mGoogleApiClient)
                .setResultCallback(new ResultCallback<DataItemBuffer>() {
                    @Override
                    public void onResult(DataItemBuffer result) {
                        if (result.getStatus().isSuccess()) {
                            deleteDataItems(result);
                        } else {
                            if (Log.isLoggable(TAG, Log.DEBUG)) {
                                Log.d(TAG, "onDeleteEventsClicked(): failed to get Data Items");
                            }
                        }
                        result.close();
                    }
                });
    } else {
        Log.e(TAG, "Failed to delete data items"
                 + " - Client disconnected from Google Play Services");
    }
}
 
开发者ID:mauimauer,项目名称:AndroidWearable-Samples,代码行数:22,代码来源:MainActivity.java

示例15: onDeleteEventsClicked

import com.google.android.gms.wearable.DataItemBuffer; //导入依赖的package包/类
public void onDeleteEventsClicked(View view) {
    if (mGoogleApiClient.isConnected()) {
        Wearable.DataApi.getDataItems(mGoogleApiClient)
                .setResultCallback(new ResultCallback<DataItemBuffer>() {
                    @Override
                    public void onResult(DataItemBuffer result) {
                        try {
                            if (result.getStatus().isSuccess()) {
                                deleteDataItems(result);
                            } else {
                                if (Log.isLoggable(TAG, Log.DEBUG)) {
                                    Log.d(TAG, "onDeleteEventsClicked(): failed to get Data "
                                            + "Items");
                                }
                            }
                        } finally {
                            result.release();
                        }
                    }
                });
    } else {
        Log.e(TAG, "Failed to delete data items"
                + " - Client disconnected from Google Play Services");
    }
}
 
开发者ID:googlesamples,项目名称:android-AgendaData,代码行数:26,代码来源:MainActivity.java


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