本文整理匯總了Java中com.google.android.gms.wearable.DataEvent.getDataItem方法的典型用法代碼示例。如果您正苦於以下問題:Java DataEvent.getDataItem方法的具體用法?Java DataEvent.getDataItem怎麽用?Java DataEvent.getDataItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.wearable.DataEvent
的用法示例。
在下文中一共展示了DataEvent.getDataItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(LOG_TAG, " in data changed");
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo(WEATHER_PATH) == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
weather_id = dataMap.getInt(WEATHER_ID);
high_temp = dataMap.getDouble(HIGH_TEMP);
low_temp = dataMap.getDouble(LOW_TEMP);
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
// DataItem deleted
}
}
invalidate();
}
示例2: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
super.onDataChanged(dataEvents);
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo("/SHAKEINTENSITY") == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
Log.e("Data Event", "value->"+dataMap.getString(SHAKE_INTENSITY_KEY));
LocalStoreUtils.setShakeIntensity(dataMap.getString(SHAKE_INTENSITY_KEY), this);
}
}
}
}
示例3: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的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);
}
}
示例4: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的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);
}
}
示例5: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的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);
}
}
示例6: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
Log.i("WATCH", "onDataChanged");
for (DataEvent event : dataEventBuffer) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo(DATA_PATH) == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
extractWeatherData(dataMap);
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
// DataItem deleted
}
}
}
示例7: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
Log.d(TAG, "onDataChanged");
for (DataEvent event : dataEventBuffer) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
DataItem item = event.getDataItem();
String path = item.getUri().getPath();
Log.d(TAG, "path: " + path);
if (path.equals(REQ_PATH)) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
mWeatherId = dataMap.getInt(KEY_WEATHER_ID);
mMaxTemperature = dataMap.getDouble(KEY_TEMP_MAX);
mMinTemperature = dataMap.getDouble(KEY_TEMP_MIN);
mLocation = dataMap.getString(KEY_LOCATION);
invalidate();
}
}
}
dataEventBuffer.release();
}
示例8: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(LOG_TAG, "onDataChanged" );
for (DataEvent dataEvent : dataEvents) {
if (DataEvent.TYPE_CHANGED == dataEvent.getType()) {
DataItem dataItem = dataEvent.getDataItem();
DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
String path = dataEvent.getDataItem().getUri().getPath();
if (path.equals(WEATHER_PATH)) {
Log.d(LOG_TAG, "/weather id=" + dataMap.getString(KEY_UUID));
SunshineSyncAdapter.syncImmediately(this);
}
}
}
}
示例9: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
/**
* Called whenever a new message sent by the Wearable.
*
* @param dataEvents buffer with transmitted data
*/
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.i(TAG, "onDataChanged()");
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
DataItem dataItem = dataEvent.getDataItem();
Uri uri = dataItem.getUri();
String path = uri.getPath();
if (path.startsWith("/sensors/")) {
if (SmartWatch.getInstance() != null) {
SmartWatch.getInstance().unpackSensorData(DataMapItem.fromDataItem(dataItem).getDataMap());
}
}
}
}
}
示例10: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.i("DEV", "Wear: MainActivity.onDataChangeListener");
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo("/stayawhile/queue") == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
queueUpdated(dataMap.getString(QUEUE_KEY));
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
// DataItem deleted
}
}
}
示例11: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
DataItem dataItem = event.getDataItem();
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;
}
}
}
}
示例12: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的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);
}
}
示例13: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的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,項目名稱:american_sunsets_watch_face,代碼行數:21,代碼來源:WatchFaceCompanionConfigActivity.java
示例14: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for( DataEvent event : dataEvents ) {
if( event.getType() == DataEvent.TYPE_CHANGED ) {
DataItem item = event.getDataItem();
if( item.getUri().getPath().compareTo( DATA_LAYER_PATH ) == 0 ) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
int selectedBackgroundPosition = dataMap.getInt(KEY_BACKGROUND_POSITION);
TypedArray typedArray = getResources().obtainTypedArray( R.array.background_resource_ids );
initBackground( typedArray.getResourceId( selectedBackgroundPosition, 0 ) );
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
preferences.edit().putInt( SHARED_PREFERENCE_POSITION, selectedBackgroundPosition ).commit();
typedArray.recycle();
invalidate();
}
}
}
}
示例15: onDataChanged
import com.google.android.gms.wearable.DataEvent; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
super.onDataChanged(dataEvents);
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
DataItem dataItem = dataEvent.getDataItem();
Uri uri = dataItem.getUri();
String path = uri.getPath();
if (path.startsWith("/filter")) {
DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
int filterById = dataMap.getInt(DataMapKeys.FILTER);
deviceClient.setSensorFilter(filterById);
}
}
}
}