Beispiel #1
0
 @Override
 public void onDataChanged(DataEventBuffer dataEventBuffer) {
   for (DataEvent event : dataEventBuffer) {
     if (event.getType() == DataEvent.TYPE_CHANGED) {
       DataItem item = event.getDataItem();
       DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
       if (item.getUri().getPath().compareTo("/headReq") == 0) {
         if (dataMap.getInt("head") == 1 && gameStatus == true) {
           sendHeadVector();
         }
       } else if (item.getUri().getPath().compareTo("/" + RESUME) == 0) {
         if (dataMap.getInt(RESUME) == 1) {
           gameStatus = true;
         }
       } else if (item.getUri().getPath().compareTo("/" + PAUSE) == 0) {
         if (dataMap.getInt(PAUSE) == 1) {
           gameStatus = false;
         }
       } else if (item.getUri().getPath().compareTo("/" + RESTART) == 0) {
         if (dataMap.getInt(RESTART) == 1) {
           gameStatus = true;
         }
       }
     }
   }
 }
  @Override
  public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent event : dataEvents) {
      if (event.getType() == DataEvent.TYPE_CHANGED) {

        DataMap map = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

        String path = event.getDataItem().getUri().getPath();

        if ("/sunshine".equals(path)) {
          high = map.getDouble("temp-high");
          low = map.getDouble("temp-low");
          weatherId = map.getInt("weather-id");

          Log.d(LOG_TAG, high + "-" + low + "-" + weatherId);

          Intent intent = new Intent("weather-data");

          intent.putExtra("temp-high", high);
          intent.putExtra("temp-low", low);
          intent.putExtra("weather-id", weatherId);

          LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
        }
      }
    }
  }
    @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();
    }
  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);
  }
Beispiel #5
0
 private boolean processDataItem(GoogleApiClient googleApiClient, DataItem dataItem) {
   if (!dataItem.getUri().getPath().equals("/artwork")) {
     Log.w(TAG, "Ignoring data item " + dataItem.getUri().getPath());
     return false;
   }
   DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
   DataMap artworkDataMap = dataMapItem.getDataMap().getDataMap("artwork");
   if (artworkDataMap == null) {
     Log.w(TAG, "No artwork in datamap.");
     return false;
   }
   final Artwork artwork = Artwork.fromBundle(artworkDataMap.toBundle());
   final Asset asset = dataMapItem.getDataMap().getAsset("image");
   if (asset == null) {
     Log.w(TAG, "No image asset in datamap.");
     return false;
   }
   // Convert asset into a file descriptor and block until it's ready
   final DataApi.GetFdForAssetResult getFdForAssetResult =
       Wearable.DataApi.getFdForAsset(googleApiClient, asset).await();
   InputStream assetInputStream = getFdForAssetResult.getInputStream();
   if (assetInputStream == null) {
     Log.w(TAG, "Empty asset input stream (probably an unknown asset).");
     return false;
   }
   Bitmap image = BitmapFactory.decodeStream(assetInputStream);
   if (image == null) {
     Log.w(TAG, "Couldn't decode a bitmap from the stream.");
     return false;
   }
   File localCache = new File(getCacheDir(), "cache.png");
   FileOutputStream out = null;
   try {
     out = new FileOutputStream(localCache);
     image.compress(Bitmap.CompressFormat.PNG, 100, out);
   } catch (IOException e) {
     Log.e(TAG, "Error writing local cache", e);
   } finally {
     try {
       if (out != null) {
         out.close();
       }
     } catch (IOException e) {
       Log.e(TAG, "Error closing local cache file", e);
     }
   }
   enableComponents(FullScreenActivity.class);
   if (MuzeiProvider.saveCurrentArtworkLocation(this, localCache)) {
     getContentResolver().insert(MuzeiContract.Artwork.CONTENT_URI, artwork.toContentValues());
   }
   return true;
 }
 /**
  * Overwrites the current config {@link DataItem}'s {@link DataMap} with {@code newConfig}. If the
  * config DataItem doesn't exist, it's created.
  */
 public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig) {
   PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_WITH_FEATURE);
   DataMap configToPut = putDataMapRequest.getDataMap();
   configToPut.putAll(newConfig);
   Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest())
       .setResultCallback(
           new ResultCallback<DataApi.DataItemResult>() {
             @Override
             public void onResult(DataApi.DataItemResult dataItemResult) {
               if (Log.isLoggable(TAG, Log.DEBUG)) {
                 Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus());
               }
             }
           });
 }
    @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();
      }
    }
