fix displaying temps from extended on overview page

This commit is contained in:
Milos Kozak 2016-07-12 00:08:45 +02:00
parent 9e7b018589
commit 4c312366c2
3 changed files with 14 additions and 5 deletions

View file

@ -148,12 +148,18 @@ public class TempBasal {
return isInProgress(new Date()); return isInProgress(new Date());
} }
public double tempBasalConvertedToAbsolute() { public double tempBasalConvertedToAbsolute(Date time) {
if (isAbsolute) return absolute; if (isExtended) {
else {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
double absval = profile.getBasal(NSProfile.secondsFromMidnight()) * percent / 100; double absval = profile.getBasal(NSProfile.secondsFromMidnight(time)) + absolute;
return absval; return absval;
} else {
if (isAbsolute) return absolute;
else {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
double absval = profile.getBasal(NSProfile.secondsFromMidnight(time)) * percent / 100;
return absval;
}
} }
} }

View file

@ -534,7 +534,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
for (long time = fromTime; time < now; time += 5 * 60 * 1000L) { for (long time = fromTime; time < now; time += 5 * 60 * 1000L) {
TempBasal tb = MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(new Date(time)); TempBasal tb = MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(new Date(time));
if (tb != null) if (tb != null)
basalArray.add(new BarDataPoint(time, tb.tempBasalConvertedToAbsolute(), true)); basalArray.add(new BarDataPoint(time, tb.tempBasalConvertedToAbsolute(new Date(time)), true));
else else
basalArray.add(new BarDataPoint(time, profile.getBasal(NSProfile.secondsFromMidnight(new Date(time))), false)); basalArray.add(new BarDataPoint(time, profile.getBasal(NSProfile.secondsFromMidnight(new Date(time))), false));
} }

View file

@ -230,6 +230,9 @@ public class TempBasalsFragment extends Fragment implements PluginBase, TempBasa
for (TempBasal t : tempBasals) { for (TempBasal t : tempBasals) {
if (t.isInProgress(time)) return t; if (t.isInProgress(time)) return t;
} }
if (useExtendedBoluses) {
return getExtendedBolus(time);
}
return null; return null;
} }