From 7d53bf3d809da8b8013f45fbf4726067430388a7 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 30 Sep 2021 07:24:59 +0200 Subject: [PATCH] Prevent crash --- .../main/java/eu/faircode/email/FragmentMessages.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index de7f7a0b71..14efc142ef 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -1415,7 +1415,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. selectionTracker.addObserver(new SelectionTracker.SelectionObserver() { @Override public void onSelectionChanged() { - if (!getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return; FragmentActivity activity = getActivity(); @@ -1427,7 +1427,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. @Override public void onItemStateChanged(@NonNull Long key, boolean selected) { - if (!getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return; int pos = adapter.getPositionForKey(key); @@ -1473,6 +1473,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. @Override public boolean isInAbsoluteEnd() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return false; + PagedList list = ((AdapterMessage) rvMessage.getAdapter()).getCurrentList(); if (list == null) return false; @@ -5271,9 +5274,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Context context = getContext(); if (context == null) return; - if (getView() == null) - return; - if (!getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);