本文整理匯總了Java中com.google.android.gms.wearable.DataEvent.TYPE_DELETED屬性的典型用法代碼示例。如果您正苦於以下問題:Java DataEvent.TYPE_DELETED屬性的具體用法?Java DataEvent.TYPE_DELETED怎麽用?Java DataEvent.TYPE_DELETED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.google.android.gms.wearable.DataEvent
的用法示例。
在下文中一共展示了DataEvent.TYPE_DELETED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDataChanged
@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
@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());
}
}
}
}
示例3: onDataChanged
@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
}
}
}
示例4: onDataChanged
@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
}
}
}
示例5: onDataChanged
@Override
public void onDataChanged(final DataEventBuffer dataEventBuffer) {
for (final DataEvent event : dataEventBuffer) {
final DataItem item = event.getDataItem();
final long id = ContentUris.parseId(item.getUri());
// Update the configuration only if ID matches
if (id != mConfigurationId)
continue;
// Configuration added or edited
if (event.getType() == DataEvent.TYPE_CHANGED) {
final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
final UartConfiguration configuration = new UartConfiguration(dataMap, id);
// Update UI on UI thread
runOnUiThread(() -> mAdapter.setConfiguration(configuration));
} else if (event.getType() == DataEvent.TYPE_DELETED) {
// Configuration removed
// Update UI on UI thread
runOnUiThread(() -> mAdapter.setConfiguration(null));
}
}
}
示例6: onDataChanged
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());
for (DataEvent event : dataEvents) {
Uri uri = event.getDataItem().getUri();
LOGD(TAG, "onDataChanged(): Received a data item change with uri: " + uri.toString());
if (event.getType() == DataEvent.TYPE_DELETED) {
if (uri.getPath().startsWith(PATH_FEEDBACK)) {
dismissLocalNotification(uri.getLastPathSegment());
}
} else if (event.getType() == DataEvent.TYPE_CHANGED) {
if (uri.getPath().startsWith(PATH_FEEDBACK)) {
setupNotification(event.getDataItem());
}
}
}
}
示例7: onDataChanged
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
Log.d(TAG, "onDataChanged: " + dataEventBuffer);
for (DataEvent event : dataEventBuffer) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// DataItem changed
} else if (event.getType() == DataEvent.TYPE_DELETED) {
// DataItem deleted
}
DataItem item = event.getDataItem();
if (item.getUri().getPath().compareTo("/forecast") == 0) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
updateUiforDataMap(dataMap);
}
}
}
示例8: onDataChanged
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
ArrayList<DataEvent> dataEvents1 = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : dataEvents1) {
DataItem dataItem = event.getDataItem();
String[] parts = dataItem.getUri().getPath().split("/");
switch (parts[1]) {
case "image":
String photoId = parts[2];
switch (event.getType()) {
case DataEvent.TYPE_CHANGED:
photos.put(photoId, dataItem);
// Show new image immediately (even in ambient mode).
updateImage(dataItem);
extraWake();
break;
case DataEvent.TYPE_DELETED:
photos.remove(photoId);
if (currentPhoto.equals(photoId))
setEmptyBackground();
break;
}
}
}
}
示例9: onDataItemReceived
private void onDataItemReceived(DataItem dataItem, int eventType){
final Uri dataUri = dataItem.getUri();
final String dataPath = dataUri.getPath();
if (dataPath.startsWith(WearUtils.VEHICLE_DATA_PREFIX)) {
final String dataType = dataPath.replace(WearUtils.VEHICLE_DATA_PREFIX, "");
final byte[] eventData;
if(eventType == DataEvent.TYPE_DELETED)
eventData = null;
else{
eventData = dataItem.getData();
}
handler.post(new Runnable() {
@Override
public void run() {
onVehicleDataUpdated(dataType, eventData);
}
});
}
}
示例10: onDataChanged
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_DELETED) {
Log.d("TAG", "DataItem deleted: " + event.getDataItem().getUri());
} else if (event.getType() == DataEvent.TYPE_CHANGED) {
Log.d("TAG", "DataItem changed: " + event.getDataItem().getUri());
DataMap dataMap = DataMap.fromByteArray(event.getDataItem().getData());
count = dataMap.getInt("key");
runOnUiThread(new Runnable() {
@Override
public void run() {
textView.setText(Integer.toString(count));
}
});
}
}
}
示例11: onDataChanged
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
String content = dataMap.getString(Constants.KEY_CONTENT);
String title = dataMap.getString(Constants.KEY_TITLE);
if (Constants.WATCH_ONLY_PATH.equals(dataEvent.getDataItem().getUri().getPath())) {
buildWearableOnlyNotification(title, content, false);
} else if (Constants.BOTH_PATH.equals(dataEvent.getDataItem().getUri().getPath())) {
buildWearableOnlyNotification(title, content, true);
}
} else if (dataEvent.getType() == DataEvent.TYPE_DELETED) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "DataItem deleted: " + dataEvent.getDataItem().getUri().getPath());
}
if (Constants.BOTH_PATH.equals(dataEvent.getDataItem().getUri().getPath())) {
// Dismiss the corresponding notification
((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
.cancel(Constants.BOTH_ID);
}
}
}
}
示例12: onDataChanged
/**
* Listen for DataItems added/deleted from the geofence service running on the companion.
*/
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());
}
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_DELETED) {
cancelNotificationForDataItem(event.getDataItem());
} else if (event.getType() == DataEvent.TYPE_CHANGED) {
// The user has entered a geofence - post a notification!
String geofenceId = DataMap.fromByteArray(event.getDataItem().getData())
.getString(KEY_GEOFENCE_ID);
postNotificationForGeofenceId(geofenceId, event.getDataItem().getUri());
}
}
dataEvents.close();
}
示例13: onDataChanged
@Override
public void onDataChanged(DataEvent event) {
if (DataEvent.TYPE_CHANGED == event.getType()) {
DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
Asset asset = item.getDataMap().getAsset(ASSET_KEY);
ConnectionResult result = mGoogleApiClient
.blockingConnect(TIMEOUT, TimeUnit.SECONDS);
if (result.isSuccess()) {
InputStream stream = Wearable.DataApi
.getFdForAsset(mGoogleApiClient, asset)
.await().getInputStream();
if (null != asset) {
Bitmap bitmap = BitmapFactory.decodeStream(stream);
showAsset(bitmap);
}
}
} else if (DataEvent.TYPE_DELETED == event.getType()) {
hideAsset();
}
}
示例14: onDataChanged
@Override
public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) {
Log.d(TAG, "onDataChanged: " + dataEventBuffer);
for (DataEvent event : dataEventBuffer) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if (datapath.equals(path)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
String message = dataMapItem.getDataMap().getString("message");
Log.v(TAG, "Wear activity received message: " + message);
// Display message in UI
mTextView.setText(message);
} else {
Log.e(TAG, "Unrecognized path: " + path);
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
Log.v(TAG, "Data deleted : " + event.getDataItem().toString());
} else {
Log.e(TAG, "Unknown data event Type = " + event.getType());
}
}
}
示例15: onDataChanged
/**
* Receives the data, note since we are using the same data base, we will also receive
* data that we sent as well. Likely should add some kind of id number to datamap, so it
* can tell between mobile device and wear device. or this maybe the functionality you want.
*/
@Override
public void onDataChanged(@NonNull DataEventBuffer dataEventBuffer) {
Log.d(TAG, "onDataChanged: " + dataEventBuffer);
for (DataEvent event : dataEventBuffer) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if (datapath.equals(path)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
String message = dataMapItem.getDataMap().getString("message");
Log.v(TAG, "Wear activity received message: " + message);
// Display message in UI
logthis(message);
} else {
Log.e(TAG, "Unrecognized path: " + path);
}
} else if (event.getType() == DataEvent.TYPE_DELETED) {
Log.v(TAG, "Data deleted : " + event.getDataItem().toString());
} else {
Log.e(TAG, "Unknown data event Type = " + event.getType());
}
}
}