Search in sources :

Example 11 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.

the class ListenerService method getBloodTests.

public static DataMap getBloodTests(long startTime) {
    BloodTest last = BloodTest.last();
    if (last != null) {
        Log.d(TAG, "getBloodTests last.timestamp:" + JoH.dateTimeText(last.timestamp));
    }
    List<BloodTest> graph = BloodTest.latestForGraph(60, startTime);
    if (!graph.isEmpty()) {
        Log.d(TAG, "getBloodTests graph size=" + graph.size());
        final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
        DataMap entries = dataMapForWatchface(graph.get(0));
        for (BloodTest data : graph) {
            dataMaps.add(dataMapForWatchface(data));
        }
        entries.putDataMapArrayList("entries", dataMaps);
        Log.d(TAG, "getBloodTests entries=" + entries);
        return entries;
    } else {
        Log.d(TAG, "getBloodTests no entries for startTime=" + JoH.dateTimeText(startTime));
        return null;
    }
}
Also used : BloodTest(com.eveningoutpost.dexdrip.Models.BloodTest) ArrayList(java.util.ArrayList) DataMap(com.google.android.gms.wearable.DataMap)

Example 12 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.

the class ListenerService method sendReplyMsg.

private synchronized void sendReplyMsg(String msg, long last_timestamp, String path, boolean showToast, int length) {
    Log.d(TAG, "sendReplyMsg msg=" + msg);
    DataMap dataMap = new DataMap();
    dataMap.putString("msg", msg);
    dataMap.putLong("last_timestamp", last_timestamp);
    // eg. START_COLLECTOR_PATH
    dataMap.putString("action_path", path);
    Log.d(TAG, "sendReplyMsg dataMap=" + dataMap);
    if (showToast) {
        sendLocalToast(msg, length);
    }
    sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray());
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 13 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.

the class ListenerService method getCalibrations.

public static DataMap getCalibrations(long startTime) {
    Calibration last = Calibration.last();
    if (last != null) {
        Log.d(TAG, "getCalibrations last.timestamp:" + JoH.dateTimeText(last.timestamp));
    }
    List<Calibration> graph = Calibration.latestForGraph(60, startTime, Long.MAX_VALUE);
    // calibrations = Calibration.latestForGraph(numValues, start - (3 * Constants.DAY_IN_MS), end);
    if (!graph.isEmpty()) {
        Log.d(TAG, "getCalibrations graph size=" + graph.size());
        final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
        DataMap entries = null;
        // if (last.slope_confidence != 0) entries = dataMapForWatchface(last);
        for (Calibration data : graph) {
            if (data.slope_confidence != 0) {
                if (entries == null) {
                    entries = dataMapForWatchface(data);
                    dataMaps.add(dataMapForWatchface(data));
                } else
                    dataMaps.add(dataMapForWatchface(data));
            }
        }
        if (entries != null) {
            entries.putDataMapArrayList("entries", dataMaps);
            Log.d(TAG, "getCalibrations entries=" + entries);
        }
        return entries;
    } else
        return null;
}
Also used : ArrayList(java.util.ArrayList) Calibration(com.eveningoutpost.dexdrip.Models.Calibration) DataMap(com.google.android.gms.wearable.DataMap)

Example 14 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.

the class ListenerService method dataMap.

private DataMap dataMap(TransmitterData bg) {
    // KS
    DataMap dataMap = new DataMap();
    String json = bg.toS();
    Log.d(TAG, "dataMap BG GSON: " + json);
    dataMap.putString("bgs", json);
    return dataMap;
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 15 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.

the class ListenerService method dataMapForWatchface.

private static DataMap dataMapForWatchface(BloodTest data) {
    DataMap dataMap = new DataMap();
    dataMap.putDouble("timestamp", data.timestamp);
    dataMap.putDouble("sgvDouble", data.mgdl);
    return dataMap;
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Aggregations

DataMap (com.google.android.gms.wearable.DataMap)157 Date (java.util.Date)42 ArrayList (java.util.ArrayList)38 Gson (com.google.gson.Gson)20 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)18 GsonBuilder (com.google.gson.GsonBuilder)18 DateTypeAdapter (com.google.gson.internal.bind.DateTypeAdapter)18 Intent (android.content.Intent)17 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)14 SuppressLint (android.annotation.SuppressLint)12 PendingIntent (android.app.PendingIntent)11 Context (android.content.Context)8 Calibration (com.eveningoutpost.dexdrip.Models.Calibration)8 Treatments (com.eveningoutpost.dexdrip.Models.Treatments)8 Bundle (android.os.Bundle)6 HeartRate (com.eveningoutpost.dexdrip.Models.HeartRate)6 Paint (android.graphics.Paint)5 BloodTest (com.eveningoutpost.dexdrip.Models.BloodTest)5 BroadcastReceiver (android.content.BroadcastReceiver)4 SharedPreferences (android.content.SharedPreferences)4