Fixed
Status Update
Comments
du...@google.com <du...@google.com> #2
Thanks for filing this, we should definitely expose some easier ways to access the loaded items without triggering page fetches due to prefetchDistance
.
du...@google.com <du...@google.com> #3
To note - a simply way to support this use-case might be to allow retrieving snapshots of loaded or presented data.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 4d7ed3eb5b271cd235deec3f30466f6dcc4e7286
Author: Dustin Lam <dustinlam@google.com>
Date: Thu Jul 23 15:03:09 2020
Add a peek() method which doesn't trigger page fetch
Allowing users to access presented data with triggering page fetch.
RelNote: "Explicit peek() methods added to AsyncPagingDataDiffer and
PagingDataAdapter to allow presented data access without trigger page
loads."
Bug: 159104197
Test: ./gradlew paging:paging-common:test
Change-Id: I388982364c55ffd87a2f515dffdada817eceaec0
M paging/common/src/main/kotlin/androidx/paging/PagingDataDiffer.kt
M paging/common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
M paging/runtime/api/current.txt
M paging/runtime/api/public_plus_experimental_current.txt
M paging/runtime/api/restricted_current.txt
M paging/runtime/src/main/java/androidx/paging/AsyncPagingDataDiffer.kt
M paging/runtime/src/main/java/androidx/paging/PagingDataAdapter.kt
https://android-review.googlesource.com/1371246
Branch: androidx-master-dev
commit 4d7ed3eb5b271cd235deec3f30466f6dcc4e7286
Author: Dustin Lam <dustinlam@google.com>
Date: Thu Jul 23 15:03:09 2020
Add a peek() method which doesn't trigger page fetch
Allowing users to access presented data with triggering page fetch.
RelNote: "Explicit peek() methods added to AsyncPagingDataDiffer and
PagingDataAdapter to allow presented data access without trigger page
loads."
Bug: 159104197
Test: ./gradlew paging:paging-common:test
Change-Id: I388982364c55ffd87a2f515dffdada817eceaec0
M paging/common/src/main/kotlin/androidx/paging/PagingDataDiffer.kt
M paging/common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
M paging/runtime/api/current.txt
M paging/runtime/api/public_plus_experimental_current.txt
M paging/runtime/api/restricted_current.txt
M paging/runtime/src/main/java/androidx/paging/AsyncPagingDataDiffer.kt
M paging/runtime/src/main/java/androidx/paging/PagingDataAdapter.kt
Description
Version used: 3.0.0-alpha01
I'm trying to replace my old PagedListAdapters with the new PagingDataAdapter.
Using the RecyclerView selection tracker library I need to implement an ItemKeyProvider which has two methods :
getKey(position: Int) and getPosition(key: String).
For the first one I can retrieve the key by calling adapter.getItem(position) but for the second one the PagingDataAdapter doesn't expose the list of items or any method to get the position of an item (like adapter.getposition(item)).
With the PagedListAdapter I was exposing the list by overriding submitList() and making a copy of the list (I don't know if it was a good solution though) but I can't do it with the new adapter as the submitData method is not open.
Is there already a solution that I don't know about or should the PagingDataAdapter exposing a method?