Updated selection tracker to version 1.1.0-alpha01

This commit is contained in:
M66B
2019-02-12 12:50:23 +00:00
parent 57f8dc1b0e
commit ab814ae495
7 changed files with 46 additions and 32 deletions

View File

@@ -21,12 +21,10 @@ 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
@@ -40,7 +38,7 @@ import java.util.Map;
public final class StableIdKeyProvider extends ItemKeyProvider<Long> {
private final SparseArray<Long> mPositionToKey = new SparseArray<>();
private final Map<Long, Integer> mKeyToPosition = new HashMap<Long, Integer>();
private final LongSparseArray<Integer> mKeyToPosition = new LongSparseArray<>();
private final RecyclerView mRecyclerView;
/**
@@ -102,9 +100,6 @@ public final class StableIdKeyProvider extends ItemKeyProvider<Long> {
@Override
public int getPosition(@NonNull Long key) {
if (mKeyToPosition.containsKey(key)) {
return mKeyToPosition.get(key);
}
return RecyclerView.NO_POSITION;
return mKeyToPosition.get(key, RecyclerView.NO_POSITION);
}
}