use of com.google.android.gms.wearable.DataEvent in project ETSMobile-Android2 by ApplETS.
the class ListenerService method onDataChanged.
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvents);
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem() != null && event.getDataItem().getUri().getPath().equals("/today_req")) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
ArrayList<DataMap> seancesDataMapList = dataMapItem.getDataMap().getDataMapArrayList("list_seances");
ArrayList<Seances> seances = new ArrayList<>();
for (DataMap seanceDataMap : seancesDataMapList) {
Seances seance = new Seances();
seance.getData(seanceDataMap);
seances.add(seance);
}
Intent intent = new Intent("seances_update");
intent.putExtra("seances", seances);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
super.onDataChanged(dataEvents);
}