本文整理汇总了Java中com.google.android.gms.wearable.DataMapItem.fromDataItem方法的典型用法代码示例。如果您正苦于以下问题:Java DataMapItem.fromDataItem方法的具体用法?Java DataMapItem.fromDataItem怎么用?Java DataMapItem.fromDataItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMapItem
的用法示例。
在下文中一共展示了DataMapItem.fromDataItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());
for (DataEvent event : dataEvents) {
LOGD(TAG, "Uri is: " + event.getDataItem().getUri());
DataMapItem mapItem = DataMapItem.fromDataItem(event.getDataItem());
String path = event.getDataItem().getUri().getPath();
if (event.getType() == DataEvent.TYPE_CHANGED) {
if (PATH_RESPONSE.equals(path)) {
// we have a response
DataMap data = mapItem.getDataMap();
saveFeedback(data);
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
if (path.startsWith(SessionAlarmService.PATH_FEEDBACK)) {
Uri uri = event.getDataItem().getUri();
dismissLocalNotification(uri.getLastPathSegment());
}
}
}
}
示例2: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "Data changed");
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(
ConfigurationHelper.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
Log.d(TAG, "Config DataItem updated:" + config);
// This can happen from this method more often when phone changes
updateUiForConfigDataMap(config);
}
}
示例3: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(
WatchFaceUtil.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
Log.d(TAG, "Config DataItem updated:" + config);
updateUiForConfigDataMap(config);
}
}
示例4: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG,"onDataChanged "+dataEvents);
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(WatchFaceUtil.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
Log.d(TAG, "Config DataItem updated:" + config);
updateUiForConfigDataMap(config);
}
}
示例5: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : events) {
Uri uri = event.getDataItem().getUri();
String path = uri.getPath();
if (WEAR_PATH.equals(path)) {
DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
byte[] realmAsset = item.getDataMap().getByteArray(DATA_ASSET_FILE);
if (realmAsset != null) {
toFile(realmAsset);
getBaseContext().sendBroadcast(new Intent(DATA_STORY_CHANGED));
}
}
}
}
示例6: deleteSingleIgcFile
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
private void deleteSingleIgcFile(DataItem item) {
item.freeze();
DataMapItem dataMapItem = DataMapItem.fromDataItem(item);
String filename = dataMapItem.getDataMap().getString(Statics.DATADELETE);
File dir = getFilesDir();
File[] subFiles = dir.listFiles();
if (subFiles != null) {
for (File file : subFiles) {
if (filename.contains(Statics.getUTCdateReverse())) return;
if (file.getName().equals(filename)) {
if (file.delete()) {
if (debugMode) Log.d(TAG, "File " + filename + " is deleted.");
Wearable.DataApi.deleteDataItems(mGoogleApiClient, item.getUri());
} else {
if (debugMode) Log.d(TAG, "File " + filename + " delete error.");
}
}
}
}
}
示例7: getExceptionFromWear
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
private void getExceptionFromWear(DataItem dataItem) {
if (debugMode) Log.d(TAG, "Exception from wear!!!");
dataItem.freeze();
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
ByteArrayInputStream bis = new ByteArrayInputStream(dataMapItem.getDataMap().getByteArray("exception"));
Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItem.getUri());
try {
ObjectInputStream ois = new ObjectInputStream(bis);
Throwable ex = (Throwable) ois.readObject();
FirebaseCrash.log("board: " + dataMapItem.getDataMap().getString("board"));
FirebaseCrash.log("fingerprint: " + dataMapItem.getDataMap().getString("fingerprint"));
FirebaseCrash.log("model: " + dataMapItem.getDataMap().getString("model"));
FirebaseCrash.log("manufacturer: " + dataMapItem.getDataMap().getString("manufacturer"));
FirebaseCrash.log("product: " + dataMapItem.getDataMap().getString("product"));
FirebaseCrash.report(ex);
} catch (IOException | ClassNotFoundException e) {
FirebaseCrash.report(e);
if (debugMode) Log.e(TAG, Log.getStackTraceString(e));
}
}
示例8: getBTFailed
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
private void getBTFailed(DataItem dataItem) {
dataItem.freeze();
final Uri dataItemUri = dataItem.getUri();
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
final int reason = dataMapItem.getDataMap().getInt("reason");
if (debugMode) Log.d(TAG, "BT failed on wear, reason: " + reason);
switch (reason) {
case Statics.MY_BT_FAILED_NO_BT:
Toast.makeText(getApplicationContext(), R.string.bt_failed_no_bt, Toast.LENGTH_LONG).show();
break;
case Statics.MY_BT_FAILED_NO_DEVICE:
Toast.makeText(getApplicationContext(), R.string.bt_failed_no_device, Toast.LENGTH_LONG).show();
break;
case Statics.MY_BT_FAILED_USER:
Toast.makeText(getApplicationContext(), R.string.bt_failed_user, Toast.LENGTH_LONG).show();
break;
}
Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri);
prefs.edit().putBoolean(Statics.PREFUSEBTVARIO, false).apply();
checkBoxBT.setChecked(false);
}
示例9: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
for (DataEvent dataEvent : dataEventBuffer) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(
DigitalWatchFaceUtil.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
Log.d("WatchFace", "Config DataItem updated:" + config);
updateUiForConfigDataMap(config);
}
}
示例10: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvents);
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
Log.d(TAG, "onDataChanged: Path" + path);
switch (path) {
case Consts.Paths.GAME_INFORMATION:
DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
GameInformation info = GameInformation.fromDataMap(item.getDataMap());
GameState.getInstance().update(info);
updateDisplay();
break;
}
}
}
}
示例11: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(
SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
Log.d(TAG, "Config DataItem updated:" + config);
updateUiForConfigDataMap(config);
}
}
示例12: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
super.onDataChanged(dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
if (!mGoogleApiClient.isConnected()) {
ConnectionResult connectionResult = mGoogleApiClient
.blockingConnect(30, TimeUnit.SECONDS);
if (!connectionResult.isSuccess()) {
Log.e(TAG, "Service failed to connect to GoogleApiClient.");
return;
}
}
for(DataEvent event : events) {
if(event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if(DataInterface.PATH_NOTIFICATION.equals(path)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
updateOrShowNotification(dataMapItem);
}
}
}
}
示例13: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : events) {
Log.d(TAG, "Event: " + event.getDataItem().toString());
Uri uri = event.getDataItem().getUri();
String path = uri.getPath();
if (path.equals(Path.GRADE_SYSTEM)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
String gradeSystem = dataMapItem.getDataMap().getString(Path.GRADE_SYSTEM_KEY);
if (gradeSystem != null) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(Path.PREF_GRAD_SYSTEM_TYPE, gradeSystem);
editor.commit();
}
}
}
}
示例14: getBitmapFromDataApi
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
public Bitmap getBitmapFromDataApi(String path) {
final Uri uri = getUriForDataItem(path);
Log.d(TAG, "Load bitmap " + path + " " + uri.toString());
if (uri != null) {
final DataApi.DataItemResult result = Wearable.DataApi.getDataItem(mApiClient, uri).await();
if (result != null && result.getDataItem() != null) {
Log.d(TAG, "From DataApi");
final DataMapItem dataMapItem = DataMapItem.fromDataItem(result.getDataItem());
final Asset firstAsset = dataMapItem.getDataMap().getAsset(imageAssetName);
if (firstAsset != null) {
Bitmap bitmap = loadBitmapFromAsset(firstAsset);
return bitmap;
}
}
}
Log.d(TAG, "can't find " + path + " [" + imageAssetName + "] in DataApi");
return null;
}
示例15: onDataChanged
import com.google.android.gms.wearable.DataMapItem; //导入方法依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Config DataItem updated:" + config);
}
updateUiForConfigDataMap(config);
}
}
开发者ID:marcouberti,项目名称:african_sunsets_watch_face,代码行数:21,代码来源:WatchFaceCompanionConfigActivity.java