Don't show confirmation on empty message/input

This commit is contained in:
Roumen Georgiev 2018-03-01 16:57:36 +02:00 committed by GitHub
parent 38933ac323
commit bea486d816
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -278,6 +278,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
if (!initialEventTime.equals(eventTime)) {
confirmMessage += "<br/> Time: " + DateUtil.dateAndTimeString(eventTime);
}
if(confirmMessage.length() > 0) {
final int finalCarbsAfterConstraints = carbsAfterConstraints;
@ -287,6 +288,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
builder.setTitle(this.getContext().getString(R.string.confirmation));
if (confirmMessage.startsWith("<br/>"))
confirmMessage = confirmMessage.substring("<br/>".length());
builder.setMessage(Html.fromHtml(confirmMessage));
builder.setPositiveButton(getString(R.string.ok), (dialog, id) -> {
synchronized (builder) {
@ -344,9 +346,12 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
builder.setNegativeButton(getString(R.string.cancel), null);
builder.show();
dismiss();
} else
dismiss();
} catch (Exception e) {
log.error("Unhandled exception", e);
}
}
@Override