use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.
the class BaseWatchFace method addToWatchSetTreats.
public void addToWatchSetTreats(DataMap dataMap, ArrayList<BgWatchData> dataList) {
if (d)
Log.d(TAG, "addToWatchSetTreats dataList.size()=" + (dataList != null ? dataList.size() : "0"));
// necessary since treatments, bloodtest and calibrations can be deleted/invalidated
dataList.clear();
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
if (d)
Log.d(TAG, "addToWatchSetTreats entries.size()=" + entries.size() + " entries=" + entries);
for (DataMap entry : entries) {
addDataMapTreats(entry, dataList);
}
}
if (d)
Log.d(TAG, "addToWatchSetTreats dataList.size()=" + dataList.size());
}
use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.
the class CircleWatchface method addToWatchSet.
public void addToWatchSet(DataMap dataMap) {
Log.d(TAG, "addToWatchSet bgDataList.size()=" + bgDataList.size());
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
Log.d(TAG, "addToWatchSet entries.size()=" + entries.size());
for (DataMap entry : entries) {
addDataMap(entry);
}
} else {
addDataMap(dataMap);
}
for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) {
// Get rid of anything more than 5 hours old
bgDataList.remove(i);
break;
}
}
Collections.sort(bgDataList);
}
use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.
the class HeartRateService method dataMap.
// this is pretty inefficient - maybe eventually replace with protobuf
private static DataMap dataMap(HeartRate log) {
final DataMap dataMap = new DataMap();
final String json = log.toS();
dataMap.putString("entry", json);
return dataMap;
}
use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.
the class HeartRateService method getWearHeartSensorData.
public static synchronized DataMap getWearHeartSensorData(int count, long last_send_time, int min_count) {
UserError.Log.d(TAG, "getWearHeartSensorData last_send_time:" + JoH.dateTimeText(last_send_time));
if ((count != 0) || (JoH.ratelimit("heartrate-datamap", 5))) {
HeartRate last_log = HeartRate.last();
if (last_log != null) {
UserError.Log.d(TAG, "getWearHeartSensorData last_log.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
} else {
UserError.Log.d(TAG, "getWearHeartSensorData HeartRate.last() = null:");
return null;
}
if (last_log != null && last_send_time <= last_log.timestamp) {
// startTime
long last_send_success = last_send_time;
UserError.Log.d(TAG, "getWearHeartSensorData last_send_time < last_bg.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
List<HeartRate> logs = HeartRate.latestForGraph(count, last_send_time);
if (!logs.isEmpty() && logs.size() > min_count) {
DataMap entries = dataMap(last_log);
final ArrayList<DataMap> dataMaps = new ArrayList<>(logs.size());
for (HeartRate log : logs) {
dataMaps.add(dataMap(log));
last_send_success = (long) log.timestamp;
}
// MOST IMPORTANT LINE FOR TIMESTAMP
entries.putLong("time", JoH.tsl());
entries.putDataMapArrayList("entries", dataMaps);
UserError.Log.i(TAG, "getWearHeartSensorData SYNCED up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size());
return entries;
} else
UserError.Log.i(TAG, "getWearHeartSensorData SYNCED up to " + JoH.dateTimeText(last_send_success) + " count = 0");
}
return null;
} else {
UserError.Log.d(TAG, "Ratelimitted getWearHeartSensorData");
return null;
}
}
use of com.google.android.gms.wearable.DataMap in project xDrip-plus by jamorham.
the class Simulation method Approve.
public void Approve(View myview) {
if (watchkeypad) {
// Treatments.create(carbs, insulin, thisnotes, new Date().getTime());
DataMap dataMap = new DataMap();
dataMap.putDouble("timeoffset", timeoffset);
dataMap.putDouble("carbs", carbs);
dataMap.putDouble("insulin", insulin);
dataMap.putDouble("bloodtest", bloodtest);
dataMap.putString("notes", thisnotes);
// dataMap.putLong("timestamp", System.currentTimeMillis());
ListenerService.createTreatment(dataMap, this);
} else
SendData(this, WEARABLE_APPROVE_TREATMENT, null);
finish();
}
Aggregations