From ab41541c6906854f0d59a3a1513baf9460e9e9e1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 28 Jun 2018 22:31:42 +0200 Subject: [PATCH] fix NPE --- .../androidaps/plugins/Overview/OverviewFragment.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index eb13cf5ef8..de7c20d45b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1414,13 +1414,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, final long fromTime; final long endTime; - APSResult apsResult; - if (Config.APS) - apsResult = finalLastRun.constraintsProcessed; - else - apsResult = NSDeviceStatus.getAPSResult(); + APSResult apsResult = null; if (finalPredictionsAvailable && SP.getBoolean("showprediction", false)) { + if (Config.APS) + apsResult = finalLastRun.constraintsProcessed; + else + apsResult = NSDeviceStatus.getAPSResult(); int predHours = (int) (Math.ceil(apsResult.getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000)); predHours = Math.min(2, predHours); predHours = Math.max(0, predHours);