check for null context in wizarddialog
This commit is contained in:
parent
65ea11d9a8
commit
9f9d348c11
|
@ -26,6 +26,8 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -51,6 +53,7 @@ import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
|
||||||
public class WizardDialog extends DialogFragment implements OnClickListener {
|
public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(WizardDialog.class);
|
||||||
|
|
||||||
Button wizardDialogDeliverButton;
|
Button wizardDialogDeliverButton;
|
||||||
TextView correctionInput;
|
TextView correctionInput;
|
||||||
|
@ -208,40 +211,44 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
if (parentContext != null) {
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||||
builder.setMessage(confirmMessage);
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setMessage(confirmMessage);
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final ConfigBuilderPlugin pump = MainApp.getConfigBuilder();
|
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||||
mHandler.post(new Runnable() {
|
final ConfigBuilderPlugin pump = MainApp.getConfigBuilder();
|
||||||
@Override
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
PumpEnactResult result = pump.deliverTreatmentFromBolusWizard(
|
public void run() {
|
||||||
parentContext,
|
PumpEnactResult result = pump.deliverTreatmentFromBolusWizard(
|
||||||
finalInsulinAfterConstraints,
|
parentContext,
|
||||||
finalCarbsAfterConstraints,
|
finalInsulinAfterConstraints,
|
||||||
SafeParse.stringToDouble(bgInput.getText().toString()),
|
finalCarbsAfterConstraints,
|
||||||
"Manual",
|
SafeParse.stringToDouble(bgInput.getText().toString()),
|
||||||
SafeParse.stringToInt(carbTimeEdit.getText().toString()),
|
"Manual",
|
||||||
boluscalcJSON
|
SafeParse.stringToInt(carbTimeEdit.getText().toString()),
|
||||||
);
|
boluscalcJSON
|
||||||
if (!result.success) {
|
);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
if (!result.success) {
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||||
builder.setMessage(result.comment);
|
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
builder.setMessage(result.comment);
|
||||||
builder.show();
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
builder.show();
|
||||||
builder.show();
|
dismiss();
|
||||||
dismiss();
|
} else {
|
||||||
|
log.error("parentContext == null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue