Merge pull request #952 from jotomo/rainbow
Fix missing predictions in graph, color them.
This commit is contained in:
commit
dbca668afd
|
@ -211,7 +211,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
}
|
||||
int color = MainApp.sResources.getColor(R.color.inrange);
|
||||
if (isPrediction())
|
||||
color = MainApp.sResources.getColor(R.color.prediction);
|
||||
return getPredectionColor();
|
||||
else if (valueToUnits(units) < lowLine)
|
||||
color = MainApp.sResources.getColor(R.color.low);
|
||||
else if (valueToUnits(units) > highLine)
|
||||
|
@ -219,8 +219,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
private int getPredectionColor() {
|
||||
if (isIOBPrediction)
|
||||
return MainApp.sResources.getColor(R.color.iob);
|
||||
if (isCOBPrediction)
|
||||
|
|
|
@ -263,9 +263,4 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
|||
return Color.GRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -297,8 +297,4 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
|||
return Color.CYAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,11 +263,6 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
|||
return Color.CYAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ProfileSwitch{" +
|
||||
"date=" + date +
|
||||
|
|
|
@ -164,9 +164,4 @@ public class AutosensData implements DataPointWithLabelInterface {
|
|||
return MainApp.gc(R.color.cob);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1359,7 +1359,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
// **** BG ****
|
||||
if (predictionsAvailable && SP.getBoolean("showprediction", false))
|
||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
|
||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine,
|
||||
finalLastRun.constraintsProcessed.getPredictions());
|
||||
else
|
||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.jjoe64.graphview.series.LineGraphSeries;
|
|||
import com.jjoe64.graphview.series.Series;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
|
@ -61,7 +62,7 @@ public class GraphData {
|
|||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||
}
|
||||
|
||||
public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, APSResult apsResult) {
|
||||
public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, List<BgReading> predictions) {
|
||||
double maxBgValue = 0d;
|
||||
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
||||
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
||||
|
@ -74,9 +75,12 @@ public class GraphData {
|
|||
if (bg.value > maxBgValue) maxBgValue = bg.value;
|
||||
bgListArray.add(bg);
|
||||
}
|
||||
if (apsResult != null) {
|
||||
List<BgReading> predArray = apsResult.getPredictions();
|
||||
bgListArray.addAll(predArray);
|
||||
if (predictions != null) {
|
||||
Collections.sort(predictions, (o1, o2) -> Double.compare(o1.getX(), o2.getX()));
|
||||
for (BgReading prediction : predictions) {
|
||||
if (prediction.value >= 40)
|
||||
bgListArray.add(prediction);
|
||||
}
|
||||
}
|
||||
|
||||
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
|
||||
|
@ -273,6 +277,7 @@ public class GraphData {
|
|||
for (int tx = 0; tx < treatments.size(); tx++) {
|
||||
Treatment t = treatments.get(tx);
|
||||
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
||||
if (t.isSMB && !t.isValid) continue;
|
||||
t.setY(getNearestBg((long) t.getX()));
|
||||
filteredTreatments.add(t);
|
||||
}
|
||||
|
|
|
@ -55,5 +55,4 @@ public interface DataPointWithLabelInterface extends DataPointInterface{
|
|||
PointsWithLabelGraphSeries.Shape getShape();
|
||||
float getSize();
|
||||
int getColor();
|
||||
int getSecondColor();
|
||||
}
|
||||
|
|
|
@ -211,7 +211,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
|||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setStrokeWidth(0);
|
||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
||||
mPaint.setColor(value.getSecondColor());
|
||||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setStrokeWidth(0);
|
||||
canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint);
|
||||
|
|
|
@ -193,11 +193,6 @@ public class Treatment implements DataPointWithLabelInterface {
|
|||
return MainApp.instance().getResources().getColor(android.R.color.holo_red_light);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(double y) {
|
||||
yValue = y;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<color name="bolus">#FFFFCC03</color>
|
||||
<color name="cob">#FFFB8C00</color>
|
||||
<color name="uam">#ffea00</color>
|
||||
<color name="zt">#ff9500</color>
|
||||
<color name="zt">#00ffff</color>
|
||||
<color name="ratio">#FFFFFF</color>
|
||||
<color name="devslopepos">#FFFFFF00</color>
|
||||
<color name="devslopeneg">#FFFF00FF</color>
|
||||
|
|
Loading…
Reference in a new issue