check for null profile
This commit is contained in:
parent
b6ce7c03c6
commit
1e359184a9
12 changed files with 48 additions and 49 deletions
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.interfaces;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,7 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
|
@ -404,6 +404,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile));
|
||||||
|
dismiss();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -672,7 +672,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
||||||
|
|
||||||
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && actualBg != null) {
|
if (quickWizardEntry != null && actualBg != null && profile != null) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
final BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, actualBg, true);
|
final BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, actualBg, true);
|
||||||
|
|
||||||
|
@ -964,16 +964,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
String units = profile.getUnits();
|
if (profile == null) {
|
||||||
|
|
||||||
if (units == null) {
|
|
||||||
pumpStatusView.setText(R.string.noprofileset);
|
pumpStatusView.setText(R.string.noprofileset);
|
||||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||||
loopStatusLayout.setVisibility(View.GONE);
|
loopStatusLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String units = profile.getUnits();
|
||||||
final double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
final double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
||||||
final double highLine = OverviewPlugin.getPlugin().determineHighLine(units);
|
final double highLine = OverviewPlugin.getPlugin().determineHighLine(units);
|
||||||
|
|
||||||
|
@ -1092,12 +1091,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
basalText = "T: " + activeTemp.toStringVeryShort();
|
basalText = "T: " + activeTemp.toStringVeryShort();
|
||||||
} else {
|
} else {
|
||||||
basalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h";
|
basalText = DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h";
|
||||||
}
|
}
|
||||||
baseBasalView.setOnClickListener(new View.OnClickListener() {
|
baseBasalView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String fullText = MainApp.sResources.getString(R.string.pump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h\n";
|
String fullText = MainApp.sResources.getString(R.string.pump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(profile.getBasal()) + "U/h\n";
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
fullText += MainApp.sResources.getString(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
fullText += MainApp.sResources.getString(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
||||||
}
|
}
|
||||||
|
@ -1110,7 +1109,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
basalText = activeTemp.toStringFull() + " ";
|
basalText = activeTemp.toStringFull() + " ";
|
||||||
}
|
}
|
||||||
if (Config.NSCLIENT || Config.G5UPLOADER)
|
if (Config.NSCLIENT || Config.G5UPLOADER)
|
||||||
basalText += "(" + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + " U/h)";
|
basalText += "(" + DecimalFormatter.to2Decimal(profile.getBasal()) + " U/h)";
|
||||||
else if (pump.getPumpDescription().isTempBasalCapable) {
|
else if (pump.getPumpDescription().isTempBasalCapable) {
|
||||||
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
|
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
|
||||||
}
|
}
|
||||||
|
@ -1373,7 +1372,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
// add target line
|
// add target line
|
||||||
graphData.addTargetLine(fromTime, toTime);
|
graphData.addTargetLine(fromTime, toTime, profile);
|
||||||
|
|
||||||
// **** NOW line ****
|
// **** NOW line ****
|
||||||
graphData.addNowLine(now);
|
graphData.addNowLine(now);
|
||||||
|
|
|
@ -221,12 +221,7 @@ public class GraphData {
|
||||||
addSeries(absoluteBasalsLineSeries);
|
addSeries(absoluteBasalsLineSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTargetLine(long fromTime, long toTime) {
|
public void addTargetLine(long fromTime, long toTime, Profile profile) {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
if (profile == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineGraphSeries<DataPoint> targetsSeries;
|
LineGraphSeries<DataPoint> targetsSeries;
|
||||||
|
|
||||||
Scale targetsScale = new Scale();
|
Scale targetsScale = new Scale();
|
||||||
|
|
|
@ -120,6 +120,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
profile = new ProfileStore(newProfile.getData());
|
profile = new ProfileStore(newProfile.getData());
|
||||||
storeNSProfile();
|
storeNSProfile();
|
||||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||||
|
if (MainApp.getConfigBuilder().isProfileValid("storeNewProfile")) {
|
||||||
ConfigBuilderPlugin.getCommandQueue().setProfile(MainApp.getConfigBuilder().getProfile(), new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().setProfile(MainApp.getConfigBuilder().getProfile(), new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -132,6 +133,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void storeNSProfile() {
|
private void storeNSProfile() {
|
||||||
SP.putString("profile", profile.getData().toString());
|
SP.putString("profile", profile.getData().toString());
|
||||||
|
|
|
@ -85,12 +85,6 @@ public class ProfileViewDialog extends DialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setContent() {
|
private void setContent() {
|
||||||
// if (profile == null) {
|
|
||||||
// noProfile.setVisibility(View.VISIBLE);
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// noProfile.setVisibility(View.GONE);
|
|
||||||
// }
|
|
||||||
ProfileStore store = ((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfile();
|
ProfileStore store = ((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfile();
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
noProfile.setVisibility(View.GONE);
|
noProfile.setVisibility(View.GONE);
|
||||||
|
|
|
@ -114,6 +114,13 @@ public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
|
||||||
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
|
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 4;
|
||||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||||
|
|
||||||
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
|
if (profile == null) {
|
||||||
|
log.debug("No profile");
|
||||||
|
return new AutosensResult();
|
||||||
|
}
|
||||||
|
|
||||||
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
||||||
log.debug("No autosens data available");
|
log.debug("No autosens data available");
|
||||||
return new AutosensResult();
|
return new AutosensResult();
|
||||||
|
@ -159,8 +166,6 @@ public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
|
||||||
Double[] deviations = new Double[deviationsArray.size()];
|
Double[] deviations = new Double[deviationsArray.size()];
|
||||||
deviations = deviationsArray.toArray(deviations);
|
deviations = deviationsArray.toArray(deviations);
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
|
|
||||||
double sens = profile.getIsf();
|
double sens = profile.getIsf();
|
||||||
|
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
|
|
|
@ -88,8 +88,13 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(tempBasal.durationInMinutes) + " min");
|
holder.duration.setText(DecimalFormatter.to0Decimal(tempBasal.durationInMinutes) + " min");
|
||||||
if (tempBasal.isAbsolute) {
|
if (tempBasal.isAbsolute) {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile(tempBasal.date);
|
Profile profile = MainApp.getConfigBuilder().getProfile(tempBasal.date);
|
||||||
|
if (profile != null) {
|
||||||
holder.absolute.setText(DecimalFormatter.to0Decimal(tempBasal.tempBasalConvertedToAbsolute(tempBasal.date, profile)) + " U/h");
|
holder.absolute.setText(DecimalFormatter.to0Decimal(tempBasal.tempBasalConvertedToAbsolute(tempBasal.date, profile)) + " U/h");
|
||||||
holder.percent.setText("");
|
holder.percent.setText("");
|
||||||
|
} else {
|
||||||
|
holder.absolute.setText(MainApp.gs(R.string.noprofile));
|
||||||
|
holder.percent.setText("");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.absolute.setText("");
|
holder.absolute.setText("");
|
||||||
holder.percent.setText(DecimalFormatter.to0Decimal(tempBasal.percentRate) + "%");
|
holder.percent.setText(DecimalFormatter.to0Decimal(tempBasal.percentRate) + "%");
|
||||||
|
|
|
@ -332,16 +332,16 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
private static String generateTDDMessage(List<DanaRHistoryRecord> historyList, List<DanaRHistoryRecord> dummies) {
|
private static String generateTDDMessage(List<DanaRHistoryRecord> historyList, List<DanaRHistoryRecord> dummies) {
|
||||||
|
|
||||||
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
if (activeProfile == null) {
|
if (profile == null) {
|
||||||
return "No profile loaded :(";
|
return "No profile loaded :(";
|
||||||
}
|
}
|
||||||
|
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
String message = "";
|
String message = "";
|
||||||
|
|
||||||
double refTDD = activeProfile.getProfile().getDefaultProfile().baseBasalSum() * 2;
|
double refTDD = profile.baseBasalSum() * 2;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
double sum = 0d;
|
double sum = 0d;
|
||||||
|
|
|
@ -149,14 +149,13 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
|
|
||||||
|
|
||||||
private void sendStatus() {
|
private void sendStatus() {
|
||||||
|
|
||||||
|
|
||||||
String status = ""; // sent once on disable
|
String status = ""; // sent once on disable
|
||||||
|
|
||||||
if (fragmentEnabled) {
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
status = buildStatusString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (fragmentEnabled && profile != null) {
|
||||||
|
status = buildStatusString(profile);
|
||||||
|
}
|
||||||
|
|
||||||
//sendData
|
//sendData
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
|
@ -168,7 +167,7 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String buildStatusString() {
|
private String buildStatusString(Profile profile) {
|
||||||
String status = "";
|
String status = "";
|
||||||
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||||
|
|
||||||
|
@ -200,10 +199,6 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
+ DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
|
||||||
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
+ DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
|
||||||
}
|
}
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
|
|
||||||
if (profile == null)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
if (!mPrefs.getBoolean("xdripstatus_showbgi", false)) {
|
if (!mPrefs.getBoolean("xdripstatus_showbgi", false)) {
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -403,10 +403,11 @@ public class CommandQueue {
|
||||||
|
|
||||||
public boolean isThisProfileSet(Profile profile) {
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
PumpInterface activePump = ConfigBuilderPlugin.getActivePump();
|
PumpInterface activePump = ConfigBuilderPlugin.getActivePump();
|
||||||
if (activePump != null) {
|
Profile current = MainApp.getConfigBuilder().getProfile();
|
||||||
|
if (activePump != null && current != null) {
|
||||||
boolean result = activePump.isThisProfileSet(profile);
|
boolean result = activePump.isThisProfileSet(profile);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
log.debug("Current profile: " + MainApp.getConfigBuilder().getProfile().getData().toString());
|
log.debug("Current profile: " + current.getData().toString());
|
||||||
log.debug("New profile: " + profile.getData().toString());
|
log.debug("New profile: " + profile.getData().toString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue