draw basals only if pump is tempbasal capable

This commit is contained in:
Milos Kozak 2017-01-01 14:00:59 +01:00
parent 86f5aec0bb
commit 9edb5c9a66

View file

@ -668,27 +668,29 @@ public class OverviewFragment extends Fragment {
Double maxBasalValueFound = 0d; Double maxBasalValueFound = 0d;
long now = new Date().getTime(); long now = new Date().getTime();
List<BarDataPoint> basalArray = new ArrayList<BarDataPoint>(); if (pump.getPumpDescription().isTempBasalCapable) {
for (long time = fromTime; time < now; time += 5 * 60 * 1000L) { List<BarDataPoint> basalArray = new ArrayList<BarDataPoint>();
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date(time)); for (long time = fromTime; time < now; time += 5 * 60 * 1000L) {
Double basal = 0d; TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date(time));
if (tb != null) Double basal = 0d;
basalArray.add(new BarDataPoint(time, basal = tb.tempBasalConvertedToAbsolute(new Date(time)), true)); if (tb != null)
else basalArray.add(new BarDataPoint(time, basal = tb.tempBasalConvertedToAbsolute(new Date(time)), true));
basalArray.add(new BarDataPoint(time, basal = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time))), false)); else
maxBasalValueFound = Math.max(maxBasalValueFound, basal); basalArray.add(new BarDataPoint(time, basal = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time))), false));
} maxBasalValueFound = Math.max(maxBasalValueFound, basal);
BarDataPoint[] basal = new BarDataPoint[basalArray.size()];
basal = basalArray.toArray(basal);
bgGraph.addSeries(basalsSeries = new BarGraphSeries<DataPoint>(basal));
basalsSeries.setValueDependentColor(new ValueDependentColor<DataPoint>() {
@Override
public int get(DataPoint data) {
BarDataPoint point = (BarDataPoint) data;
if (point.isTempBasal) return Color.BLUE;
else return Color.CYAN;
} }
}); BarDataPoint[] basal = new BarDataPoint[basalArray.size()];
basal = basalArray.toArray(basal);
bgGraph.addSeries(basalsSeries = new BarGraphSeries<DataPoint>(basal));
basalsSeries.setValueDependentColor(new ValueDependentColor<DataPoint>() {
@Override
public int get(DataPoint data) {
BarDataPoint point = (BarDataPoint) data;
if (point.isTempBasal) return Color.BLUE;
else return Color.CYAN;
}
});
}
// set manual x bounds to have nice steps // set manual x bounds to have nice steps
bgGraph.getViewport().setMaxX(toTime); bgGraph.getViewport().setMaxX(toTime);
@ -784,10 +786,12 @@ public class OverviewFragment extends Fragment {
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines); bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines);
// set second scale // set second scale
bgGraph.getSecondScale().addSeries(basalsSeries); if (pump.getPumpDescription().isTempBasalCapable) {
bgGraph.getSecondScale().setMinY(0); bgGraph.getSecondScale().addSeries(basalsSeries);
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d); bgGraph.getSecondScale().setMinY(0);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide
}
} }