Java Code Examples for com.google.android.gms.wearable.DataMap#putStringArrayList()

The following examples show how to use com.google.android.gms.wearable.DataMap#putStringArrayList() . 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: WatchUpdaterService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static boolean sendWearTreatmentsDataDelete(List<String> list) {
    if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
        googleApiClient.connect();
    }
    if (googleApiClient != null) {
        if (!list.isEmpty()) {
            Log.d(TAG, "sendWearTreatmentsDataDelete graph size=" + list.size());
            DataMap entries = new DataMap();
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putString("action", "delete");
            entries.putStringArrayList("entries", (new ArrayList<String>(list)));
            new SendToDataLayerThread(WEARABLE_TREATMENTS_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
        } else
            Log.d(TAG, "sendWearTreatmentsDataDelete treatments count = 0");
    } else {
        Log.e(TAG, "sendWearTreatmentsData No connection to wearable available for send treatment!");
        return false;
    }
    return true;
}
 
Example 2
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static boolean sendWearTreatmentsDataDelete(List<String> list) {
    if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
        googleApiClient.connect();
    }
    if (googleApiClient != null) {
        if (!list.isEmpty()) {
            Log.d(TAG, "sendWearTreatmentsDataDelete graph size=" + list.size());
            DataMap entries = new DataMap();
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putString("action", "delete");
            entries.putStringArrayList("entries", (new ArrayList<String>(list)));
            new SendToDataLayerThread(WEARABLE_TREATMENTS_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
        } else
            Log.d(TAG, "sendWearTreatmentsDataDelete treatments count = 0");
    } else {
        Log.e(TAG, "sendWearTreatmentsData No connection to wearable available for send treatment!");
        return false;
    }
    return true;
}
 
Example 3
Source File: RequestListenerService.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
/**
 * Handles issuing a response to a layer request. A layer request indicates
 * that the Wear device wants a list of previously used layers to display to
 * the user.
 *
 * @param event the MessageEvent from the Wear device
 * @param client the Google API client used to communicate
 */
private void handleLayerRequest(MessageEvent event, GoogleApiClient client) {
  Log.i("Test", "Received Layer request, sending layer list");
  // Create a PutDataMapRequest with the Layer response path
  PutDataMapRequest req = PutDataMapRequest.create(LAYER_RESPONSE);
  DataMap dm = req.getDataMap();
  // Put an array list of layer names into the data map
  dm.putStringArrayList("layers", new ArrayList<>(sLayerMap.keySet()));
  // Put the current time into the data map, which forces an onDataChanged event (this event
  // only occurs when data actually changes, so putting the time ensures something always changes)
  dm.putLong("Time", System.currentTimeMillis());
  // Put the DataItem into the Data API stream
  Wearable.DataApi.putDataItem(client, req.asPutDataRequest());
}
 
Example 4
Source File: RequestListenerService.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
/**
 * Handles issuing a response to a FeatureType request. A FeatureType request
 * indicates that the Wear devices wants a list of available FeatureTypes for
 * the selected layer to display to the user.
 *
 * @param event the MessageEvent from the Wear device
 * @param client the Google API client used to communicate
 */
private void handleFeatureTypeRequest(MessageEvent event, GoogleApiClient client) {
  // Get the name and URL of the layer that was selected
  String layerName = new String(event.getData());
  String url = sLayerMap.get(layerName);
  // Create an ArcGISFeatureLayer with the specified URL
  sArcGISFeatureLayer = new ArcGISFeatureLayer(url, ArcGISFeatureLayer.MODE.SNAPSHOT);

  // While this isn't good practice, there is no way to be notified that an
  // ArcGISFeatureLayer has loaded its LayerServiceInfo. The OnStatusChangedListener
  // seems to be more relevant when the layer is actually being added to a MapView.
  // As such, we simply do a quick sleep until the LayerServiceInfo has been loaded
  try {
    while (sArcGISFeatureLayer.getLayerServiceInfo() == null) {
      Thread.sleep(500);
    }
  } catch (Exception e) {
    //
  }
  // Create a PutDataMapRequest with the FeatureType response path
  PutDataMapRequest req = PutDataMapRequest.create(FEATURE_TYPE_RESPONSE);
  DataMap dm = req.getDataMap();
  // Put an array list of the FeatureType names into the data map
  dm.putStringArrayList("featureTypes", FeatureLayerUtil.getFeatureTypes(sArcGISFeatureLayer));
  // Put the current time into the data map, which forces an onDataChanged event (this event
  // only occurs when data actually changes, so putting the time ensures something always changes)
  dm.putLong("Time", System.currentTimeMillis());
  // Put the DataItem into the Data API stream
  Wearable.DataApi.putDataItem(client, req.asPutDataRequest());
}
 
Example 5
Source File: DataBundleUtil.java    From android_external_GmsLib with Apache License 2.0 4 votes vote down vote up
@Override
void storeList(DataMap dataMap, String key, ArrayList<String> valueList) {
    dataMap.putStringArrayList(key, valueList);
}
 
Example 6
Source File: DataBundleUtil.java    From android_external_GmsLib with Apache License 2.0 4 votes vote down vote up
@Override
void storeList(DataMap dataMap, String key, ArrayList<String> valueList) {
    dataMap.putStringArrayList(key, valueList);
}