Пример #1
0
    @Override
    protected void onPostExecute(String s) {
      super.onPostExecute(s);

      try {
        JSONObject obj = new JSONObject(s);
        dataMap = new DataMap();
        dataMap.putString("serverHour", date.getTime().toString());
        dataMap.putString("serverName", obj.getString("name"));
        new Realtime().execute();

      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
  private void updateConfigDataItem(String key, String value) {

    Log.d(TAG, key + " - updateConfigDataItem - " + value);

    DataMap configKeysToOverwrite = new DataMap();
    configKeysToOverwrite.putString(key, value);
    BReelWatchFaceUtil.overwriteKeysInConfigDataMap(mGoogleApiClient, configKeysToOverwrite);
  }
Пример #3
0
    @Override
    protected void onPostExecute(String s) {
      super.onPostExecute(s);

      dataMap.putString("json", s);
      new SendToDataLayerThread(WEARABLE_DATA_PATH, dataMap.toString()).start();
      // new SendToDataLayerThread("/message_path", s).start();
    }
  /** Permet d'envoyer une liste d'elements */
  protected void sendElements(final List<Element> elements) {

    final PutDataMapRequest putDataMapRequest = PutDataMapRequest.create("/elements/");

    ArrayList<DataMap> elementsDataMap = new ArrayList<>();

    // envoie chaque élémént 1 par 1
    for (int position = 0; position < elements.size(); ++position) {

      DataMap elementDataMap = new DataMap();
      Element element = elements.get(position);

      // créé un emplacement mémoire "element/[position]"

      // ajoute la date de mi[jase à jour
      elementDataMap.putString("timestamp", new Date().toString());

      // ajoute l'element champ par champ
      elementDataMap.putString("titre", element.getTitre());
      elementDataMap.putString("description", element.getDescription());
      elementDataMap.putString("url", element.getUrl());

      // ajoute cette datamap à notre arrayList
      elementsDataMap.add(elementDataMap);
    }

    // place la liste dans la datamap envoyée à la wear
    putDataMapRequest.getDataMap().putDataMapArrayList("/list/", elementsDataMap);

    // envoie la liste à la montre
    if (mApiClient.isConnected())
      Wearable.DataApi.putDataItem(mApiClient, putDataMapRequest.asPutDataRequest());

    // puis envoie les images dans un second temps
    for (int position = 0; position < elements.size(); ++position) {
      // charge l'image associée pour l'envoyer en bluetooth
      sendImage(elements.get(position).getUrl(), position);
    }
  }
Пример #5
0
  /*データの種類
  key	     type    備考        format(BluetoothSPP)
  --------------------------------------------------
  scene    string  シーン情報   "scene:ex"
  ready    boolean 準備完了状態 "ready:ex"
  vibrator integer バイブ時間   "vibrator:ex(ms)"
  */
  public void SyncData(
      String key_name, String sync_data) { // HandheldとWear間の各種データの更新をする。データの種類は上記のコメントを参照
    PutDataMapRequest dataMapRequest = PutDataMapRequest.create(globalv.DATA_PATH);
    DataMap dataMap = dataMapRequest.getDataMap();
    // Data set
    dataMap.putString(key_name, sync_data); // ("keyname",data);

    // Data Push
    PutDataRequest request = dataMapRequest.asPutDataRequest();
    PendingResult<DataApi.DataItemResult> pendingResult =
        Wearable.DataApi.putDataItem(mGoogleApiClient, request);
    pendingResult.setResultCallback(
        new ResultCallback<DataApi.DataItemResult>() {
          @Override
          public void onResult(DataApi.DataItemResult dataItemResult) {
            Log.d("TAG", "onResult:" + dataItemResult.getStatus().toString());
          }
        });
  }
Пример #6
0
 private static void a(List<Asset> arrayList, DataMap dataMap, String string, pd.a.a object) {
   int n = object.type;
   if (n == 14) {
     dataMap.putString(string, null);
     return;
   }
   pd.a[] arra = object.awh;
   if (n == 1) {
     dataMap.putByteArray(string, arra.awi);
     return;
   }
   if (n == 11) {
     dataMap.putStringArray(string, arra.aws);
     return;
   }
   if (n == 12) {
     dataMap.putLongArray(string, arra.awt);
     return;
   }
   if (n == 15) {
     dataMap.putFloatArray(string, arra.awu);
     return;
   }
   if (n == 2) {
     dataMap.putString(string, arra.awj);
     return;
   }
   if (n == 3) {
     dataMap.putDouble(string, arra.awk);
     return;
   }
   if (n == 4) {
     dataMap.putFloat(string, arra.awl);
     return;
   }
   if (n == 5) {
     dataMap.putLong(string, arra.awm);
     return;
   }
   if (n == 6) {
     dataMap.putInt(string, arra.awn);
     return;
   }
   if (n == 7) {
     dataMap.putByte(string, (byte) arra.awo);
     return;
   }
   if (n == 8) {
     dataMap.putBoolean(string, arra.awp);
     return;
   }
   if (n == 13) {
     if (arrayList == null) {
       throw new RuntimeException("populateBundle: unexpected type for: " + string);
     }
     dataMap.putAsset(string, arrayList.get((int) arra.awv));
     return;
   }
   if (n == 9) {
     object = new DataMap();
     for (pd.a a : arra.awq) {
       pc.a(arrayList, (DataMap) object, a.name, a.awf);
     }
     dataMap.putDataMap(string, (DataMap) object);
     return;
   }
   if (n == 10) {
     n = pc.a(string, arra.awr);
     arrayList = pc.a(arrayList, (pd.a.a.a) arra, n);
     if (n == 14) {
       dataMap.putStringArrayList(string, arrayList);
       return;
     }
     if (n == 9) {
       dataMap.putDataMapArrayList(string, arrayList);
       return;
     }
     if (n == 2) {
       dataMap.putStringArrayList(string, arrayList);
       return;
     }
     if (n == 6) {
       dataMap.putIntegerArrayList(string, arrayList);
       return;
     }
     throw new IllegalStateException("Unexpected typeOfArrayList: " + n);
   }
   throw new RuntimeException("populateBundle: unexpected type " + n);
 }
Пример #7
0
 public DataMap putToDataMap(DataMap map) {
   map.putString("user", this.username);
   map.putString("password", this.password);
   return map;
 }
Пример #8
0
 public DataMap putToDataMap(DataMap map) {
   map.putInt("id", id);
   map.putString("name", name);
   return map;
 }