This commit is contained in:
Milos Kozak 2018-01-04 23:12:40 +01:00
commit aff0e6f5a8
3 changed files with 14 additions and 3 deletions

View file

@ -64,14 +64,21 @@ public class GlucoseStatus {
return this;
}
@Nullable
public static GlucoseStatus getGlucoseStatusData() {
public static GlucoseStatus getGlucoseStatusData(){
return getGlucoseStatusData(false);
}
@Nullable
public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) {
// load 45min
long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45);
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
int sizeRecords = data.size();
if (sizeRecords < 1 || data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L) {
if (sizeRecords < 1 || (data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L && !allowOldData)) {
return null;
}

View file

@ -316,7 +316,7 @@ public class WatchUpdaterService extends WearableListenerService implements
if (last_bg == null) return;
List<BgReading> graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true);
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(true);
if (!graph_bgs.isEmpty()) {
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);

View file

@ -569,6 +569,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
if("delta_granularity".equals(key)){
ListenerService.requestData(this);
}
if(layoutSet){
setDataFields();
setColor();