use of com.eveningoutpost.dexdrip.Models.StepCounter in project xDrip-plus by jamorham.
the class WatchUpdaterService method syncStepSensorData.
private synchronized void syncStepSensorData(DataMap dataMap, boolean bBenchmark) {
Log.d(TAG, "syncStepSensorData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
Log.d(TAG, "syncStepSensorData add to Table");
if (entries != null) {
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new DateTypeAdapter()).serializeSpecialFloatingPointValues().create();
StepCounter pm = StepCounter.last();
Log.d(TAG, "syncStepSensorData add Table entries count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG, "syncStepSensorData add Table entry=" + entry);
String record = entry.getString("entry");
if (record != null) {
Log.d(TAG, "syncStepSensorData add Table record=" + record);
StepCounter data = gson.fromJson(record, StepCounter.class);
if (data != null) {
timeOfLastEntry = (long) data.timestamp + 1;
Log.d(TAG, "syncStepSensorData add Entry Wear=" + data.toString());
Log.d(TAG, "syncStepSensorData WATCH data.metric=" + data.metric + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
if (!bBenchmark)
data.saveit();
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH, "DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark ? "BM" : "STEP", -1);
}
}
use of com.eveningoutpost.dexdrip.Models.StepCounter in project xDrip-plus by jamorham.
the class Home method updateHealthInfo.
private void updateHealthInfo(String caller) {
final StepCounter pm = StepCounter.last();
final boolean use_pebble_health = Pref.getBoolean("use_pebble_health", true);
if ((use_pebble_health) && (pm != null)) {
stepsButton.setText(Integer.toString(pm.metric));
stepsButton.setVisibility(View.VISIBLE);
// TODO this can be done with PrefsView binding
stepsButton.setAlpha(Pref.getBoolean("show_pebble_movement_line", true) ? 1.0f : 0.3f);
} else {
stepsButton.setVisibility(View.INVISIBLE);
}
final HeartRate hr = HeartRate.last();
if ((use_pebble_health) && (hr != null)) {
bpmButton.setText(Integer.toString(hr.bpm));
bpmButton.setVisibility(View.VISIBLE);
// TODO this can be done with PrefsView binding
bpmButton.setAlpha(Pref.getBoolean("show_pebble_movement_line", true) ? 1.0f : 0.3f);
} else {
bpmButton.setVisibility(View.INVISIBLE);
}
}
Aggregations