mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-31 18:11:03 +01:00
Finished multiple select
This commit is contained in:
@@ -1,18 +1,35 @@
|
||||
package eu.faircode.email;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.paging.PagedList;
|
||||
import androidx.recyclerview.selection.SelectionTracker;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class SelectionPredicateMessage extends SelectionTracker.SelectionPredicate<Long> {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
SelectionPredicateMessage(RecyclerView recyclerView) {
|
||||
this.recyclerView = recyclerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetStateForKey(@NonNull Long key, boolean nextState) {
|
||||
return true;
|
||||
AdapterMessage adapter = (AdapterMessage) recyclerView.getAdapter();
|
||||
PagedList<TupleMessageEx> messages = adapter.getCurrentList();
|
||||
if (messages != null)
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
TupleMessageEx message = messages.get(i);
|
||||
if (message != null && message.id.equals(key))
|
||||
return (message.uid != null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetStateAtPosition(int position, boolean nextState) {
|
||||
return true;
|
||||
AdapterMessage adapter = (AdapterMessage) recyclerView.getAdapter();
|
||||
return (adapter.getCurrentList().get(position).uid != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user