mirror of https://github.com/M66B/FairEmail.git
parent
2f28bf9f55
commit
6b8222f3c5
Binary file not shown.
@ -0,0 +1,38 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import androidx.appcompat.view.ActionMode;
|
||||||
|
import androidx.recyclerview.selection.SelectionTracker;
|
||||||
|
|
||||||
|
public class MyActionModeController implements ActionMode.Callback {
|
||||||
|
private final Context context;
|
||||||
|
private final SelectionTracker selectionTracker;
|
||||||
|
|
||||||
|
public MyActionModeController(Context context, SelectionTracker selectionTracker) {
|
||||||
|
this.context = context;
|
||||||
|
this.selectionTracker = selectionTracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyActionMode(ActionMode actionMode) {
|
||||||
|
selectionTracker.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.selection.ItemDetailsLookup;
|
||||||
|
|
||||||
|
public class MyItemDetail extends ItemDetailsLookup.ItemDetails<Long> {
|
||||||
|
private final int adapterPosition;
|
||||||
|
private final Long selectionKey;
|
||||||
|
|
||||||
|
public MyItemDetail(int adapterPosition, Long selectionKey) {
|
||||||
|
Log.i(Helper.TAG, "MyItemDetail");
|
||||||
|
this.adapterPosition = adapterPosition;
|
||||||
|
this.selectionKey = selectionKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPosition() {
|
||||||
|
Log.i(Helper.TAG, "MyItemDetail.getPosition=" + adapterPosition);
|
||||||
|
return adapterPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Long getSelectionKey() {
|
||||||
|
Log.i(Helper.TAG, "MyItemDetail.getSelectionKey=" + selectionKey);
|
||||||
|
return selectionKey;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.paging.PagedList;
|
||||||
|
import androidx.recyclerview.selection.ItemKeyProvider;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
public class MyItemKeyProvider extends ItemKeyProvider<Long> {
|
||||||
|
private final PagedList<TupleMessageEx> messages;
|
||||||
|
|
||||||
|
public MyItemKeyProvider(PagedList<TupleMessageEx> messages) {
|
||||||
|
super(ItemKeyProvider.SCOPE_MAPPED);
|
||||||
|
this.messages = messages;
|
||||||
|
Log.i(Helper.TAG, "MyItemKeyProvider");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Long getKey(int position) {
|
||||||
|
Log.i(Helper.TAG, "MyItemKeyProvider.getKey pos=" + position + " key=" + messages.get(position).id);
|
||||||
|
return messages.get(position).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPosition(@NonNull Long key) {
|
||||||
|
Log.i(Helper.TAG, "MyItemKeyProvider.getPosition key=" + key);
|
||||||
|
int pos = RecyclerView.NO_POSITION;
|
||||||
|
for (int i = 0; i < messages.size(); i++)
|
||||||
|
if (messages.get(i).id.equals(key))
|
||||||
|
pos = i;
|
||||||
|
Log.i(Helper.TAG, "MyItemKeyProvider.getPosition key=" + key + " pos=" + pos);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.selection.ItemDetailsLookup;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
public class MyItemLookup extends ItemDetailsLookup<Long> {
|
||||||
|
|
||||||
|
private final RecyclerView recyclerView;
|
||||||
|
|
||||||
|
public MyItemLookup(RecyclerView recyclerView) {
|
||||||
|
Log.i(Helper.TAG, "MyItemLookup");
|
||||||
|
this.recyclerView = recyclerView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public ItemDetails<Long> getItemDetails(@NonNull MotionEvent e) {
|
||||||
|
Log.i(Helper.TAG, "MyItemLookup.getItemDetails");
|
||||||
|
View view = recyclerView.findChildViewUnder(e.getX(), e.getY());
|
||||||
|
if (view != null) {
|
||||||
|
RecyclerView.ViewHolder viewHolder = recyclerView.getChildViewHolder(view);
|
||||||
|
if (viewHolder instanceof AdapterMessage.ViewHolder) {
|
||||||
|
return ((AdapterMessage.ViewHolder) viewHolder).getItemDetails();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue