more dialogs tweaking

This commit is contained in:
Milos Kozak 2016-08-14 20:33:29 +02:00
parent bb041b1c06
commit 8864886702
4 changed files with 16 additions and 14 deletions

View file

@ -351,12 +351,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
if (bolusProgressDialog != null) {
bolusProgressDialog.dismiss();
}
bolusProgressDialog.bolusEnded = true;
if (Config.logCongigBuilderActions)
log.debug("deliverTreatmentFromBolusWizard insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
if (bolusProgressDialog != null && bolusProgressDialog.running) {
try {
bolusProgressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace(); // TODO: handle this better
}
}
if (result.success) {
Treatment t = new Treatment();

View file

@ -38,13 +38,10 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
Handler mHandler;
public static HandlerThread mHandlerThread;
Context parentContext = null;
public NewTreatmentDialog(Context context) {
public NewTreatmentDialog() {
mHandlerThread = new HandlerThread(NewTreatmentDialog.class.getSimpleName());
mHandlerThread.start();
this.mHandler = new Handler(mHandlerThread.getLooper());
parentContext = context;
}
@Override
@ -91,7 +88,9 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
final Context context = getContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(this.getContext().getString(R.string.confirmation));
builder.setMessage(confirmMessage);
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@ -101,9 +100,9 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
mHandler.post(new Runnable() {
@Override
public void run() {
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints, parentContext);
PumpEnactResult result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints, context);
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
builder.setMessage(result.comment);
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);

View file

@ -258,7 +258,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
ArrayList<CharSequence> profileList;
profileList = profile.getProfileList();
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(parentContext,
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
android.R.layout.simple_spinner_item, profileList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
profileSpinner.setAdapter(adapter);

View file

@ -137,7 +137,7 @@ public class OverviewFragment extends Fragment {
@Override
public void onClick(View view) {
FragmentManager manager = getFragmentManager();
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog(getContext());
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
treatmentDialogFragment.show(manager, "TreatmentDialog");
}
});