當前位置: 首頁>>代碼示例>>Java>>正文


Java DataEvent.TYPE_DELETED屬性代碼示例

本文整理匯總了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();
}
 
開發者ID:rashikaranpuria,項目名稱:ubiquitous,代碼行數:19,代碼來源:MyWatchFace.java

示例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());
            }
        }
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:22,代碼來源:FeedbackWearableListenerService.java

示例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
        }
    }
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:16,代碼來源:MainActivity.java

示例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
        }
    }
}
 
開發者ID:frank-tan,項目名稱:Sunshine-Android-Wear,代碼行數:17,代碼來源:DigitalWatchFace.java

示例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));
		}
	}
}
 
開發者ID:NordicSemiconductor,項目名稱:Android-nRF-Toolbox,代碼行數:25,代碼來源:UARTCommandsActivity.java

示例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());
            }
        }
    }
}
 
開發者ID:The-WebOps-Club,項目名稱:saarang-iosched,代碼行數:18,代碼來源:HomeListenerService.java

示例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);
        }
    }
}
 
開發者ID:josemontiel,項目名稱:SunshineWatchFace,代碼行數:19,代碼來源:SunshineWatchFace.java

示例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;
        }
    }
  }
}
 
開發者ID:jimblackler,項目名稱:YourPhotosWatch,代碼行數:26,代碼來源:BaseWatchService.java

示例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);
            }
        });
    }
}
 
開發者ID:DroidPlanner,項目名稱:tower-wear,代碼行數:22,代碼來源:BaseActivity.java

示例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));
                }
            });
        }
    }
}
 
開發者ID:bati11,項目名稱:wear-datalayer-sample,代碼行數:18,代碼來源:DataItemSampleActivity.java

示例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);
            }
        }
    }
}
 
開發者ID:mauimauer,項目名稱:AndroidWearable-Samples,代碼行數:24,代碼來源:NotificationUpdateService.java

示例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();
}
 
開發者ID:mauimauer,項目名稱:AndroidWearable-Samples,代碼行數:20,代碼來源:HomeListenerService.java

示例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();
    }
}
 
開發者ID:ezhuk,項目名稱:wear,代碼行數:21,代碼來源:MainActivity.java

示例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());
        }
    }
}
 
開發者ID:JimSeker,項目名稱:wearable,代碼行數:23,代碼來源:MainActivity.java

示例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());
        }
    }
}
 
開發者ID:JimSeker,項目名稱:wearable,代碼行數:27,代碼來源:MainActivity.java


注:本文中的com.google.android.gms.wearable.DataEvent.TYPE_DELETED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。