diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java index 43661b117a..cbdd5d696a 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java @@ -31,7 +31,7 @@ public interface TreatmentsInterface { MealData getMealData(); List getTreatmentsFromHistory(); - List getTreatments5MinBackFromHistory(long time); + List getCarbTreatments5MinBackFromHistory(long time); List getTreatmentsFromHistoryAfterTimestamp(long timestamp); long getLastBolusTime(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index 57a1bba9ed..9fe87856b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -237,11 +237,11 @@ public class IobCobOref1Thread extends Thread { } } - List recentTreatments = TreatmentsPlugin.getPlugin().getTreatments5MinBackFromHistory(bgTime); - for (int ir = 0; ir < recentTreatments.size(); ir++) { - autosensData.carbsFromBolus += recentTreatments.get(ir).carbs; - autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir))); - autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentTreatments.get(ir).carbs) + "g]"; + List recentCarbTreatments = TreatmentsPlugin.getPlugin().getCarbTreatments5MinBackFromHistory(bgTime); + for (Treatment recentCarbTreatment : recentCarbTreatments) { + autosensData.carbsFromBolus += recentCarbTreatment.carbs; + autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentCarbTreatment)); + autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentCarbTreatment.carbs) + "g]"; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index fba1555d4c..7389e39b8d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -236,11 +236,11 @@ public class IobCobThread extends Thread { } } - List recentTreatments = TreatmentsPlugin.getPlugin().getTreatments5MinBackFromHistory(bgTime); - for (int ir = 0; ir < recentTreatments.size(); ir++) { - autosensData.carbsFromBolus += recentTreatments.get(ir).carbs; - autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir))); - autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentTreatments.get(ir).carbs) + "g]"; + List recentCarbTreatments = TreatmentsPlugin.getPlugin().getCarbTreatments5MinBackFromHistory(bgTime); + for (Treatment recentCarbTreatment : recentCarbTreatments) { + autosensData.carbsFromBolus += recentCarbTreatment.carbs; + autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentCarbTreatment)); + autosensData.pastSensitivity += "[" + DecimalFormatter.to0Decimal(recentCarbTreatment.carbs) + "g]"; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 69589a126f..8ec0b48ffa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -361,11 +361,10 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface @Override - public List getTreatments5MinBackFromHistory(long time) { + public List getCarbTreatments5MinBackFromHistory(long time) { List in5minback = new ArrayList<>(); synchronized (treatments) { - for (Integer pos = 0; pos < treatments.size(); pos++) { - Treatment t = treatments.get(pos); + for (Treatment t : treatments) { if (!t.isValid) continue; if (t.date <= time && t.date > time - 5 * 60 * 1000 && t.carbs > 0)