Search in sources :

Example 11 with StepCounter

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);
    }
}
Also used : StepCounter(com.eveningoutpost.dexdrip.Models.StepCounter) DateTypeAdapter(com.google.gson.internal.bind.DateTypeAdapter) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DataMap(com.google.android.gms.wearable.DataMap)

Example 12 with StepCounter

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);
    }
}
Also used : StepCounter(com.eveningoutpost.dexdrip.Models.StepCounter) HeartRate(com.eveningoutpost.dexdrip.Models.HeartRate)

Aggregations

StepCounter (com.eveningoutpost.dexdrip.Models.StepCounter)12 HeartRate (com.eveningoutpost.dexdrip.Models.HeartRate)4 Context (android.content.Context)2 PolyTrendLine (com.eveningoutpost.dexdrip.Models.Forecast.PolyTrendLine)2 TrendLine (com.eveningoutpost.dexdrip.Models.Forecast.TrendLine)2 PebbleKit (com.getpebble.android.kit.PebbleKit)2 PebbleDictionary (com.getpebble.android.kit.util.PebbleDictionary)2 DataMap (com.google.android.gms.wearable.DataMap)2 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 DateTypeAdapter (com.google.gson.internal.bind.DateTypeAdapter)2 RequestBody (com.squareup.okhttp.RequestBody)2 ResponseBody (com.squareup.okhttp.ResponseBody)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 Line (lecho.lib.hellocharts.model.Line)2 PointValue (lecho.lib.hellocharts.model.PointValue)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2