Merge pull request #1015 from jotomo/lemming-treatment

Fix finding BG in graph for treatments before the first displayed BG.
This commit is contained in:
AdrianLxM 2018-05-06 19:51:01 +02:00 committed by GitHub
commit cdc8e45f32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -320,14 +320,13 @@ public class GraphData {
}
private double getNearestBg(long date) {
double bg = 0;
for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
BgReading reading = bgReadingsArray.get(r);
if (reading.date > date) continue;
bg = Profile.fromMgdlToUnits(reading.value, units);
break;
return Profile.fromMgdlToUnits(reading.value, units);
}
return bg;
return bgReadingsArray.size() > 0
? Profile.fromMgdlToUnits(bgReadingsArray.get(0).value, units) : 0;
}
// scale in % of vertical size (like 0.3)