From 9e62536d680c12a322c525ef03256d40ea79ddae Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 17 Feb 2016 16:23:28 +0100 Subject: [PATCH] Fix missing button clicks --- .../errors/FixableErrorFragment.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/errors/FixableErrorFragment.java b/app/src/main/java/org/solovyev/android/calculator/errors/FixableErrorFragment.java index 3b41cf6b..1de7becc 100644 --- a/app/src/main/java/org/solovyev/android/calculator/errors/FixableErrorFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/errors/FixableErrorFragment.java @@ -64,22 +64,28 @@ public class FixableErrorFragment extends BaseDialogFragment { @Override protected void onPrepareDialog(@NonNull AlertDialog.Builder builder) { builder.setMessage(error.message); - builder.setNeutralButton(R.string.cpp_dont_show_again, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - preferredPreferences.dontShowWarningDialog(); - dismiss(); - } - }); + builder.setNeutralButton(R.string.cpp_dont_show_again, null); builder.setNegativeButton(R.string.close, null); if (error.error != null) { - builder.setPositiveButton(R.string.fix, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - error.error.fix(preferredPreferences); - dismiss(); - } - }); + builder.setPositiveButton(R.string.fix, null); + } + } + + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case DialogInterface.BUTTON_NEUTRAL: + preferredPreferences.dontShowWarningDialog(); + dismiss(); + break; + case DialogInterface.BUTTON_POSITIVE: + assert error.error != null; + error.error.fix(preferredPreferences); + dismiss(); + break; + default: + super.onClick(dialog, which); + break; } }