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());
}
public double tempBasalConvertedToAbsolute() {
if (isAbsolute) return absolute;
else {
public double tempBasalConvertedToAbsolute(Date time) {
if (isExtended) {
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
double absval = profile.getBasal(NSProfile.secondsFromMidnight()) * percent / 100;
double absval = profile.getBasal(NSProfile.secondsFromMidnight(time)) + absolute;
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) {
TempBasal tb = MainApp.getConfigBuilder().getActiveTempBasals().getTempBasal(new Date(time));
if (tb != null)
basalArray.add(new BarDataPoint(time, tb.tempBasalConvertedToAbsolute(), true));
basalArray.add(new BarDataPoint(time, tb.tempBasalConvertedToAbsolute(new Date(time)), true));
else
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) {
if (t.isInProgress(time)) return t;
}
if (useExtendedBoluses) {
return getExtendedBolus(time);
}
return null;
}