looper to profile switch
This commit is contained in:
parent
45ffc18d25
commit
65b8ca00db
1 changed files with 34 additions and 15 deletions
|
@ -5,6 +5,8 @@ import android.app.Activity;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
@ -102,10 +104,23 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
|
||||
Date eventTime;
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
|
||||
public void setOptions(OptionsToShow options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public NewNSTreatmentDialog() {
|
||||
super();
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(NewNSTreatmentDialog.class.getSimpleName());
|
||||
sHandlerThread.start();
|
||||
sHandler = new Handler(sHandlerThread.getLooper());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
context = (FragmentActivity) activity;
|
||||
|
@ -529,6 +544,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
|
||||
if (options.executeProfileSwitch) {
|
||||
if (data.has("profile")) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String profile = data.getString("profile");
|
||||
NSProfile nsProfile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
|
@ -541,11 +559,12 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
} else {
|
||||
log.error("No active pump selected");
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue