Merge branch 'last-bolus-time' into 'smb060'

Make TreatmentsPlugin.getLastBolusTime robust.

See merge request MilosKozak/AndroidAPS!384
This commit is contained in:
Milos Kozak 2018-01-29 10:37:25 +00:00
commit ac6a9ac723

View file

@ -288,12 +288,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public long getLastBolusTime() {
long now = System.currentTimeMillis();
long last = 0;
for (Integer pos = 0; pos < treatments.size(); pos++) {
Treatment t = treatments.get(pos);
if (!t.isValid)
continue;
if (t.date > last)
for (Treatment t : treatments) {
if (t.date > last && t.insulin > 0 && t.isValid && t.date <= now)
last = t.date;
}
log.debug("Last bolus time: " + new Date(last).toLocaleString());