com.google.android.gms.wearable.DataEvent Java Examples
The following examples show how to use
com.google.android.gms.wearable.DataEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override //DataListener public void onDataChanged(DataEventBuffer dataEvents) { LOGD(TAG, "onDataChanged: " + dataEvents); final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents); dataEvents.close(); runOnUiThread(new Runnable() { @Override public void run() { for (DataEvent event : events) { if (event.getType() == DataEvent.TYPE_CHANGED) { mDataItemListAdapter.add( new Event("DataItem Changed", event.getDataItem().toString())); } else if (event.getType() == DataEvent.TYPE_DELETED) { mDataItemListAdapter.add( new Event("DataItem Deleted", event.getDataItem().toString())); } } } }); }
Example #2
Source File: DaVinci.java From DaVinci with Apache License 2.0 | 6 votes |
/** * When received assets from DataApi * * @param dataEvents */ @Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { String path = dataEvent.getDataItem().getUri().getPath(); Log.d(TAG, "onDataChanged(" + path + ")"); if (path.startsWith(DAVINCI_PATH)) { //if it's a davinci path Log.d(TAG, "davinci-onDataChanged " + path); //download the bitmap and add it to cache Asset asset = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap().getAsset(DAVINCI_ASSET_IMAGE); Bitmap bitmap = loadBitmapFromAsset(asset); if (bitmap != null) saveBitmap(getKey(path), bitmap); //callbacks callIntoWaiting(path); } } }
Example #3
Source File: MainActivity.java From DaVinci with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem().getUri().getPath().startsWith("/elements/")) { DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem()); List<DataMap> elementsDataMap = dataMapItem.getDataMap().getDataMapArrayList("/list/"); if (elementList == null || elementList.isEmpty()) { elementList = new ArrayList<>(); for (DataMap dataMap : elementsDataMap) { elementList.add(getElement(dataMap)); } startMainScreen(); } } } }
Example #4
Source File: NotificationUpdateService.java From android-SynchronizedNotifications with Apache License 2.0 | 6 votes |
@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.WATCH_ONLY_ID); } } } }
Example #5
Source File: ListenerService.java From io2015-codelabs with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG, "onDataChanged: " + dataEvents); final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents); for (DataEvent event : events) { if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem() != null && Constants.ATTRACTION_PATH.equals(event.getDataItem().getUri().getPath())) { DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem()); ArrayList<DataMap> attractionsData = dataMapItem.getDataMap().getDataMapArrayList(Constants.EXTRA_ATTRACTIONS); showNotification(dataMapItem.getUri(), attractionsData); } } }
Example #6
Source File: ListenerService.java From io2015-codelabs with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG, "onDataChanged: " + dataEvents); final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents); for (DataEvent event : events) { if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem() != null && Constants.ATTRACTION_PATH.equals(event.getDataItem().getUri().getPath())) { DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem()); ArrayList<DataMap> attractionsData = dataMapItem.getDataMap().getDataMapArrayList(Constants.EXTRA_ATTRACTIONS); showNotification(dataMapItem.getUri(), attractionsData); } } }
Example #7
Source File: ConfigChangeListenerService.java From FORMWatchFace with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(final DataEventBuffer dataEvents) { ConfigHelper configHelper = new ConfigHelper(this); if (!configHelper.connect()) { return; } String localNodeId = configHelper.getLocalNodeId(); for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } Uri uri = dataEvent.getDataItem().getUri(); if (!TextUtils.equals(uri.getHost(), localNodeId) && uri.getPath().equals("/config")) { configHelper.readConfigSharedPrefsFromDataLayer(); } } configHelper.disconnect(); }
Example #8
Source File: UARTCommandsActivity.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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 != configurationId) 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(() -> adapter.setConfiguration(configuration)); } else if (event.getType() == DataEvent.TYPE_DELETED) { // Configuration removed // Update UI on UI thread runOnUiThread(() -> adapter.setConfiguration(null)); } } }
Example #9
Source File: Emmet.java From Wear-Emmet with Apache License 2.0 | 6 votes |
public Emmet onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { String path = dataEvent.getDataItem().getUri().getPath(); if (ENABLE_LOG) Log.d(TAG, "onDataChanged(" + path + ")"); if (path.startsWith(PATH)) { //if it's an Emmet path if (ENABLE_LOG) Log.d(TAG, "emmet-onDataChanged " + path); try { DataMap methodDataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap(); callMethodOnInterfaces(methodDataMap); } catch (Throwable t) { Log.e(TAG, "error decoding datamap", t); } } } return this; }
Example #10
Source File: WatchFaceCompanionConfigActivity.java From american-sunsets-watch-face with Apache License 2.0 | 6 votes |
@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); } }
Example #11
Source File: SunsetsWatchFace.java From american-sunsets-watch-face with Apache License 2.0 | 6 votes |
@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); } }
Example #12
Source File: NotificationUpdateService.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@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); } } } }
Example #13
Source File: HomeListenerService.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
/** * 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(); }
Example #14
Source File: MessageReceiverService.java From SensorDashboard with Apache License 2.0 | 6 votes |
@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); } } } }
Example #15
Source File: SensorReceiverService.java From SensorDashboard with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(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/")) { unpackSensorData( Integer.parseInt(uri.getLastPathSegment()), DataMapItem.fromDataItem(dataItem).getDataMap() ); } } } }
Example #16
Source File: WearDataLayerListenerService.java From climb-tracker with Apache License 2.0 | 6 votes |
@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(); } } } }
Example #17
Source File: HomeListenerService.java From android-Geofencing with Apache License 2.0 | 6 votes |
/** * 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()); } } }
Example #18
Source File: SensorReceiverService.java From wearabird with MIT License | 6 votes |
@Override public void onDataChanged(DataEventBuffer 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("/sensors/")) { unpackSensorData( Integer.parseInt(uri.getLastPathSegment()), DataMapItem.fromDataItem(dataItem).getDataMap() ); } } } }
Example #19
Source File: CollectionActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { Log.i("Test", "Data changed event received"); // Get the data changed event and handle it appropriately for(DataEvent event : dataEventBuffer) { if (event.getType() == DataEvent.TYPE_CHANGED) { DataItem item = event.getDataItem(); String path = item.getUri().getPath(); switch (path) { case LAYER_RESPONSE: handleLayerResponse(item); break; case FEATURE_TYPE_RESPONSE: handleFeatureTypeResponse(item); break; case STATUS_RESPONSE: handleStatusResponse(item); break; } } } }
Example #20
Source File: MainActivity.java From DronesWear with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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; } } } }
Example #21
Source File: DataLayerListenerService.java From LibreAlarm with GNU General Public License v3.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { // Check the data path String path = event.getDataItem().getUri().getPath(); if (WearableApi.SETTINGS.equals(path)) { HashMap<String, String> newSettings = new HashMap<>(); DataMap dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); for (String key : dataMap.keySet()) { newSettings.put(key, dataMap.getString(key, null)); PreferencesUtil.putString(this, key, newSettings.get(key)); } WearableApi.sendMessage(mGoogleApiClient, WearableApi.SETTINGS, PreferencesUtil.toString(newSettings), null); sendStatus(mGoogleApiClient); } } } }
Example #22
Source File: WatchUpdaterService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) {//KS does not seem to get triggered; therefore use OnMessageReceived instead DataMap dataMap; for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { String path = event.getDataItem().getUri().getPath(); switch (path) { case WEARABLE_PREF_DATA_PATH: dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); if (dataMap != null) { Log.d(TAG, "onDataChanged WEARABLE_PREF_DATA_PATH dataMap=" + dataMap); syncPrefData(dataMap); } break; default: Log.d(TAG, "Unknown wearable path: " + path); break; } } } }
Example #23
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) {//KS does not seem to get triggered; therefore use OnMessageReceived instead DataMap dataMap; for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { String path = event.getDataItem().getUri().getPath(); switch (path) { case WEARABLE_PREF_DATA_PATH: dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); if (dataMap != null) { Log.d(TAG, "onDataChanged WEARABLE_PREF_DATA_PATH dataMap=" + dataMap); syncPrefData(dataMap); } break; default: Log.d(TAG, "Unknown wearable path: " + path); break; } } } }
Example #24
Source File: WatchFace.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
@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(); } } } }
Example #25
Source File: MainActivity.java From wear with MIT License | 6 votes |
@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(); } }
Example #26
Source File: DataListenerTest.java From wear with MIT License | 6 votes |
public void testDataChanged() { DataItem item = Mockito.mock(DataItem.class); Mockito.when(item.getUri()).thenReturn(Uri.parse(DATA_PATH)); DataEvent event = Mockito.mock(DataEvent.class); Mockito.when(event.getType()).thenReturn(DataEvent.TYPE_CHANGED); Mockito.when(event.getDataItem()).thenReturn(item); DataListener listener = new DataListener(); DataListener.Callback callback = Mockito.mock(DataListener.Callback.class); listener.addCallback(DATA_PATH, callback); // TODO Mockito.verify(callback).onDataChanged(event); Mockito.verifyNoMoreInteractions(callback); }
Example #27
Source File: ListenerService.java From wear-os-samples with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG, "onDataChanged: " + dataEvents); for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem() != null && Constants.ATTRACTION_PATH.equals(event.getDataItem().getUri().getPath())) { DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem()); ArrayList<DataMap> attractionsData = dataMapItem.getDataMap().getDataMapArrayList(Constants.EXTRA_ATTRACTIONS); showNotification(dataMapItem.getUri(), attractionsData); } } }
Example #28
Source File: MainActivity.java From wearable with Apache License 2.0 | 6 votes |
@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()); } } }
Example #29
Source File: MainActivity.java From wearable with Apache License 2.0 | 6 votes |
/** * 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()); } } }
Example #30
Source File: DigitalWatchFaceService.java From wear-os-samples with Apache License 2.0 | 6 votes |
@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( DigitalWatchFaceUtil.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); } }