Search in sources :

Example 61 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.

the class ListenerService method getTreatments.

public static DataMap getTreatments(long startTime) {
    Treatments last = Treatments.last();
    if (last != null) {
        Log.d(TAG, "getTreatments last.timestamp:" + JoH.dateTimeText(last.timestamp));
    }
    List<Treatments> graph = Treatments.latestForGraph(60, startTime);
    if (!graph.isEmpty()) {
        Log.d(TAG, "getTreatments graph size=" + graph.size());
        final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
        DataMap entries = null;
        // if (includeTreatment(last)) entries = dataMapForWatchface(last);
        for (Treatments data : graph) {
            if (includeTreatment(data)) {
                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, "getTreatments entries=" + entries);
        }
        return entries;
    } else
        return null;
}
Also used : ArrayList(java.util.ArrayList) Treatments(com.eveningoutpost.dexdrip.Models.Treatments) DataMap(com.google.android.gms.wearable.DataMap)

Example 62 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.

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 63 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.

the class ListenerService method dataMapForWatchface.

private static DataMap dataMapForWatchface(Treatments data) {
    DataMap dataMap = new DataMap();
    // dataMap.putString("notes", data.notes);//TODO
    dataMap.putDouble("timestamp", data.timestamp);
    dataMap.putDouble("high", data.carbs);
    dataMap.putDouble("low", data.insulin);
    return dataMap;
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 64 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.

the class ListenerService method dataMap.

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

Example 65 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.

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)

Aggregations

DataMap (com.google.android.gms.wearable.DataMap)147 Date (java.util.Date)38 ArrayList (java.util.ArrayList)36 Gson (com.google.gson.Gson)18 Intent (android.content.Intent)17 GsonBuilder (com.google.gson.GsonBuilder)16 DateTypeAdapter (com.google.gson.internal.bind.DateTypeAdapter)16 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)12 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)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 Point (android.graphics.Point)4