mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-24 01:43:42 +02:00
Updated recyclerview selection to versio 1.1.0-alpha02
This commit is contained in:
@@ -21,10 +21,12 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.collection.LongSparseArray;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An {@link ItemKeyProvider} that provides stable ids by way of cached
|
||||
* {@link RecyclerView.Adapter} stable ids. Items enter the cache as they are laid out by
|
||||
@@ -38,7 +40,7 @@ import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListene
|
||||
public final class StableIdKeyProvider extends ItemKeyProvider<Long> {
|
||||
|
||||
private final SparseArray<Long> mPositionToKey = new SparseArray<>();
|
||||
private final LongSparseArray<Integer> mKeyToPosition = new LongSparseArray<>();
|
||||
private final Map<Long, Integer> mKeyToPosition = new HashMap<Long, Integer>();
|
||||
private final RecyclerView mRecyclerView;
|
||||
|
||||
/**
|
||||
@@ -100,6 +102,9 @@ public final class StableIdKeyProvider extends ItemKeyProvider<Long> {
|
||||
|
||||
@Override
|
||||
public int getPosition(@NonNull Long key) {
|
||||
return mKeyToPosition.get(key, RecyclerView.NO_POSITION);
|
||||
if (mKeyToPosition.containsKey(key)) {
|
||||
return mKeyToPosition.get(key);
|
||||
}
|
||||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user