Merge branch 'fix-predictions-cast' into 'smb'

Remove cast to DetermineBasalResultAMA for predictions.

See merge request MilosKozak/AndroidAPS!367
This commit is contained in:
Johannes Mockenhaupt 2017-10-24 21:59:37 +00:00
commit 9d4bba4190
2 changed files with 7 additions and 10 deletions

View file

@ -1323,7 +1323,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** BG **** // **** BG ****
if (showPrediction) if (showPrediction)
graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, (DetermineBasalResultAMA) finalLastRun.constraintsProcessed); graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
else else
graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, null); graphData.addBgReadings(bgGraph, fromTime, toTime, lowLine, highLine, null);

View file

@ -12,7 +12,6 @@ import com.jjoe64.graphview.series.LineGraphSeries;
import com.jjoe64.graphview.series.Series; import com.jjoe64.graphview.series.Series;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
@ -27,7 +26,7 @@ import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint;
@ -52,7 +51,7 @@ public class GraphData {
private List<BgReading> bgReadingsArray; private List<BgReading> bgReadingsArray;
private String units; private String units;
public void addBgReadings(GraphView bgGraph, long fromTime, long toTime, double lowLine, double highLine, DetermineBasalResultAMA amaResult) { public void addBgReadings(GraphView bgGraph, long fromTime, long toTime, double lowLine, double highLine, APSResult apsResult) {
double maxBgValue = 0d; double maxBgValue = 0d;
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true); bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>(); List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
@ -61,14 +60,12 @@ public class GraphData {
return; return;
} }
Iterator<BgReading> it = bgReadingsArray.iterator(); for (BgReading bg : bgReadingsArray) {
while (it.hasNext()) {
BgReading bg = it.next();
if (bg.value > maxBgValue) maxBgValue = bg.value; if (bg.value > maxBgValue) maxBgValue = bg.value;
bgListArray.add(bg); bgListArray.add(bg);
} }
if (amaResult != null) { if (apsResult != null) {
List<BgReading> predArray = amaResult.getPredictions(); List<BgReading> predArray = apsResult.getPredictions();
bgListArray.addAll(predArray); bgListArray.addAll(predArray);
} }
@ -266,7 +263,7 @@ public class GraphData {
} }
} }
double getNearestBg(long date) { private double getNearestBg(long date) {
double bg = 0; double bg = 0;
for (int r = bgReadingsArray.size() - 1; r >= 0; r--) { for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
BgReading reading = bgReadingsArray.get(r); BgReading reading = bgReadingsArray.get(r);