From 4c57d7f744e7f5b4ae3227b32170febd2deab8bf Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 11 Sep 2019 19:32:17 +0200 Subject: [PATCH] Check send at result code --- .../eu/faircode/email/FragmentCompose.java | 48 +++++++++---------- .../eu/faircode/email/FragmentDialogEx.java | 9 ++++ 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index b5ae846f38..f3efb36e53 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -3685,36 +3685,34 @@ public class FragmentCompose extends FragmentBase { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent intent) { super.onActivityResult(requestCode, resultCode, intent); - Context context = getContext(); - if (context == null) - return; + if (resultCode == RESULT_OK && intent != null) { + Bundle data = intent.getBundleExtra("args"); + long id = data.getLong("id"); + long duration = data.getLong("duration"); + long time = data.getLong("time"); - Bundle data = intent.getBundleExtra("args"); - long id = data.getLong("id"); - long duration = data.getLong("duration"); - long time = data.getLong("time"); - - Bundle args = new Bundle(); - args.putLong("id", id); - args.putLong("wakeup", duration == 0 ? -1 : time); + Bundle args = new Bundle(); + args.putLong("id", id); + args.putLong("wakeup", duration == 0 ? -1 : time); - new SimpleTask() { - @Override - protected Void onExecute(Context context, Bundle args) { - long id = args.getLong("id"); - Long wakeup = args.getLong("wakeup"); + new SimpleTask() { + @Override + protected Void onExecute(Context context, Bundle args) { + long id = args.getLong("id"); + Long wakeup = args.getLong("wakeup"); - DB db = DB.getInstance(context); - db.message().setMessageSnoozed(id, wakeup < 0 ? null : wakeup); + DB db = DB.getInstance(context); + db.message().setMessageSnoozed(id, wakeup < 0 ? null : wakeup); - return null; - } + return null; + } - @Override - protected void onException(Bundle args, Throwable ex) { - Helper.unexpectedError(getFragmentManager(), ex); - } - }.execute(this, args, "compose:snooze"); + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(getFragmentManager(), ex); + } + }.execute(this, args, "compose:snooze"); + } } } diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogEx.java b/app/src/main/java/eu/faircode/email/FragmentDialogEx.java index 41427b1097..8a3c1f6267 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogEx.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogEx.java @@ -76,6 +76,15 @@ public class FragmentDialogEx extends DialogFragment { Log.i("Stop " + this); } + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + Log.i("Result class=" + this.getClass().getSimpleName() + + " request=" + requestCode + " result=" + resultCode); + Log.logExtras(data); + super.onActivityResult(requestCode, resultCode, data); + + } + @NonNull @Override public LifecycleOwner getViewLifecycleOwner() {