diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CaloriesDailyFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CaloriesDailyFragment.java index 355cfbe6f..6689e62d0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CaloriesDailyFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CaloriesDailyFragment.java @@ -29,7 +29,6 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample; -import nodomain.freeyourgadget.gadgetbridge.entities.GarminRestingMetabolicRateSample; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; @@ -121,7 +120,7 @@ public class CaloriesDailyFragment extends AbstractChartFragment provider = device.getDeviceCoordinator().getRestingMetabolicRateProvider(device, db.getDaoSession()); return provider.getLatestSample(); } @@ -155,7 +154,10 @@ public class CaloriesDailyFragment extends AbstractChartFragment samples = getActivitySamples(db, device, startTs, endTs); - TimeSample metabolicRate = getRestingMetabolicRate(db, device); + RestingMetabolicRateSample metabolicRate = getRestingMetabolicRate(db, device); + if (metabolicRate == null) { + return new CaloriesData(0, 0, 0); + } int totalBurnt; int activeBurnt = 0; boolean sameDay = calendar.get(Calendar.DAY_OF_YEAR) == day.get(Calendar.DAY_OF_YEAR) && @@ -164,7 +166,7 @@ public class CaloriesDailyFragment extends AbstractChartFragment getSamples(DBHandler db, GBDevice device, int tsFrom, int tsTo) { return getAllSamples(db, device, tsFrom, tsTo); } - protected static TimeSample getRestingMetabolicRate(DBHandler db, GBDevice device) { + protected static RestingMetabolicRateSample getRestingMetabolicRate(DBHandler db, GBDevice device) { TimeSampleProvider provider = device.getDeviceCoordinator().getRestingMetabolicRateProvider(device, db.getDaoSession()); return provider.getLatestSample(); }