pass bolus data to wear graph builder
This commit is contained in:
parent
c10468e90f
commit
126322053e
|
@ -0,0 +1,12 @@
|
|||
package info.nightscout.androidaps.data;
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/11/16.
|
||||
*/
|
||||
|
||||
public class BolusWatchData {
|
||||
public long date;
|
||||
public double bolus;
|
||||
public double carbs;
|
||||
public boolean isSMB;
|
||||
}
|
|
@ -43,6 +43,7 @@ import java.util.ArrayList;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.BasalWatchData;
|
||||
import info.nightscout.androidaps.data.BgWatchData;
|
||||
import info.nightscout.androidaps.data.BolusWatchData;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.data.TempWatchData;
|
||||
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
||||
|
@ -74,6 +75,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
|
||||
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
|
||||
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
|
||||
public ArrayList<BolusWatchData> bolusWatchDataList = new ArrayList<>();
|
||||
public PowerManager.WakeLock wakeLock;
|
||||
public View layoutView;
|
||||
private final Point displaySize = new Point();
|
||||
|
@ -398,6 +400,18 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
basalWatchDataList.add(bwd);
|
||||
}
|
||||
}
|
||||
ArrayList<DataMap> boluses = dataMap.getDataMapArrayList("boluses");
|
||||
if (boluses != null) {
|
||||
bolusWatchDataList = new ArrayList<>();
|
||||
for (DataMap basal : basals) {
|
||||
BolusWatchData bwd = new BolusWatchData();
|
||||
bwd.date = basal.getLong("date");
|
||||
bwd.bolus = basal.getDouble("bolus");
|
||||
bwd.carbs = basal.getDouble("carbs");
|
||||
bwd.isSMB = basal.getBoolean("isSMB");
|
||||
bolusWatchDataList.add(bwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showAgeAndStatus() {
|
||||
|
@ -640,9 +654,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
|
||||
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
|
||||
if (lowResMode) {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
} else {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, bolusWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
}
|
||||
|
||||
chart.setLineChartData(bgGraphBuilder.lineData());
|
||||
|
|
|
@ -628,9 +628,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
|
||||
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
|
||||
if (lowResMode) {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, null, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
} else {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, null, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
|
||||
}
|
||||
|
||||
chart.setLineChartData(bgGraphBuilder.lineData());
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.TimeZone;
|
|||
|
||||
import info.nightscout.androidaps.data.BasalWatchData;
|
||||
import info.nightscout.androidaps.data.BgWatchData;
|
||||
import info.nightscout.androidaps.data.BolusWatchData;
|
||||
import info.nightscout.androidaps.data.TempWatchData;
|
||||
import lecho.lib.hellocharts.model.Axis;
|
||||
import lecho.lib.hellocharts.model.AxisValue;
|
||||
|
@ -27,6 +28,7 @@ import lecho.lib.hellocharts.model.Viewport;
|
|||
* Created by emmablack on 11/15/14.
|
||||
*/
|
||||
public class BgGraphBuilder {
|
||||
private ArrayList<BolusWatchData> bolusWatchDataList;
|
||||
private ArrayList<BasalWatchData> basalWatchDataList;
|
||||
public List<TempWatchData> tempWatchDataList;
|
||||
private int timespan;
|
||||
|
@ -55,7 +57,7 @@ public class BgGraphBuilder {
|
|||
|
||||
|
||||
//used for low resolution screen.
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
|
||||
end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
|
||||
start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
|
||||
this.bgDataList = aBgList;
|
||||
|
@ -70,12 +72,13 @@ public class BgGraphBuilder {
|
|||
this.timespan = timespan;
|
||||
this.tempWatchDataList = tempWatchDataList;
|
||||
this.basalWatchDataList = basalWatchDataList;
|
||||
this.bolusWatchDataList = (bolusWatchDataList!=null)?bolusWatchDataList:new ArrayList<BolusWatchData>();
|
||||
this.gridColour = gridColour;
|
||||
this.basalCenterColor = basalCenterColor;
|
||||
this.basalBackgroundColor = basalBackgroundColor;
|
||||
}
|
||||
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, ArrayList<BolusWatchData> bolusWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
|
||||
end_time = System.currentTimeMillis() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
|
||||
start_time = System.currentTimeMillis() - (1000 * 60 * 60 * timespan); //timespan hours ago
|
||||
this.bgDataList = aBgList;
|
||||
|
@ -89,6 +92,7 @@ public class BgGraphBuilder {
|
|||
this.timespan = timespan;
|
||||
this.tempWatchDataList = tempWatchDataList;
|
||||
this.basalWatchDataList = basalWatchDataList;
|
||||
this.bolusWatchDataList = (bolusWatchDataList!=null)?bolusWatchDataList:new ArrayList<BolusWatchData>();
|
||||
this.gridColour = gridColour;
|
||||
this.basalCenterColor = basalCenterColor;
|
||||
this.basalBackgroundColor = basalBackgroundColor;
|
||||
|
|
Loading…
Reference in a new issue