mirror of https://github.com/M66B/FairEmail.git
Prevent crash
This commit is contained in:
parent
51f49c9c22
commit
05f62b4cae
|
@ -449,13 +449,17 @@ public class FragmentMessages extends FragmentEx {
|
|||
public void onSelectionChanged() {
|
||||
// Workaround AndroidX bug
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
ViewModelMessages modelMessages = ViewModelProviders.of(activity).get(ViewModelMessages.class);
|
||||
if (selectionTracker.hasSelection())
|
||||
modelMessages.removeObservers(viewType, getViewLifecycleOwner());
|
||||
else
|
||||
modelMessages.observe(viewType, getViewLifecycleOwner(), observer);
|
||||
}
|
||||
if (activity != null)
|
||||
try {
|
||||
ViewModelMessages modelMessages = ViewModelProviders.of(activity).get(ViewModelMessages.class);
|
||||
if (selectionTracker.hasSelection())
|
||||
modelMessages.removeObservers(viewType, getViewLifecycleOwner());
|
||||
else
|
||||
modelMessages.observe(viewType, getViewLifecycleOwner(), observer);
|
||||
} catch (IllegalStateException ex) {
|
||||
// getViewLifecycleOwner
|
||||
Log.w(ex);
|
||||
}
|
||||
|
||||
if (selectionTracker.hasSelection()) {
|
||||
swipeRefresh.setEnabled(false);
|
||||
|
|
Loading…
Reference in New Issue