Prevent crash

pull/147/head
M66B 6 years ago
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…
Cancel
Save