From 7e7ccfa9b5d92ae31ef69d5573fc0bd025a4259e Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 28 Dec 2018 08:15:58 +0000 Subject: [PATCH] Prevent crash --- .../eu/faircode/email/FragmentMessages.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index f2802f7c99..88049548fa 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -429,21 +429,22 @@ public class FragmentMessages extends FragmentEx { selectionTracker.addObserver(new SelectionTracker.SelectionObserver() { @Override public void onSelectionChanged() { - if (selectionTracker.hasSelection()) { - swipeRefresh.setEnabled(false); - if (messages != null) - messages.removeObservers(getViewLifecycleOwner()); - fabMore.show(); - } else { - predicate.clearAccount(); - fabMore.hide(); - try { + try { + if (selectionTracker.hasSelection()) { + swipeRefresh.setEnabled(false); + if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) + if (messages != null) + messages.removeObservers(getViewLifecycleOwner()); + fabMore.show(); + } else { + predicate.clearAccount(); + fabMore.hide(); if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) loadMessages(); - } catch (IllegalStateException ex) { - Log.w(ex); + swipeRefresh.setEnabled(true); } - swipeRefresh.setEnabled(true); + } catch (IllegalStateException ex) { + Log.w(ex); } } });