From 1f1332a169058fab23c5106e9bee7bfdf3506608 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 17 Jan 2019 19:22:16 +0000 Subject: [PATCH] Small improvement --- .../eu/faircode/email/FragmentAnswer.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAnswer.java b/app/src/main/java/eu/faircode/email/FragmentAnswer.java index af687b6bb3..027a4e8459 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAnswer.java +++ b/app/src/main/java/eu/faircode/email/FragmentAnswer.java @@ -136,12 +136,20 @@ public class FragmentAnswer extends FragmentBase { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Helper.setViewsEnabled(view, false); - Bundle args = new Bundle(); args.putLong("id", id); new SimpleTask() { + @Override + protected void onPreExecute(Bundle args) { + Helper.setViewsEnabled(view, false); + } + + @Override + protected void onPostExecute(Bundle args) { + Helper.setViewsEnabled(view, true); + } + @Override protected Void onExecute(Context context, Bundle args) { long id = args.getLong("id"); @@ -156,7 +164,6 @@ public class FragmentAnswer extends FragmentBase { @Override protected void onException(Bundle args, Throwable ex) { - Helper.setViewsEnabled(view, true); Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex); } }.execute(FragmentAnswer.this, args, "answer:delete"); @@ -167,14 +174,22 @@ public class FragmentAnswer extends FragmentBase { } private void onActionSave() { - Helper.setViewsEnabled(view, false); - Bundle args = new Bundle(); args.putLong("id", id); args.putString("name", etName.getText().toString()); args.putString("text", Html.toHtml(etText.getText())); new SimpleTask() { + @Override + protected void onPreExecute(Bundle args) { + Helper.setViewsEnabled(view, false); + } + + @Override + protected void onPostExecute(Bundle args) { + Helper.setViewsEnabled(view, true); + } + @Override protected Void onExecute(Context context, Bundle args) { long id = args.getLong("id"); @@ -204,7 +219,6 @@ public class FragmentAnswer extends FragmentBase { @Override protected void onException(Bundle args, Throwable ex) { - Helper.setViewsEnabled(view, true); Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex); } }.execute(this, args, "answer:save");