mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-29 09:01:30 +01:00
Disable multiple select on swiping
This commit is contained in:
@@ -24,14 +24,23 @@ import androidx.recyclerview.selection.SelectionTracker;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class SelectionPredicateMessage extends SelectionTracker.SelectionPredicate<Long> {
|
||||
private boolean enabled;
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
SelectionPredicateMessage(RecyclerView recyclerView) {
|
||||
this.enabled = true;
|
||||
this.recyclerView = recyclerView;
|
||||
}
|
||||
|
||||
void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetStateForKey(@NonNull Long key, boolean nextState) {
|
||||
if (!enabled)
|
||||
return false;
|
||||
|
||||
AdapterMessage adapter = (AdapterMessage) recyclerView.getAdapter();
|
||||
TupleMessageEx message = adapter.getItemForKey(key);
|
||||
|
||||
@@ -43,6 +52,9 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica
|
||||
|
||||
@Override
|
||||
public boolean canSetStateAtPosition(int position, boolean nextState) {
|
||||
if (!enabled)
|
||||
return false;
|
||||
|
||||
AdapterMessage adapter = (AdapterMessage) recyclerView.getAdapter();
|
||||
TupleMessageEx message = adapter.getItemAtPosition(position);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user