Java Code Examples for com.google.android.gms.wearable.DataMap#getInt()
The following examples show how to use
com.google.android.gms.wearable.DataMap#getInt() .
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: DigitalWatchFaceCompanionConfigActivity.java From wear-os-samples with Apache License 2.0 | 6 votes |
private void setUpColorPickerSelection(int spinnerId, final String configKey, DataMap config, int defaultColorNameResId) { String defaultColorName = getString(defaultColorNameResId); int defaultColor = Color.parseColor(defaultColorName); int color; if (config != null) { color = config.getInt(configKey, defaultColor); } else { color = defaultColor; } Spinner spinner = (Spinner) findViewById(spinnerId); String[] colorNames = getResources().getStringArray(R.array.color_array); for (int i = 0; i < colorNames.length; i++) { if (Color.parseColor(colorNames[i]) == color) { spinner.setSelection(i); break; } } }
Example 2
Source File: RawDisplayData.java From AndroidAPS with GNU Affero General Public License v3.0 | 6 votes |
private void updateStatus(DataMap dataMap) { WearUtil.getWakeLock("readingPrefs", 50); sBasalRate = dataMap.getString("currentBasal"); sUploaderBattery = dataMap.getString("battery"); sRigBattery = dataMap.getString("rigBattery"); detailedIOB = dataMap.getBoolean("detailedIob"); sIOB1 = dataMap.getString("iobSum") + "U"; sIOB2 = dataMap.getString("iobDetail"); sCOB1 = "Carb"; sCOB2 = dataMap.getString("cob"); sBgi = dataMap.getString("bgi"); showBGI = dataMap.getBoolean("showBgi"); externalStatusString = dataMap.getString("externalStatusString"); batteryLevel = dataMap.getInt("batteryLevel"); openApsStatus = dataMap.getLong("openApsStatus"); }
Example 3
Source File: ListenerService.java From xDrip with GNU General Public License v3.0 | 6 votes |
private void syncSensorData(DataMap dataMap, Context context) {//KS Log.d(TAG, "syncSensorData"); if (dataMap != null) { String uuid = dataMap.getString("uuid"); Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid); long started_at = dataMap.getLong("started_at"); Integer latest_battery_level = dataMap.getInt("latest_battery_level"); String sensor_location = dataMap.getString("sensor_location"); Sensor.InitDb(context);//ensure database has already been initialized if (uuid != null && !uuid.isEmpty()) { Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid + " timestamp=" + started_at + " timeString=" + JoH.dateTimeText(started_at)); Sensor sensor = Sensor.getByUuid(uuid); if (sensor == null) { Log.d(TAG, "syncSensorData createUpdate new Sensor..."); Sensor.createUpdate(started_at, 0, latest_battery_level, sensor_location, uuid); Sensor newsensor = Sensor.currentSensor(); if (newsensor != null) { Log.d(TAG, "syncSensorData createUpdate Sensor with uuid=" + uuid + " started at=" + started_at); } else Log.d(TAG, "syncSensorData Failed to createUpdate new Sensor for uuid=" + uuid); } else Log.d(TAG, "syncSensorData Sensor already exists with uuid=" + uuid); } } }
Example 4
Source File: ListenerService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private void syncSensorData(DataMap dataMap, Context context) {//KS Log.d(TAG, "syncSensorData"); if (dataMap != null) { String uuid = dataMap.getString("uuid"); Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid); long started_at = dataMap.getLong("started_at"); Integer latest_battery_level = dataMap.getInt("latest_battery_level"); String sensor_location = dataMap.getString("sensor_location"); Sensor.InitDb(context);//ensure database has already been initialized if (uuid != null && !uuid.isEmpty()) { Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid + " timestamp=" + started_at + " timeString=" + JoH.dateTimeText(started_at)); Sensor sensor = Sensor.getByUuid(uuid); if (sensor == null) { Log.d(TAG, "syncSensorData createUpdate new Sensor..."); Sensor.createUpdate(started_at, 0, latest_battery_level, sensor_location, uuid); Sensor newsensor = Sensor.currentSensor(); if (newsensor != null) { Log.d(TAG, "syncSensorData createUpdate Sensor with uuid=" + uuid + " started at=" + started_at); } else Log.d(TAG, "syncSensorData Failed to createUpdate new Sensor for uuid=" + uuid); } else Log.d(TAG, "syncSensorData Sensor already exists with uuid=" + uuid); } } }
Example 5
Source File: WatchFace.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { for( DataEvent event : dataEvents ) { if( event.getType() == DataEvent.TYPE_CHANGED ) { DataItem item = event.getDataItem(); if( item.getUri().getPath().compareTo( DATA_LAYER_PATH ) == 0 ) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); int selectedBackgroundPosition = dataMap.getInt(KEY_BACKGROUND_POSITION); TypedArray typedArray = getResources().obtainTypedArray( R.array.background_resource_ids ); initBackground( typedArray.getResourceId( selectedBackgroundPosition, 0 ) ); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); preferences.edit().putInt( SHARED_PREFERENCE_POSITION, selectedBackgroundPosition ).commit(); typedArray.recycle(); invalidate(); } } } }
Example 6
Source File: SunsetsGeneralWearableConfigActivity.java From american-sunsets-watch-face with Apache License 2.0 | 5 votes |
private void updateUiForConfigDataMap(final DataMap config) { boolean uiUpdated = false; for (String configKey : config.keySet()) { if (!config.containsKey(configKey)) { continue; } int color = config.getInt(configKey); Log.d(TAG, "Found watch face config key: " + configKey + " -> " + color); if (updateUiForKey(configKey, color)) { uiUpdated = true; } } }
Example 7
Source File: QuizListenerService.java From android-Quiz with Apache License 2.0 | 5 votes |
@Override public void onMessageReceived(MessageEvent messageEvent) { String path = messageEvent.getPath(); if (path.equals(QUIZ_EXITED_PATH)) { // Remove any lingering question notifications. ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancelAll(); } if (path.equals(QUIZ_ENDED_PATH) || path.equals(QUIZ_EXITED_PATH)) { // Quiz ended - display overall results. DataMap dataMap = DataMap.fromByteArray(messageEvent.getData()); int numCorrect = dataMap.getInt(NUM_CORRECT); int numIncorrect = dataMap.getInt(NUM_INCORRECT); int numSkipped = dataMap.getInt(NUM_SKIPPED); Notification.Builder builder = new Notification.Builder(this) .setContentTitle(getString(R.string.quiz_report)) .setSmallIcon(R.drawable.ic_launcher) .setLocalOnly(true); SpannableStringBuilder quizReportText = new SpannableStringBuilder(); appendColored(quizReportText, String.valueOf(numCorrect), R.color.dark_green); quizReportText.append(" " + getString(R.string.correct) + "\n"); appendColored(quizReportText, String.valueOf(numIncorrect), R.color.dark_red); quizReportText.append(" " + getString(R.string.incorrect) + "\n"); appendColored(quizReportText, String.valueOf(numSkipped), R.color.dark_yellow); quizReportText.append(" " + getString(R.string.skipped) + "\n"); builder.setContentText(quizReportText); if (!path.equals(QUIZ_EXITED_PATH)) { // Don't add reset option if user exited quiz (there might not be a quiz to reset!). builder.addAction(R.drawable.ic_launcher, getString(R.string.reset_quiz), getResetQuizPendingIntent()); } ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .notify(QUIZ_REPORT_NOTIF_ID, builder.build()); } }
Example 8
Source File: DexCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static void setWatchStatus(DataMap dataMap) { lastStateWatch = dataMap.getString("lastState", ""); last_transmitter_DataWatch = new TransmitterData(); last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0); mStaticStateWatch = dataMap.getInt("mStaticState", 0); last_battery_level_watch = dataMap.getInt("last_battery_level", -1); retry_time_watch = dataMap.getLong("retry_time", 0); failover_time_watch = dataMap.getLong("failover_time", 0); static_last_hexdump_watch = dataMap.getString("static_last_hexdump", ""); static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", ""); }
Example 9
Source File: DexCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public static void setWatchStatus(DataMap dataMap) { lastStateWatch = dataMap.getString("lastState", ""); last_transmitter_DataWatch = new TransmitterData(); last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0); mStaticStateWatch = dataMap.getInt("mStaticState", 0); last_battery_level_watch = dataMap.getInt("last_battery_level", -1); retry_time_watch = dataMap.getLong("retry_time", 0); failover_time_watch = dataMap.getLong("failover_time", 0); static_last_hexdump_watch = dataMap.getString("static_last_hexdump", ""); static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", ""); }
Example 10
Source File: QuizListenerService.java From AndroidWearable-Samples with Apache License 2.0 | 5 votes |
@Override public void onMessageReceived(MessageEvent messageEvent) { String path = messageEvent.getPath(); if (path.equals(QUIZ_EXITED_PATH)) { // Remove any lingering question notifications. ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancelAll(); } if (path.equals(QUIZ_ENDED_PATH) || path.equals(QUIZ_EXITED_PATH)) { // Quiz ended - display overall results. DataMap dataMap = DataMap.fromByteArray(messageEvent.getData()); int numCorrect = dataMap.getInt(NUM_CORRECT); int numIncorrect = dataMap.getInt(NUM_INCORRECT); int numSkipped = dataMap.getInt(NUM_SKIPPED); Notification.Builder builder = new Notification.Builder(this) .setContentTitle(getString(R.string.quiz_report)) .setSmallIcon(R.drawable.ic_launcher) .setLocalOnly(true); SpannableStringBuilder quizReportText = new SpannableStringBuilder(); appendColored(quizReportText, String.valueOf(numCorrect), R.color.dark_green); quizReportText.append(" " + getString(R.string.correct) + "\n"); appendColored(quizReportText, String.valueOf(numIncorrect), R.color.dark_red); quizReportText.append(" " + getString(R.string.incorrect) + "\n"); appendColored(quizReportText, String.valueOf(numSkipped), R.color.dark_yellow); quizReportText.append(" " + getString(R.string.skipped) + "\n"); builder.setContentText(quizReportText); if (!path.equals(QUIZ_EXITED_PATH)) { // Don't add reset option if user exited quiz (there might not be a quiz to reset!). builder.addAction(R.drawable.ic_launcher, getString(R.string.reset_quiz), getResetQuizPendingIntent()); } ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .notify(QUIZ_REPORT_NOTIF_ID, builder.build()); } }
Example 11
Source File: BaseWatchFace.java From NightWatch with GNU General Public License v3.0 | 5 votes |
@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"); rawString = dataMap.getString("rawString"); sgvString = dataMap.getString("sgvString"); batteryString = dataMap.getString("battery"); 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())); showAgoRawBatt(); mDirection.setText(dataMap.getString("slopeArrow")); mDelta.setText(dataMap.getString("delta")); 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(); }
Example 12
Source File: Message.java From DronesWear with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static int decodeActionTypeMessage(DataItem dataItem) { int actionType = -1; if (MESSAGE_TYPE.ACTION_TYPE.equals(getMessageType(dataItem))) { DataMap dataMap = DataMap.fromByteArray(dataItem.getData()); actionType = dataMap.getInt(VALUE_STR); } return actionType; }
Example 13
Source File: SensorReceiverService.java From SensorDashboard with Apache License 2.0 | 5 votes |
private void unpackSensorData(int sensorType, DataMap dataMap) { int accuracy = dataMap.getInt(DataMapKeys.ACCURACY); long timestamp = dataMap.getLong(DataMapKeys.TIMESTAMP); float[] values = dataMap.getFloatArray(DataMapKeys.VALUES); Log.d(TAG, "Received sensor data " + sensorType + " = " + Arrays.toString(values)); sensorManager.addSensorData(sensorType, accuracy, timestamp, values); }
Example 14
Source File: Emmet.java From Wear-Emmet with Apache License 2.0 | 4 votes |
private void callMethodOnObject(final Object object, final DataMap methodDataMap) { String methodName = methodDataMap.getString(METHOD_NAME); ArrayList<DataMap> methodDataMapList = methodDataMap.getDataMapArrayList(METHOD_PARAMS); List<Method> methodsList = getMethodWithName(object, methodName, methodDataMapList.size()); for (Method method : methodsList) { try { if (method != null) { int nbArgs = methodDataMapList.size(); Object[] params = new Object[nbArgs]; for (int argumentPos = 0; argumentPos < nbArgs; ++argumentPos) { Class paramClass = method.getParameterTypes()[argumentPos]; DataMap map = methodDataMapList.get(argumentPos); String type = map.getString(PARAM_TYPE); switch (type) { case (TYPE_INT): params[argumentPos] = map.getInt(PARAM_VALUE); break; case (TYPE_FLOAT): params[argumentPos] = map.getFloat(PARAM_VALUE); break; case (TYPE_DOUBLE): params[argumentPos] = map.getDouble(PARAM_VALUE); break; case (TYPE_LONG): params[argumentPos] = map.getLong(PARAM_VALUE); break; case (TYPE_STRING): params[argumentPos] = map.getString(PARAM_VALUE); break; default: { Type t = method.getGenericParameterTypes()[argumentPos]; Object deserialized = SerialisationUtilsGSON.deserialize(t, map.getString(PARAM_VALUE)); params[argumentPos] = deserialized; } } } //found the method method.invoke(object, params); //if call success, return / don't call other methods return; } } catch (Exception e) { Log.e(TAG, "callMethodOnObject error", e); } } }
Example 15
Source File: BIGChart.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getBundleExtra("data"); if (bundle ==null){ return; } DataMap dataMap = DataMap.fromBundle(bundle); if (layoutSet) { wakeLock.acquire(50); sgvLevel = dataMap.getLong("sgvLevel"); batteryLevel = dataMap.getInt("batteryLevel"); datetime = dataMap.getDouble("timestamp"); rawString = dataMap.getString("rawString"); sgvString = dataMap.getString("sgvString"); batteryString = dataMap.getString("battery"); 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(BIGChart.this); mTime.setText(timeFormat.format(System.currentTimeMillis())); showAgoRawBatt(); String delta = dataMap.getString("delta"); if (delta.endsWith(" mg/dl")) { mDelta.setText(delta.substring(0, delta.length() - 6)); } else if (delta.endsWith(" mmol")) { mDelta.setText(delta.substring(0, delta.length() - 5)); } if (chart != null) { addToWatchSet(dataMap); setupCharts(); } mRelativeLayout.measure(specW, specH); mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight()); invalidate(); setColor(); //start animation? // dataMap.getDataMapArrayList("entries") == null -> not on "resend data". if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5"))) { startAnimation(); } } else { Log.d("ERROR: ", "DATA IS NOT YET SET"); } }
Example 16
Source File: CircleWatchface.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { final PowerManager.WakeLock wl = JoH.getWakeLock("circle-message-receiver", 60000); try { DataMap dataMap; Bundle bundle = intent.getBundleExtra("msg"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); String msg = dataMap.getString("msg", ""); int length = dataMap.getInt("length", 0); JoH.static_toast(xdrip.getAppContext(), msg, length); } bundle = intent.getBundleExtra("steps"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) { mStepsCount = dataMap.getInt("steps", 0); mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0); } } bundle = intent.getBundleExtra("data"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); setSgvLevel((int) dataMap.getLong("sgvLevel")); Log.d(TAG, "CircleWatchface sgv level : " + getSgvLevel()); setSgvString(dataMap.getString("sgvString")); Log.d(TAG, "CircleWatchface sgv string : " + getSgvString()); setRawString(dataMap.getString("rawString")); setDelta(dataMap.getString("delta")); setDatetime(dataMap.getDouble("timestamp")); mExtraStatusLine = dataMap.getString("extra_status_line"); addToWatchSet(dataMap); //start animation? // dataMap.getDataMapArrayList("entries") == null -> not on "resend data". if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (getSgvString().equals("100") || getSgvString().equals("5.5") || getSgvString().equals("5,5"))) { startAnimation(); } prepareLayout(); prepareDrawTime(); invalidate(); } //status bundle = intent.getBundleExtra("status"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); setStatusString(dataMap.getString("externalStatusString")); prepareLayout(); prepareDrawTime(); invalidate(); } } finally { JoH.releaseWakeLock(wl); } }
Example 17
Source File: QuizListenerService.java From android-Quiz with Apache License 2.0 | 4 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .build(); ConnectionResult connectionResult = googleApiClient.blockingConnect(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS); if (!connectionResult.isSuccess()) { Log.e(TAG, "QuizListenerService failed to connect to GoogleApiClient."); return; } for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { DataItem dataItem = event.getDataItem(); DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap(); if (dataMap.getBoolean(QUESTION_WAS_ANSWERED) || dataMap.getBoolean(QUESTION_WAS_DELETED)) { // Ignore the change in data; it is used in MainActivity to update // the question's status (i.e. was the answer right or wrong or left blank). continue; } String question = dataMap.getString(QUESTION); int questionIndex = dataMap.getInt(QUESTION_INDEX); int questionNum = questionIndex + 1; String[] answers = dataMap.getStringArray(ANSWERS); int correctAnswerIndex = dataMap.getInt(CORRECT_ANSWER_INDEX); Intent deleteOperation = new Intent(this, DeleteQuestionService.class); deleteOperation.setData(dataItem.getUri()); PendingIntent deleteIntent = PendingIntent.getService(this, 0, deleteOperation, PendingIntent.FLAG_UPDATE_CURRENT); // First page of notification contains question as Big Text. Notification.BigTextStyle bigTextStyle = new Notification.BigTextStyle() .setBigContentTitle(getString(R.string.question, questionNum)) .bigText(question); Notification.Builder builder = new Notification.Builder(this) .setStyle(bigTextStyle) .setSmallIcon(R.drawable.ic_launcher) .setLocalOnly(true) .setDeleteIntent(deleteIntent); // Add answers as actions. Notification.WearableExtender wearableOptions = new Notification.WearableExtender(); for (int i = 0; i < answers.length; i++) { Notification answerPage = new Notification.Builder(this) .setContentTitle(question) .setContentText(answers[i]) .extend(new Notification.WearableExtender() .setContentAction(i)) .build(); boolean correct = (i == correctAnswerIndex); Intent updateOperation = new Intent(this, UpdateQuestionService.class); // Give each intent a unique action. updateOperation.setAction("question_" + questionIndex + "_answer_" + i); updateOperation.setData(dataItem.getUri()); updateOperation.putExtra(UpdateQuestionService.EXTRA_QUESTION_INDEX, questionIndex); updateOperation.putExtra(UpdateQuestionService.EXTRA_QUESTION_CORRECT, correct); PendingIntent updateIntent = PendingIntent.getService(this, 0, updateOperation, PendingIntent.FLAG_UPDATE_CURRENT); Notification.Action action = new Notification.Action.Builder( questionNumToDrawableId.get(i), null, updateIntent) .build(); wearableOptions.addAction(action).addPage(answerPage); } builder.extend(wearableOptions); Notification notification = builder.build(); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .notify(questionIndex, notification); } else if (event.getType() == DataEvent.TYPE_DELETED) { Uri uri = event.getDataItem().getUri(); // URI's are of the form "/question/0", "/question/1" etc. // We use the question index as the notification id. int notificationId = Integer.parseInt(uri.getLastPathSegment()); ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .cancel(notificationId); } // Delete the quiz report, if it exists. ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .cancel(QUIZ_REPORT_NOTIF_ID); } googleApiClient.disconnect(); }
Example 18
Source File: BIGChart.java From NightWatch with GNU General Public License v3.0 | 4 votes |
@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"); rawString = dataMap.getString("rawString"); sgvString = dataMap.getString("sgvString"); batteryString = dataMap.getString("battery"); 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(BIGChart.this); mTime.setText(timeFormat.format(System.currentTimeMillis())); showAgoRawBatt(); String delta = dataMap.getString("delta"); if (delta.endsWith(" mg/dl")) { mDelta.setText(delta.substring(0, delta.length() - 6)); } else if (delta.endsWith(" mmol")) { mDelta.setText(delta.substring(0, delta.length() - 5)); } if (chart != null) { addToWatchSet(dataMap); setupCharts(); } mRelativeLayout.measure(specW, specH); mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight()); invalidate(); setColor(); //start animation? // dataMap.getDataMapArrayList("entries") == null -> not on "resend data". if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5"))) { startAnimation(); } } else { Log.d("ERROR: ", "DATA IS NOT YET SET"); } }
Example 19
Source File: WatchUpdaterService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private synchronized void syncBgReadingsData(DataMap dataMap) { Log.d(TAG, "sync-precalculated-bg-readings-Data"); final int calibration_state = dataMap.getInt("native_calibration_state", 0); Ob1G5CollectionService.processCalibrationState(CalibrationState.parse(calibration_state)); Ob1G5StateMachine.injectDexTime(dataMap.getString("dextime", null)); final boolean queue_drained = dataMap.getBoolean(PREF_QUEUE_DRAINED); if (queue_drained) { Ob1G5StateMachine.emptyQueue(); } final ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries"); if (entries != null) { final Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); final int count = entries.size(); if (count > 0) { final Sensor current_sensor = Sensor.currentSensor(); if (current_sensor == null) { UserError.Log.e(TAG, "Cannot sync wear BG readings because sensor is marked stopped on phone"); return; } Log.d(TAG, "syncTransmitterData add BgReading Table entries count=" + count); int idx = 0; long timeOfLastBG = 0; for (DataMap entry : entries) { if (entry != null) { idx++; final String bgrecord = entry.getString("bgs"); if (bgrecord != null) { final BgReading bgData = gson.fromJson(bgrecord, BgReading.class); final BgReading uuidexists = BgReading.findByUuid(bgData.uuid); if (uuidexists == null) { final BgReading exists = BgReading.getForTimestamp(bgData.timestamp); if (exists == null) { Log.d(TAG, "Saving new synced pre-calculated bg-reading: " + JoH.dateTimeText(bgData.timestamp) + " last entry: " + (idx == count) + " " + BgGraphBuilder.unitized_string_static(bgData.calculated_value)); bgData.sensor = current_sensor; bgData.save(); BgSendQueue.handleNewBgReading(bgData, "create", xdrip.getAppContext(), Home.get_follower(), idx != count); } else { Log.d(TAG, "BgReading for timestamp already exists: " + JoH.dateTimeText(bgData.timestamp)); } } else { Log.d(TAG, "BgReading with uuid: " + bgData.uuid + " already exists: " + JoH.dateTimeText(bgData.timestamp)); } timeOfLastBG = Math.max(bgData.timestamp + 1, timeOfLastBG); } } } sendDataReceived(DATA_ITEM_RECEIVED_PATH, "DATA_RECEIVED_BGS count=" + entries.size(), timeOfLastBG, "BG", -1); } else { UserError.Log.e(TAG, "Not acknowledging wear BG readings as count was 0"); } } else { UserError.Log.d(TAG, "Null entries list - should only happen with native status update only"); } }
Example 20
Source File: DataBundleUtil.java From android_external_GmsLib with Apache License 2.0 | 4 votes |
@Override Integer load(DataMap dataMap, String key) { return dataMap.getInt(key); }