From a52bc5f5e4ae22b39cbcfd9706e7d32d2c2cdac8 Mon Sep 17 00:00:00 2001 From: serso Date: Sat, 30 Jan 2016 21:14:08 +0100 Subject: [PATCH] firstTime argument in onShowDialog method --- .../android/calculator/BaseDialogFragment.java | 6 +++--- .../calculator/functions/EditFunctionFragment.java | 10 ++++++---- .../calculator/variables/EditVariableFragment.java | 10 ++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java b/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java index 89ebbb3e..9651553b 100644 --- a/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/BaseDialogFragment.java @@ -34,7 +34,7 @@ public abstract class BaseDialogFragment extends DialogFragment { @NonNull @Override - public AlertDialog onCreateDialog(Bundle savedInstanceState) { + public AlertDialog onCreateDialog(@Nullable final Bundle savedInstanceState) { final Preferences.Gui.Theme theme = Preferences.Gui.getTheme(preferences); final Context context = getActivity(); final LayoutInflater inflater = LayoutInflater.from(context); @@ -47,13 +47,13 @@ public abstract class BaseDialogFragment extends DialogFragment { dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface d) { - onShowDialog(dialog); + onShowDialog(dialog, savedInstanceState == null); } }); return dialog; } - protected void onShowDialog(@NonNull AlertDialog dialog) { + protected void onShowDialog(@NonNull AlertDialog dialog, boolean firstTime) { } protected abstract void onPrepareDialog(@NonNull AlertDialog.Builder builder); diff --git a/app/src/main/java/org/solovyev/android/calculator/functions/EditFunctionFragment.java b/app/src/main/java/org/solovyev/android/calculator/functions/EditFunctionFragment.java index 0c32a7a3..0b69d032 100644 --- a/app/src/main/java/org/solovyev/android/calculator/functions/EditFunctionFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/functions/EditFunctionFragment.java @@ -157,11 +157,13 @@ public class EditFunctionFragment extends BaseDialogFragment implements View.OnC } @Override - protected void onShowDialog(@NonNull AlertDialog dialog) { - super.onShowDialog(dialog); + protected void onShowDialog(@NonNull AlertDialog dialog, boolean firstTime) { + super.onShowDialog(dialog, firstTime); - nameView.selectAll(); - showIme(nameView); + if (firstTime) { + nameView.selectAll(); + showIme(nameView); + } final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE); ok.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/org/solovyev/android/calculator/variables/EditVariableFragment.java b/app/src/main/java/org/solovyev/android/calculator/variables/EditVariableFragment.java index 932ffd44..6be531fc 100644 --- a/app/src/main/java/org/solovyev/android/calculator/variables/EditVariableFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/variables/EditVariableFragment.java @@ -167,11 +167,13 @@ public class EditVariableFragment extends BaseDialogFragment implements Calculat @Override - protected void onShowDialog(@NonNull AlertDialog dialog) { - super.onShowDialog(dialog); + protected void onShowDialog(@NonNull AlertDialog dialog, boolean firstTime) { + super.onShowDialog(dialog, firstTime); - nameView.selectAll(); - showIme(nameView); + if (firstTime) { + nameView.selectAll(); + showIme(nameView); + } final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE); ok.setOnClickListener(new View.OnClickListener() {