Prevent NPE

This commit is contained in:
Milos Kozak 2021-11-08 16:27:47 +01:00
parent c1f4a13b09
commit 7cd136bf23

View file

@ -51,9 +51,9 @@ public class AutosensData implements DataPointWithLabelInterface {
time = t.getTimestamp();
carbs = t.getAmount();
remaining = t.getAmount();
if (isAAPSOrWeighted) {
double maxAbsorptionHours = sp.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
Profile profile = profileFunction.getProfile(t.getTimestamp());
if (isAAPSOrWeighted && profile != null) {
double maxAbsorptionHours = sp.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
double sens = profile.getIsfMgdl(t.getTimestamp());
double ic = profile.getIc(t.getTimestamp());
min5minCarbImpact = t.getAmount() / (maxAbsorptionHours * 60 / 5) * sens / ic;