Beispiel #8
0
 private static pd.a[] a(DataMap dataMap, List<Asset> list) {
   Object object = dataMap.keySet();
   pd.a[] arra = new pd.a[object.size()];
   object = object.iterator();
   int n = 0;
   while (object.hasNext()) {
     String string = (String) object.next();
     Object t = dataMap.get(string);
     arra[n] = new pd.a();
     arra[n].name = string;
     arra[n].awf = pc.a(list, t);
     ++n;
   }
   return arra;
 }
  @Override
  public void onDataChanged(DataEventBuffer dataEvents) {
    DataMap dataMap;
    for (DataEvent event : dataEvents) {
      if (event.getType() == DataEvent.TYPE_CHANGED) {
        String path = event.getDataItem().getUri().getPath();

        if (path.equals(PATH_WEATHER_INFO)) {}
        dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtras(dataMap.toBundle());
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
      }
    }
  }
  @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);
        }
      }
    }
  }
  /* handle a given action/message */
  private void doAction(String action, DataMap dataMap) {

    switch (action) {
      case ACTION_FEEDBACK:
        boolean ok = dataMap.getBoolean(EXTRA_STATUS);
        String toast = ok ? "PATTERN PLAYED (ack)" : "Error on the watch...";
        Log.d(getPackageName(), toast);
        //                Toast.makeText( getApplicationContext(), toast, Toast.LENGTH_SHORT
        // ).show();
        break;

      case ACTION_GET_CONTACTS:
        SendToWearableService.sendContacts(getContactsList());
        break;

      case ACTION_SEND_MSG:
        String phone = dataMap.getString(EXTRA_PHONE);
        long[] pattern = dataMap.getLongArray(EXTRA_PATTERN);
        String text = dataMap.getString(EXTRA_TEXT);

        if (phone != null && pattern.length > 0) {
          GcmSenderService.sendMessage(phone, pattern, text);
        }
        break;

      case ACTION_OPEN:
        String number = dataMap.getString(EXTRA_PHONE);

        // don't know why, but the extras are only passed with a pendingIntent...
        try {
          Intent intent = new Intent(getApplicationContext(), MainActivity.class);
          intent.putExtra(GcmConstants.FROM_KEY, number);
          PendingIntent pendingIntent =
              PendingIntent.getActivity(
                  getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
          pendingIntent.send(getApplicationContext(), 0, new Intent());

        } catch (PendingIntent.CanceledException e) {
          e.printStackTrace();
        }
        break;

      default:
        break;
    }
  }
    @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();
        }
      }
    }
  private void sendPositionData(float x, float y) {
    if (mNode != null) {
      DataMap positionData = new DataMap();
      positionData.putFloat(TAG_X_COORDINATE, x);
      positionData.putFloat(TAG_Y_COORDINATE, y);
      Wearable.MessageApi.sendMessage(
              mGoogleApiClient, mNode.getId(), PATH_POSITION_UPDATE, positionData.toByteArray())
          .setResultCallback(
              new ResultCallback<MessageApi.SendMessageResult>() {

                @Override
                public void onResult(MessageApi.SendMessageResult sendMessageResult) {
                  Log.e(TAG, "SendRequireMessage:" + sendMessageResult.getStatus());
                  if (!sendMessageResult.getStatus().isSuccess()) {}
                }
              });
    }
  }
  /*データの種類
  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());
          }
        });
  }
  @Override
  public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals(PATH_WEATHER_INFO)) {
      DataMap dataMap = DataMap.fromByteArray(messageEvent.getData());

      Bundle bundle = new Bundle();

      bundle.putString("minTemp", dataMap.getString("minTemp"));
      bundle.putString("maxTemp", dataMap.getString("maxTemp"));
      bundle.putString("weatherId", dataMap.getString("weatherId"));

      Intent messageIntent = new Intent();
      messageIntent.setAction(Intent.ACTION_SEND);
      messageIntent.putExtras(bundle);

      LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    } else {
      super.onMessageReceived(messageEvent);
    }
  }
  @Override
  public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
      if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
        DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
        String message = dataMap.getString(Constants.KEY_TEXT_FROM_SERVER);
        String type = dataMap.getString(Constants.KEY_MESSAGE_TYPE);
        String path = dataEvent.getDataItem().getUri().getPath();

        if (Constants.MESSAGE_WEARABLE_TO_MOBILE_PATH.equals(path)) {
          sendMessageToActivity(message, type);
        }
      } else if (dataEvent.getType() == DataEvent.TYPE_DELETED) {
        Log.d(TAG, "Message deleted");
        if (Log.isLoggable(TAG, Log.DEBUG)) {
          Log.d(TAG, "DataItem deleted: " + dataEvent.getDataItem().getUri().getPath());
        }
        if (Constants.MESSAGE_WEARABLE_TO_MOBILE_PATH.equals(
            dataEvent.getDataItem().getUri().getPath())) {}
      }
    }
  }
  /** 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);
    }
  }
Beispiel #18
0
  public void addToWatchSet(DataMap dataMap) {

    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    if (entries != null) {
      for (DataMap entry : entries) {
        double sgv = entry.getDouble("sgvDouble");
        double high = entry.getDouble("high");
        double low = entry.getDouble("low");
        double timestamp = entry.getDouble("timestamp");

        final int size = bgDataList.size();
        if (size > 0) {
          if (bgDataList.get(size - 1).timestamp == timestamp) continue; // Ignore duplicates.
        }

        bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
      }
    } else {
      double sgv = dataMap.getDouble("sgvDouble");
      double high = dataMap.getDouble("high");
      double low = dataMap.getDouble("low");
      double timestamp = dataMap.getDouble("timestamp");

      final int size = bgDataList.size();
      if (size > 0) {
        if (bgDataList.get(size - 1).timestamp == timestamp) return; // Ignore duplicates.
      }

      bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
    }

    for (int i = 0; i < bgDataList.size(); i++) {
      if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) {
        bgDataList.remove(i); // Get rid of anything more than 5 hours old
        break;
      }
    }
  }
Beispiel #19
0
    @Override
    public void onReceive(Context context, Intent intent) {
      DataMap dataMap = DataMap.fromBundle(intent.getBundleExtra("data"));
      if (layoutSet) {
        wakeLock.acquire(50);
        sgvLevel = dataMap.getLong("sgvLevel");
        batteryLevel = dataMap.getInt("batteryLevel");
        datetime = dataMap.getDouble("timestamp");

        mSgv.setText(dataMap.getString("sgvString"));

        if (ageLevel() <= 0) {
          mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
          mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        mTimestamp.setText(readingAge());

        mDirection.setText(dataMap.getString("slopeArrow"));
        mUploaderBattery.setText("Uploader: " + dataMap.getString("battery") + "%");
        mDelta.setText(dataMap.getString("delta"));

        mTimestamp.setText(readingAge());
        if (chart != null) {
          addToWatchSet(dataMap);
          setupCharts();
        }
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(
            0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight());
        invalidate();
      } else {
        Log.d("ERROR: ", "DATA IS NOT YET SET");
      }
      setColor();
    }
  @Override
  public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent event : dataEvents) {
      if (event.getType() == DataEvent.TYPE_DELETED) {
        Log.d("TAG", "DataItem deleted: " + event.getDataItem().getUri());
      } else if (event.getType() == DataEvent.TYPE_CHANGED) {
        Log.d("TAG", "DataItem changed: " + event.getDataItem().getUri());
        DataMap dataMap = DataMap.fromByteArray(event.getDataItem().getData());
        // variable = dataMap.get~("keyname"); で受け取る

        runOnUiThread(
            new Runnable() {
              @Override
              public void run() {
                // 受け取り後の処理をここに
                // resultview.setText(resultstr);
              }
            });
      }
    }
  }
 public DataMap putToDataMap(DataMap map) {
   map.putInt("id", id);
   map.putString("name", name);
   return map;
 }
 public DataObject(DataMap map) {
   this(map.getInt("id"), map.getString("name"));
 }
    @Override
    protected Void doInBackground(Void... params) {
      Dexcom dexcom = new Dexcom();

      try {
        String token =
            dexcom.login(
                PreferenceManager.getDefaultSharedPreferences(context).getString("username", ""),
                PreferenceManager.getDefaultSharedPreferences(context).getString("password", ""));
        if (token != null && token.length() > 0 && token.startsWith("\"")) {
          token = token.substring(1, token.length() - 2); // Strip the "s
          SharedPreferences.Editor editor =
              PreferenceManager.getDefaultSharedPreferences(context).edit();
          editor.putString("token", token);
          editor.apply();
          JSONArray a = dexcom.latestGlucoseValues(token, 1440, 1);
          if (a != null && a.length() > 0) {
            JSONObject o = a.getJSONObject(0);
            final int trend = o.getInt("Trend");
            final int value = o.getInt("Value");
            String WT = o.getString("WT");
            final long time = Long.valueOf(WT.substring(6, WT.length() - 2));
            Log.i("DexcomShareDashclock", "Latest glucose reading: " + value + " mg/dL");

            editor.putInt("Trend", trend);
            editor.putInt("Value", value);
            editor.putLong("Time", time);
            editor.apply();

            final GoogleApiClient googleApiClient =
                new GoogleApiClient.Builder(context).addApi(Wearable.API).build();

            ConnectionResult connectionResult =
                googleApiClient.blockingConnect(30, TimeUnit.SECONDS);

            if (!connectionResult.isSuccess()) {
              Log.e("DexcomShareDashclock", "Failed to connect to GoogleApiClient.");
              return null;
            }

            DataMap map = new DataMap();
            map.putInt("trend", trend);
            map.putInt("value", value);
            map.putLong("time", time);

            NodeApi.GetConnectedNodesResult nodes =
                Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
            for (Node node : nodes.getNodes()) {
              Wearable.MessageApi.sendMessage(
                      googleApiClient, node.getId(), "/latest_glucose", map.toByteArray())
                  .await();
            }

            googleApiClient.disconnect();
          }
        } else {
          Log.e("Dexcom", "Response: " + token);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      return null;
    }
Beispiel #24
0
 public User(DataMap map) {
   this.username = map.getString("user");
   this.password = map.getString("password");
 }
Beispiel #25
0
 public DataMap putToDataMap(DataMap map) {
   map.putString("user", this.username);
   map.putString("password", this.password);
   return map;
 }
 @Override
 public void onDataChanged(DataEventBuffer dataEvents) {
   Log.d("onDataChanged", "Received a data change");
   for (DataEvent event : dataEvents) {
     DataItem item = event.getDataItem();
     if (item.getUri().getPath().compareTo(PATH) == 0) {
       DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
       String key = dataMap.getString(ACTION_KEY);
       String checkString, dateString, newGroupName, newItemName;
       switch (key) {
         case MAKE_GROUP_KEY:
           Log.d("DATA", "MAKE_GROUP_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           groupReaderDbHelper.insertGroup(groupName);
           updateGroupList();
           break;
         case DELETE_GROUP_KEY:
           Log.d("DATA", "DELETE_GROUP_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           groupReaderDbHelper.deleteGroup(groupName);
           itemReaderDbHelper.deleteItemsInGroup(groupName);
           updateGroupList();
           break;
         case DELETE_ALL_GROUPS_KEY:
           Log.d("DATA", "DELETE_ALL_GROUPS_KEY RECEIVED");
           groupReaderDbHelper.deleteAllGroups();
           itemReaderDbHelper.deleteAllItems();
           updateGroupList();
           break;
         case MAKE_ITEM_KEY:
           Log.d("DATA", "MAKE_ITEM_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemName = dataMap.getString(ITEM_NAME_KEY);
           itemReaderDbHelper.insertItem(groupName, itemName);
           updateItemList();
           break;
         case DELETE_ITEM_KEY:
           Log.d("DATA", "DELETE_ITEM_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemName = dataMap.getString(ITEM_NAME_KEY);
           itemReaderDbHelper.deleteItem(groupName, itemName);
           updateItemList();
           break;
         case DELETE_ALL_ITEMS_IN_GROUP_KEY:
           Log.d("DATA", "DELETE_ALL_ITEMS_IN_GROUP_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemReaderDbHelper.deleteItemsInGroup(groupName);
           updateItemList();
           break;
         case CHECK_KEY:
           Log.d("DATA", "CHECK_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemName = dataMap.getString(ITEM_NAME_KEY);
           checkString = dataMap.getString(CHECK_KEY);
           switch (checkString) {
             case "0":
               itemReaderDbHelper.uncheckItem(groupName, itemName);
               uncheckItem(itemName);
               break;
             case "1":
               // TODOs : change to using broadcast receiver instead
               itemReaderDbHelper.checkItem(groupName, itemName);
               checkItem(itemName);
               break;
           }
           break;
         case DATE_KEY:
           Log.d("DATA", "DATE_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemName = dataMap.getString(ITEM_NAME_KEY);
           dateString = dataMap.getString(DATE_KEY);
           SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd");
           try {
             Date date = sdf.parse(dateString);
             itemReaderDbHelper.updateDateCheckedItem(groupName, itemName, date);
             updateItemList();
           } catch (Exception e) {
             System.out.println(e);
           }
           break;
         case COPY_KEY:
           Log.d("DATA", "COPY_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemName = dataMap.getString(ITEM_NAME_KEY);
           newGroupName = dataMap.getString(NEW_GROUP_NAME_KEY);
           itemReaderDbHelper.copyItem(groupName, newGroupName, itemName);
           updateItemList();
           break;
         case RENAME_ITEM_KEY:
           Log.d("DATA", "RENAME_ITEM_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           itemName = dataMap.getString(ITEM_NAME_KEY);
           newItemName = dataMap.getString(NEW_ITEM_NAME_KEY);
           itemReaderDbHelper.renameItem(groupName, itemName, newItemName);
           updateItemList();
           break;
         case RENAME_GROUP_KEY:
           Log.d("DATA", "RENAME_GROUP_KEY RECEIVED");
           groupName = dataMap.getString(GROUP_NAME_KEY);
           newGroupName = dataMap.getString(NEW_GROUP_NAME_KEY);
           groupReaderDbHelper.renameGroup(groupName, newGroupName);
           itemReaderDbHelper.renameGroup(groupName, newGroupName);
           updateGroupList();
           break;
         case DONE_KEY:
           groupName = dataMap.getString(GROUP_NAME_KEY);
           doneScanning(groupName);
           break;
       }
     }
   }
 }
Beispiel #27
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);
 }