wear bgGraphbuilder isValid bolus

This commit is contained in:
AdrianLxM 2018-03-04 14:06:19 +01:00
parent acf7e36d61
commit a4eb82c524

View file

@ -9,7 +9,6 @@ import android.text.format.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
@ -51,7 +50,7 @@ public class BgGraphBuilder {
public int gridColour; public int gridColour;
public int basalCenterColor; public int basalCenterColor;
public int basalBackgroundColor; public int basalBackgroundColor;
private int bolusColor; private int bolusInvalidColor;
public boolean singleLine = false; public boolean singleLine = false;
private List<PointValue> inRangeValues = new ArrayList<PointValue>(); private List<PointValue> inRangeValues = new ArrayList<PointValue>();
@ -61,7 +60,7 @@ public class BgGraphBuilder {
//used for low resolution screen. //used for low resolution screen.
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusColor, int timespan) { public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int timespan) {
this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList; this.bgDataList = aBgList;
this.predictionsList = predictionsList; this.predictionsList = predictionsList;
@ -80,13 +79,13 @@ public class BgGraphBuilder {
this.gridColour = gridColour; this.gridColour = gridColour;
this.basalCenterColor = basalCenterColor; this.basalCenterColor = basalCenterColor;
this.basalBackgroundColor = basalBackgroundColor; this.basalBackgroundColor = basalBackgroundColor;
this.bolusColor = bolusColor; this.bolusInvalidColor = bolusInvalidColor;
this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
this.predictionEndTime = getPredictionEndTime(); this.predictionEndTime = getPredictionEndTime();
this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time; this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time;
} }
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusColor, int timespan) { public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<BgWatchData> predictionsList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int bolusInvalidColor, int timespan) {
this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago this.start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
this.bgDataList = aBgList; this.bgDataList = aBgList;
this.predictionsList = predictionsList; this.predictionsList = predictionsList;
@ -104,7 +103,7 @@ public class BgGraphBuilder {
this.gridColour = gridColour; this.gridColour = gridColour;
this.basalCenterColor = basalCenterColor; this.basalCenterColor = basalCenterColor;
this.basalBackgroundColor = basalBackgroundColor; this.basalBackgroundColor = basalBackgroundColor;
this.bolusColor = bolusColor; this.bolusInvalidColor = bolusInvalidColor;
this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) this.end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
this.predictionEndTime = getPredictionEndTime(); this.predictionEndTime = getPredictionEndTime();
this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time; this.end_time = (predictionEndTime>end_time)?predictionEndTime:end_time;
@ -172,6 +171,7 @@ public class BgGraphBuilder {
lines.add(basalLine((float) minChart, factor, highlight)); lines.add(basalLine((float) minChart, factor, highlight));
lines.add(bolusLine((float) minChart)); lines.add(bolusLine((float) minChart));
lines.add(bolusInvalidLine((float) minChart));
lines.add(smbLine((float) minChart)); lines.add(smbLine((float) minChart));
lines.add(predictionLine()); lines.add(predictionLine());
@ -206,12 +206,12 @@ public class BgGraphBuilder {
List<PointValue> pointValues = new ArrayList<PointValue>(); List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) { for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && !bwd.isSMB && !bwd.isValid && bwd.bolus > 0) { if(bwd.date > start_time && !bwd.isSMB && bwd.isValid && bwd.bolus > 0) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2));
} }
} }
Line line = new Line(pointValues); Line line = new Line(pointValues);
line.setColor(bolusColor); line.setColor(bolusInvalidColor);
line.setHasLines(false); line.setHasLines(false);
line.setPointRadius(pointSize*2); line.setPointRadius(pointSize*2);
line.setHasPoints(true); line.setHasPoints(true);
@ -223,7 +223,7 @@ public class BgGraphBuilder {
List<PointValue> pointValues = new ArrayList<PointValue>(); List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) { for (BolusWatchData bwd: bolusWatchDataList) {
if(bwd.date > start_time && bwd.isSMB && !bwd.isValid && bwd.bolus > 0) { if(bwd.date > start_time && bwd.isSMB && bwd.isValid && bwd.bolus > 0) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2)); pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2));
} }
} }
@ -235,6 +235,24 @@ public class BgGraphBuilder {
return line; return line;
} }
private Line bolusInvalidLine(float offset) {
List<PointValue> pointValues = new ArrayList<PointValue>();
for (BolusWatchData bwd: bolusWatchDataList) {
if(!(bwd.isValid && bwd.bolus > 0)) {
pointValues.add(new PointValue(fuzz(bwd.date), (float) offset-2));
}
}
Line line = new Line(pointValues);
line.setColor(bolusInvalidColor);
line.setHasLines(false);
line.setPointRadius(pointSize);
line.setHasPoints(true);
return line;
}
private Line predictionLine() { private Line predictionLine() {
List<PointValue> pointValues = new ArrayList<PointValue>(); List<PointValue> pointValues = new ArrayList<PointValue>();