Search in sources :

Example 1 with DataEvent

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);
}
Also used : ArrayList(java.util.ArrayList) Intent(android.content.Intent) DataEvent(com.google.android.gms.wearable.DataEvent) Seances(ca.etsmtl.applets.etsmobile.Seances) DataMapItem(com.google.android.gms.wearable.DataMapItem) DataMap(com.google.android.gms.wearable.DataMap)

Aggregations

Intent (android.content.Intent)1 Seances (ca.etsmtl.applets.etsmobile.Seances)1 DataEvent (com.google.android.gms.wearable.DataEvent)1 DataMap (com.google.android.gms.wearable.DataMap)1 DataMapItem (com.google.android.gms.wearable.DataMapItem)1 ArrayList (java.util.ArrayList)1