catch errors on load profile
This commit is contained in:
parent
cf65b3f865
commit
777b6cdb0d
1 changed files with 52 additions and 16 deletions
|
@ -90,13 +90,13 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
editor.putBoolean("SimpleProfile" + "mmol", mmol);
|
editor.putBoolean("SimpleProfile" + "mmol", mmol);
|
||||||
editor.putBoolean("SimpleProfile" + "mgdl", mgdl);
|
editor.putBoolean("SimpleProfile" + "mgdl", mgdl);
|
||||||
editor.putFloat("SimpleProfile" + "dia", new Float(dia));
|
editor.putString("SimpleProfile" + "dia", dia.toString());
|
||||||
editor.putFloat("SimpleProfile" + "ic", new Float(ic));
|
editor.putString("SimpleProfile" + "ic", ic.toString());
|
||||||
editor.putFloat("SimpleProfile" + "isf", new Float(isf));
|
editor.putString("SimpleProfile" + "isf", isf.toString());
|
||||||
editor.putFloat("SimpleProfile" + "car", new Float(car));
|
editor.putString("SimpleProfile" + "car", car.toString());
|
||||||
editor.putFloat("SimpleProfile" + "basal", new Float(basal));
|
editor.putString("SimpleProfile" + "basal", basal.toString());
|
||||||
editor.putFloat("SimpleProfile" + "targetlow", new Float(targetLow));
|
editor.putString("SimpleProfile" + "targetlow", targetLow.toString());
|
||||||
editor.putFloat("SimpleProfile" + "targethigh", new Float(targetHigh));
|
editor.putString("SimpleProfile" + "targethigh", targetHigh.toString());
|
||||||
|
|
||||||
editor.commit();
|
editor.commit();
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
|
@ -108,31 +108,67 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
|
|
||||||
if (settings.contains("SimpleProfile" + "mgdl"))
|
if (settings.contains("SimpleProfile" + "mgdl"))
|
||||||
|
try {
|
||||||
mgdl = settings.getBoolean("SimpleProfile" + "mgdl", true);
|
mgdl = settings.getBoolean("SimpleProfile" + "mgdl", true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else mgdl = true;
|
else mgdl = true;
|
||||||
if (settings.contains("SimpleProfile" + "mmol"))
|
if (settings.contains("SimpleProfile" + "mmol"))
|
||||||
|
try {
|
||||||
mmol = settings.getBoolean("SimpleProfile" + "mmol", false);
|
mmol = settings.getBoolean("SimpleProfile" + "mmol", false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else mmol = false;
|
else mmol = false;
|
||||||
if (settings.contains("SimpleProfile" + "dia"))
|
if (settings.contains("SimpleProfile" + "dia"))
|
||||||
|
try {
|
||||||
dia = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "dia", "3"));
|
dia = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "dia", "3"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else dia = 3d;
|
else dia = 3d;
|
||||||
if (settings.contains("SimpleProfile" + "ic"))
|
if (settings.contains("SimpleProfile" + "ic"))
|
||||||
|
try {
|
||||||
ic = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "ic", "20"));
|
ic = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "ic", "20"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else ic = 20d;
|
else ic = 20d;
|
||||||
if (settings.contains("SimpleProfile" + "isf"))
|
if (settings.contains("SimpleProfile" + "isf"))
|
||||||
|
try {
|
||||||
isf = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "isf", "200"));
|
isf = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "isf", "200"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else isf = 200d;
|
else isf = 200d;
|
||||||
if (settings.contains("SimpleProfile" + "car"))
|
if (settings.contains("SimpleProfile" + "car"))
|
||||||
|
try {
|
||||||
car = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "car", "20"));
|
car = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "car", "20"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else car = 20d;
|
else car = 20d;
|
||||||
if (settings.contains("SimpleProfile" + "basal"))
|
if (settings.contains("SimpleProfile" + "basal"))
|
||||||
|
try {
|
||||||
basal = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "basal", "1"));
|
basal = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "basal", "1"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else basal = 1d;
|
else basal = 1d;
|
||||||
if (settings.contains("SimpleProfile" + "targetlow"))
|
if (settings.contains("SimpleProfile" + "targetlow"))
|
||||||
|
try {
|
||||||
targetLow = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "targetlow", "80"));
|
targetLow = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "targetlow", "80"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else targetLow = 80d;
|
else targetLow = 80d;
|
||||||
if (settings.contains("SimpleProfile" + "targethigh"))
|
if (settings.contains("SimpleProfile" + "targethigh"))
|
||||||
|
try {
|
||||||
targetHigh = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "targethigh", "120"));
|
targetHigh = SafeParse.stringToDouble(settings.getString("SimpleProfile" + "targethigh", "120"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug(e.getMessage());
|
||||||
|
}
|
||||||
else targetHigh = 120d;
|
else targetHigh = 120d;
|
||||||
createConvertedProfile();
|
createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue