Ejemplo n.º 1
0
    @Override
    public void onDataChanged(DataEventBuffer dataEventBuffer) {
      for (DataEvent dataEvent : dataEventBuffer) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
          DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
          String path = dataEvent.getDataItem().getUri().getPath();

          Log.v("BuntinLog", "onDataChanged hit");
          final String WEAR_PATH = "/sunshinewear";
          final String WEAR_HIGH = "high";
          final String WEAR_LOW = "low";
          final String WEAR_WEATHER_ID = "weatherId";

          if (path.equals(WEAR_PATH)) {
            if (dataMap.containsKey(WEAR_HIGH)) {
              mHigh = dataMap.getString(WEAR_HIGH);
            }
            if (dataMap.containsKey(WEAR_LOW)) {
              mLow = dataMap.getString(WEAR_LOW);
            }
            if (dataMap.containsKey(WEAR_WEATHER_ID)) {
              int weatherId = dataMap.getInt(WEAR_WEATHER_ID);
              mWeatherImage = Utility.getImages(weatherId);
            }
          }

          invalidate();
        }
      }
    }
Ejemplo n.º 2
0
  @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();
        String path = event.getDataItem().getUri().getPath();

        if (path.equals(WEARABLE_TO_PHONE_DATA_PATH) && dataMap.containsKey(ACTION_KEY)) {
          doAction(dataMap.getString(ACTION_KEY), dataMap);
        }
      }
    }
  }