One-short guards for Fill/Prime dialog.
This commit is contained in:
parent
96fb4323f8
commit
ef6ee43c32
1 changed files with 44 additions and 25 deletions
|
@ -61,6 +61,10 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
private EditText notesEdit;
|
private EditText notesEdit;
|
||||||
|
|
||||||
|
//one shot guards
|
||||||
|
private boolean accepted;
|
||||||
|
private boolean okClicked;
|
||||||
|
|
||||||
final private TextWatcher textWatcher = new TextWatcher() {
|
final private TextWatcher textWatcher = new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
@ -163,7 +167,14 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmAndDeliver() {
|
private synchronized void confirmAndDeliver() {
|
||||||
|
if (okClicked) {
|
||||||
|
log.debug("guarding: ok already clicked");
|
||||||
|
dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
okClicked = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||||
|
|
||||||
|
@ -198,6 +209,13 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) {
|
if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) {
|
||||||
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage)));
|
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage)));
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.primefill), (dialog, id) -> {
|
builder.setPositiveButton(MainApp.gs(R.string.primefill), (dialog, id) -> {
|
||||||
|
synchronized (builder) {
|
||||||
|
if (accepted) {
|
||||||
|
log.debug("guarding: already accepted");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
accepted = true;
|
||||||
|
|
||||||
if (finalInsulinAfterConstraints > 0) {
|
if (finalInsulinAfterConstraints > 0) {
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||||
|
@ -224,6 +242,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now(), notes);
|
NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now(), notes);
|
||||||
if (insulinCartridgeChangeCheckbox.isChecked())
|
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||||
NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now() + 1000, notes);
|
NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now() + 1000, notes);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
builder.setMessage(MainApp.gs(R.string.no_action_selected));
|
builder.setMessage(MainApp.gs(R.string.no_action_selected));
|
||||||
|
|
Loading…
Reference in a new issue