Do calculations in a central place
This commit is contained in:
parent
7d4eec6c99
commit
468b645486
|
@ -839,7 +839,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (wizard.superBolus) {
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
loopPlugin.superBolusTo(System.currentTimeMillis() + DateUtil.hourToMs(2));
|
||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||
}
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||
|
@ -1426,12 +1426,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
predHours = Math.max(0, predHours);
|
||||
hoursToFetch = rangeToDisplay - predHours;
|
||||
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
||||
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
||||
endTime = toTime + predHours * 60 * 60 * 1000L;
|
||||
fromTime = toTime - DateUtil.hourToMs(hoursToFetch);
|
||||
endTime = toTime + DateUtil.hourToMs(predHours);
|
||||
} else {
|
||||
hoursToFetch = rangeToDisplay;
|
||||
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
|
||||
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
|
||||
fromTime = toTime - DateUtil.hourToMs(hoursToFetch);
|
||||
endTime = toTime;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,4 +180,8 @@ public class DateUtil {
|
|||
return date - date % 1000;
|
||||
}
|
||||
|
||||
public static long hourToMs(long hour) {
|
||||
return hour * 60 * 60 * 1000L;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue