From f0c9ce5a003c1be52e193bdbc80d3640c4c167dd Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 30 Jun 2017 10:47:30 +0200 Subject: [PATCH] fix crash when no profile loaded from pump yet --- .../PumpDanaR/Dialogs/ProfileViewDialog.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java index ec27759b3f..4015b8856b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java @@ -17,6 +17,7 @@ import java.util.Date; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.ProfileInterface; @@ -104,14 +105,20 @@ public class ProfileViewDialog extends DialogFragment { // } else { // noProfile.setVisibility(View.GONE); // } - Profile profile = ((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfile().getDefaultProfile(); - units.setText(profile.getUnits()); - dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h"); - activeProfile.setText(((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfileName()); - ic.setText(profile.getIcList()); - isf.setText(profile.getIsfList()); - basal.setText(profile.getBasalList()); - target.setText(profile.getTargetList()); + ProfileStore store = ((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfile(); + if (store != null) { + noProfile.setVisibility(View.GONE); + Profile profile = store.getDefaultProfile(); + units.setText(profile.getUnits()); + dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h"); + activeProfile.setText(((ProfileInterface) MainApp.getConfigBuilder().getActivePump()).getProfileName()); + ic.setText(profile.getIcList()); + isf.setText(profile.getIsfList()); + basal.setText(profile.getBasalList()); + target.setText(profile.getTargetList()); + } else { + noProfile.setVisibility(View.VISIBLE); + } }