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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations