handle switching profiles in correct order

This commit is contained in:
Milos Kozak 2016-12-25 23:18:46 +01:00
parent 463a913cd1
commit a109bb9853
2 changed files with 5 additions and 7 deletions

View file

@ -245,10 +245,8 @@ public class DataService extends IntentService {
String activeProfile = bundles.getString("activeprofile");
String profile = bundles.getString("profile");
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
if (MainApp.getConfigBuilder() == null) {
log.error("Config builder not ready on receive profile");
return;
}
MainApp.bus().post(new EventNewBasalProfile(nsProfile));
PumpInterface pump = MainApp.getConfigBuilder();
if (pump != null) {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
@ -260,13 +258,11 @@ public class DataService extends IntentService {
}
}
}
} else {
log.error("No active pump selected");
}
if (Config.logIncommingData)
log.debug("Received profile: " + activeProfile + " " + profile);
MainApp.bus().post(new EventNewBasalProfile(nsProfile));
} catch (JSONException e) {
e.printStackTrace();
}

View file

@ -541,7 +541,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
builder.setMessage(confirmText);
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
if (options.executeProfileSwitch) {
if (data.has("profile")) {
sHandler.post(new Runnable() {
@ -559,12 +558,15 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
} else {
log.error("No active pump selected");
}
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
} else {
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
}
}
});