I'm trying to use Selection ( https://developer.android.com/reference/androidx/recyclerview/selection/package-summary ) with the new paging library ( so paging 3 )
With Paging 2 that was doable because we were using PagedListAdapter and that was working will with the Selection library but now with the new PagingDataAdapter I can't make it work anymore.
https://developer.android.com/reference/kotlin/androidx/paging/PagingDataAdapter
We are losing getCurrentList(), setHasStableIds() will now return UnsupportedOperationException.
So if anyone have it woring I would greatly appreciate some help on this.
In the new Paging3 library, you can get the currentlist with the snapShot() method of the PagingDataAdapter class.
I recently had the same key provider problem so I implemented a custom one like so:
class MyItemKeyProvider(private val adapter: MyPagingAdapter) :
ItemKeyProvider<String>(SCOPE_CACHED) {
override fun getKey(position: Int): String = adapter.snapshot().items[position].id
override fun getPosition(key: String): Int = adapter.snapshot().items.indexOfFirst { it.id == key }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With