Another ugly workaround

This commit is contained in:
M66B 2019-02-04 19:39:24 +00:00
parent 4f25de33f0
commit a5bc07c4c3
2 changed files with 10 additions and 2 deletions

View File

@ -441,7 +441,7 @@ public class FragmentMessages extends FragmentBase {
@Override
public void onSelectionChanged() {
SelectionTracker tracker = selectionTracker;
if (tracker == null)
if (tracker == null) // destroyed
return;
FragmentActivity activity = getActivity();
@ -476,6 +476,8 @@ public class FragmentMessages extends FragmentBase {
@Override
public void onDestroy() {
if (selectionPredicate != null)
selectionPredicate.destroy();
selectionTracker = null;
super.onDestroy();
}

View File

@ -25,10 +25,12 @@ import androidx.recyclerview.widget.RecyclerView;
public class SelectionPredicateMessage extends SelectionTracker.SelectionPredicate<Long> {
private boolean enabled;
private boolean destroyed;
private RecyclerView recyclerView;
SelectionPredicateMessage(RecyclerView recyclerView) {
this.enabled = true;
this.destroyed = false;
this.recyclerView = recyclerView;
}
@ -36,6 +38,10 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
this.enabled = enabled;
}
void destroy() {
this.destroyed = true;
}
@Override
public boolean canSetStateForKey(@NonNull Long key, boolean nextState) {
if (!enabled)
@ -66,6 +72,6 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
@Override
public boolean canSelectMultiple() {
return true;
return !destroyed;
}
}