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