Java 类com.google.android.gms.wearable.DataEvent 实例源码

项目:ubiquitous    文件:MyWatchFace.java   
@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();
}
项目:iosched-reader    文件:FeedbackWearableListenerService.java   
@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());
            }
        }
    }
}
项目:Android_watch_magpie    文件:ListenerSyncRule.java   
/**
 * This method is activated when a data is receive from the phone
 * @param dataEvents
 */
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    DataMap dataMap;
    for (DataEvent event : dataEvents) {
        // Check the data type
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // Check the data path
            dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

            //get the new rule send by the phone
            CustomRules rule= getRuleFromMap(dataMap);

            //save the rule in the database
            RulesRepository.getInstance().insertOrUpdate(rule);

            //send the value to the activty to change the display of bar

            Intent messageIntent = new Intent();
            messageIntent.setAction(Intent.ACTION_SEND);
            messageIntent.putExtra(Const.KEY_BROADCASTdATA, dataMap.toBundle());
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        }
    }
}
项目:Excuser    文件:DataLayerListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);

    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            if (item.getUri().getPath().compareTo("/SHAKEINTENSITY") == 0) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

                Log.e("Data Event", "value->"+dataMap.getString(SHAKE_INTENSITY_KEY));
                LocalStoreUtils.setShakeIntensity(dataMap.getString(SHAKE_INTENSITY_KEY), this);
            }
        }
    }

}
项目:zabbkit-android    文件:TriggersRequestService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            if (ZabbkitConstants.PATH_DATA_REQUEST.equals(dataEvent.getDataItem().getUri().getPath())) {

                Map<String, Object> params = new ArrayMap<String, Object>();

                params.put(Constants.REQ_SELECT_HOSTS, new String[]{
                        Constants.REQ_VAL_HOST_ID, Constants.REQ_VAL_HOST});
                params.put(Constants.REQ_SORT_FIELD, Constants.REQ_VAL_DESCRIPTION);
                params.put(Constants.REQ_OUTPUT, Constants.REQ_VAL_EXTEND);
                params.put(Constants.REQ_MONITORED, true);
                params.put(Constants.REQ_EXPAND_DESCRIPTION, true);
                Communicator.getInstance().getTriggers(params, this);

            }
        }
    }
}
项目:nano-go-ubiquitous    文件:SunshineWearListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    for (int i = 0; i < dataEvents.getCount(); i++) {
        DataEvent event = dataEvents.get(i);

        if (event.getType() == DataEvent.TYPE_CHANGED &&
                event.getDataItem().getUri().getPath().equals(APP_DATA_UPDATE_REQUEST)) {
            DataMap dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

            Asset asset = dataMap.getAsset("dataIcon");
            WatchFaceService.highTemp = dataMap.getInt("dataHigh");
            WatchFaceService.lowTemp = dataMap.getInt("dataLow");

            doLoadBitmap(asset);
        }
    }
}
项目:Athletica    文件:WatchFaceService.java   
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "Data changed");
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                ConfigurationHelper.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);
        // This can happen from this method more often when phone changes
        updateUiForConfigDataMap(config);
    }
}
项目:ubiquitous    文件:MyWatchFace.java   
@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();
}
项目:adrenaline_watch_face    文件:SonicBoomFace.java   
@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(
                WatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
项目:adrenaline_watch_face    文件:WatchFaceCompanionConfigActivity.java   
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG,"onDataChanged "+dataEvents);
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(WatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
项目:smconf-android    文件:FeedbackWearableListenerService.java   
@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());
            }
        }
    }
}
项目:wearDrip    文件:ListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
    dataEvents.close();
    for (DataEvent event : events) {
        Uri uri = event.getDataItem().getUri();
        String path = uri.getPath();
        if (WEAR_PATH.equals(path)) {
            DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
            byte[] realmAsset = item.getDataMap().getByteArray(DATA_ASSET_FILE);
            if (realmAsset != null) {
                toFile(realmAsset);
                getBaseContext().sendBroadcast(new Intent(DATA_STORY_CHANGED));
            }
        }
    }
}
项目:WearApp    文件:DataListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);
    DataMap dataMap = new DataMap();

    for(DataEvent dataEvent : dataEvents){
        if(dataEvent.getType()==DataEvent.TYPE_CHANGED){
            String path = dataEvent.getDataItem().getUri().getPath();

            if(path.equalsIgnoreCase(MOBILE_MESSAGE_PATH)){
                dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
            }
        }
    }

    Intent messageIntent = new Intent();
    messageIntent.setAction(Intent.ACTION_SEND);
    messageIntent.putExtra("datamap", dataMap.toBundle());
    LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
}
项目:xDrip    文件:WatchUpdaterService.java   
@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;
            }
        }
    }
}
项目:xDrip-plus    文件:WatchUpdaterService.java   
@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;
            }
        }
    }
}
项目:go-ubiquitous    文件:SunshineWatchFace.java   
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    Log.d(LOG_TAG, "Weather data has been changed!");
    for (DataEvent event : dataEventBuffer) {
        DataItem item = event.getDataItem();
        if (WEATHER_DATA_PATH.equals(item.getUri().getPath())) {
            DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
            double high = dataMap.getDouble(WEATHER_DATA_HIGH);
            double low = dataMap.getDouble(WEATHER_DATA_LOW);
            long id = dataMap.getLong(WEATHER_DATA_ID);

            mWeather = (int) Math.round(high) + "/" +  (int) Math.round(low);
            mWeatherId = (int) id;

            loadIconForWeatherId();

            SharedPreferences preferences = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putString(KEY_WEATHER, mWeather);
            editor.putInt(KEY_WEATHER_ID, mWeatherId);
            editor.apply();
        }
    }
}
项目:UdacityProject6    文件:WatchFaceService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(LOG_TAG, "onDataChanged" );
    for (DataEvent dataEvent : dataEvents) {
        if (DataEvent.TYPE_CHANGED == dataEvent.getType()) {
            DataItem dataItem = dataEvent.getDataItem();
            DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();

            String path = dataEvent.getDataItem().getUri().getPath();
            if (path.equals(WEATHER_PATH)) {
                Log.d(LOG_TAG, "/weather id=" + dataMap.getString(KEY_UUID));
                SunshineSyncAdapter.syncImmediately(this);
            }
        }
    }
}
项目:SensorLib    文件:SmartWatchListener.java   
/**
 * Called whenever a new message sent by the Wearable.
 *
 * @param dataEvents buffer with transmitted data
 */
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    Log.i(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/")) {
                if (SmartWatch.getInstance() != null) {
                    SmartWatch.getInstance().unpackSensorData(DataMapItem.fromDataItem(dataItem).getDataMap());
                }
            }
        }
    }
}
项目:stayawhile-android    文件:MainActivity.java   
@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
        }
    }
}
项目:2015-Google-I-O-app    文件:FeedbackWearableListenerService.java   
@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());
            }
        }
    }
}
项目:geowahl-android    文件:ListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    DataMap dataMap;
    for (DataEvent event : dataEvents) {
        Log.v("myTag", "DataMap received on watch: " + DataMapItem.fromDataItem(event.getDataItem()).getDataMap());
        // Check the data type
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // Check the data path
            String path = event.getDataItem().getUri().getPath();
            if (path.equals(WEARABLE_DATA_PATH)) {}
            dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();


            // Broadcast DataMap contents to wearable activity for display
            // The content has the golf hole number and distances to the front,
            // middle and back pin placements.

            Intent messageIntent = new Intent();
            messageIntent.setAction(Intent.ACTION_SEND);
            messageIntent.putExtra("datamap", dataMap.toBundle());
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);

        }
    }
}
项目:LibreAlarm    文件:DataLayerListenerService.java   
@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);
            }
        }
    }
}
项目:Wristglider    文件:MainActivity.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    if (debugMode) Log.d(TAG, "data event happened");
    for (DataEvent event : dataEvents) {
        if (debugMode) Log.d(TAG, event.getDataItem().getUri().getPath());
        if (event.getType() == DataEvent.TYPE_CHANGED &&
                event.getDataItem().getUri().getPath().contains(Statics.DATAIGC)) {
            getStringFromAsset(event.getDataItem());
        }
        if (event.getType() == DataEvent.TYPE_CHANGED &&
                event.getDataItem().getUri().getPath().contains(Statics.DATATHROWABLE)) {
            getExceptionFromWear(event.getDataItem());
        }
        if (event.getType() == DataEvent.TYPE_CHANGED &&
                event.getDataItem().getUri().getPath().contains(Statics.DATABTFAILED)) {
            getBTFailed(event.getDataItem());
        }
    }
}
项目:SunshineApp    文件:WatchFace.java   
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    for (DataEvent dataEvent : dataEventBuffer) {
        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();
        Log.d("WatchFace", "Config DataItem updated:" + config);
        updateUiForConfigDataMap(config);
    }
}
项目:SunshineWear    文件:SunshineClient.java   
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    if (dataEventBuffer == null) {
        weatherInformationListener.onWeatherInformationFetchFailure();
        return;
    }
    for (DataEvent dataEvent : dataEventBuffer) {
        if (doesHaveWeatherData(dataEvent)) {
            DataMap weatherDataMap = getWeatherDataMap(dataEvent);
            Double high = weatherDataMap.getDouble(WeatherRequestKeys.HIGH);
            Double low = weatherDataMap.getDouble(WeatherRequestKeys.LOW);
            weatherInformationListener.onTemperatureFetchSuccess(high, low);
            fetchWeatherIconAsynchronously(weatherDataMap);
            return;
        }
    }
}
项目:DronesWear    文件:MainActivity.java   
@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;
            }

        }
    }
}
项目:wearabird    文件:SensorReceiverService.java   
@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()
                );
            }
        }
    }
}
项目:Sunshine-Android-Wear    文件:DigitalWatchFace.java   
@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
        }
    }
}
项目:Sunshine.Wear    文件:SunshineWatchFace.java   
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    Log.d(TAG, "onDataChanged");
    for (DataEvent event : dataEventBuffer) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            String path = item.getUri().getPath();
            Log.d(TAG, "path: " + path);

            if (path.equals(REQ_PATH)) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

                mWeatherId = dataMap.getInt(KEY_WEATHER_ID);
                mMaxTemperature = dataMap.getDouble(KEY_TEMP_MAX);
                mMinTemperature = dataMap.getDouble(KEY_TEMP_MIN);
                mLocation = dataMap.getString(KEY_LOCATION);

                invalidate();
            }
        }
    }

    dataEventBuffer.release();
}
项目:hombot-control    文件:WearRequestEngine.java   
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEventBuffer);
    for(DataEvent event : events) {
        if (WearMessages.MESSAGE_BOT_LIST.equalsIgnoreCase(event.getDataItem().getUri().getPath())) {
            final DataMap map = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

            ArrayList<DataMap> botList = map.getDataMapArrayList(WearMessages.MAPENTRY_BOT_LIST);

            WearBot[] bots = new WearBot[botList.size()];
            for (int i = 0; i < botList.size(); i++) {
                bots[i] = new WearBot(botList.get(i));
            }

            getListener().updateBotList(bots);
        }
    }
}
项目:FMTech    文件:FeedbackWearableListenerService.java   
@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());
            }
        }
    }
}
项目:nano-go-ubiquitous    文件:SunshineWearListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    for (int i = 0; i < dataEvents.getCount(); i++) {
        DataEvent event = dataEvents.get(i);

        if (event.getType() == DataEvent.TYPE_CHANGED &&
                event.getDataItem().getUri().getPath().equals(APP_DATA_UPDATE_REQUEST)) {
            DataMap dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

            Asset asset = dataMap.getAsset("dataIcon");
            WatchFaceService.highTemp = dataMap.getInt("dataHigh");
            WatchFaceService.lowTemp = dataMap.getInt("dataLow");

            doLoadBitmap(asset);
        }
    }
}
项目:SpritzerWear    文件:ListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "onDataChanged");
    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
    dataEvents.close();
    for (DataEvent event : events) {
        Uri uri = event.getDataItem().getUri();
        String path = uri.getPath();
        if (Tools.WEAR_PATH.equals(path)) {
            DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
            byte[] realmAsset = item.getDataMap().getByteArray(Tools.DATA_ASSET_FILE);
            if(realmAsset != null){
                toFile(realmAsset);
                getBaseContext().sendBroadcast(new Intent(Tools.DATA_STORY_CHANGED));
            }
        }
    }
}
项目:american_sunsets_watch_face    文件:SunsetsWatchFace.java   
@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);
    }
}
项目:american_sunsets_watch_face    文件:WatchFaceCompanionConfigActivity.java   
@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);
    }
}
项目:climb-tracker    文件:WearDataLayerListenerService.java   
@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();
            }
        }
    }
}
项目:moment-for-android-wear    文件:WearMomentListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
        String path = dataEvent.getDataItem().getUri().getPath();
        Timber.d("Path == %s", path);

        switch (path) {
            case Constants.PATH_MOMENT_NOTIFICATION:
                handleNewMoment(dataEvent);
                break;
            case Constants.PATH_FRIEND_ADDED_BACK:
                handleFriendAddedNotification(dataEvent);
                break;
            case Constants.PATH_FRIENDS_REFRESH:
                handleRefreshFriends(dataEvent);
                break;
            default:
                break;
        }
    }
}
项目:moment-for-android-wear    文件:MobileWearListenerService.java   
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            String path = event.getDataItem().getUri().getPath();
            Timber.d("path == %s", path);

            if (path.equals(Constants.PATH_NEW_MOMENT)) {
                sendMoment(event);
            } else if (path.equals(Constants.PATH_FRIENDS_REFRESH_REQUEST)) {
                try {
                    friendsSync.syncFriends();
                } catch (IOException e) {
                    Timber.e(e, "sync friends failed");
                }
            }
        }
    }
}
项目:african_sunsets_watch_face    文件:SunsetsWatchFace.java   
@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);
    }
}
项目:african_sunsets_watch_face    文件:WatchFaceCompanionConfigActivity.java   
@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);
    }
}