resolve NPE

This commit is contained in:
Milos Kozak 2018-05-23 23:43:41 +02:00
parent 683caf78f8
commit d642418e02
2 changed files with 4 additions and 3 deletions

View file

@ -347,13 +347,12 @@ public class IobCobCalculatorPlugin extends PluginBase {
return null;
}
public BasalData getBasalData(long time) {
public BasalData getBasalData(Profile profile, long time) {
long now = System.currentTimeMillis();
time = roundUpTime(time);
BasalData retval = basalDataTable.get(time);
if (retval == null) {
retval = new BasalData();
Profile profile = MainApp.getConfigBuilder().getProfile(time);
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(time);
retval.basal = profile.getBasal(time);
if (tb != null) {

View file

@ -136,7 +136,9 @@ public class GraphData {
double lastBaseBasal = 0;
double lastTempBasal = 0;
for (long time = fromTime; time < toTime; time += 60 * 1000L) {
BasalData basalData = IobCobCalculatorPlugin.getPlugin().getBasalData(time);
Profile profile = MainApp.getConfigBuilder().getProfile(time);
if (profile == null) continue;
BasalData basalData = IobCobCalculatorPlugin.getPlugin().getBasalData(profile, time);
double baseBasalValue = basalData.basal;
double absoluteLineValue = baseBasalValue;
double tempBasalValue = 0;