Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit e29c50180eb0ac9760ae2657676bc3af402578ca
Author: Dustin Lam <dustinlam@google.com>
Date: Fri Jun 04 17:28:48 2021
Add onPagesUpdated presenter APIs
Currently the only way to react to presenter updates is via
loadStateFlow, but it de-dupes values if nothing has changed. This is
problematic in cachedIn cases where we immediately receive an initial
load with NotLoading state, and there is no way to listen to that new
generation getting applied in UI.
Test: ./gradlew paging:paging-common:test
Relnote: "Added onPagesPresented listener and flow presenter APIs
which trigger immediately after presented pages are updated in UI.
Since these updates are synchronous with UI, you may call adapter methods
such as .snapshot, .getItemCount, to inspect the state after the
update has been applied. Note that .snapshot() was left to be
explicitly called because it can be expensive to do on every update.
Page updates can happen in the following scenarios:
* Initial load of a new generation of PagingData completes,
regardless if the new generation contains any changes to the
presented items. i.e., A new generation completing initial load
with no updates because the list is exactly the same will still
trigger this callback.
* A page is inserted, even if the inserted page contains no new
items
* A page is dropped, even if the dropped page was empty"
Fixes: 189999634
Change-Id: I272c9a6b5d80f155dffcc05d5cda176d58c18d31
M paging/common/src/main/kotlin/androidx/paging/PagingDataDiffer.kt
M paging/common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
M paging/integration-tests/testapp/build.gradle
A paging/integration-tests/testapp/src/androidTest/kotlin/androidx/paging/integration/testapp/v3/OnPagesUpdatedTest.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3/V3Activity.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/1727555
Branch: androidx-main
commit e29c50180eb0ac9760ae2657676bc3af402578ca
Author: Dustin Lam <dustinlam@google.com>
Date: Fri Jun 04 17:28:48 2021
Add onPagesUpdated presenter APIs
Currently the only way to react to presenter updates is via
loadStateFlow, but it de-dupes values if nothing has changed. This is
problematic in cachedIn cases where we immediately receive an initial
load with NotLoading state, and there is no way to listen to that new
generation getting applied in UI.
Test: ./gradlew paging:paging-common:test
Relnote: "Added onPagesPresented listener and flow presenter APIs
which trigger immediately after presented pages are updated in UI.
Since these updates are synchronous with UI, you may call adapter methods
such as .snapshot, .getItemCount, to inspect the state after the
update has been applied. Note that .snapshot() was left to be
explicitly called because it can be expensive to do on every update.
Page updates can happen in the following scenarios:
* Initial load of a new generation of PagingData completes,
regardless if the new generation contains any changes to the
presented items. i.e., A new generation completing initial load
with no updates because the list is exactly the same will still
trigger this callback.
* A page is inserted, even if the inserted page contains no new
items
* A page is dropped, even if the dropped page was empty"
Fixes: 189999634
Change-Id: I272c9a6b5d80f155dffcc05d5cda176d58c18d31
M paging/common/src/main/kotlin/androidx/paging/PagingDataDiffer.kt
M paging/common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
M paging/integration-tests/testapp/build.gradle
A paging/integration-tests/testapp/src/androidTest/kotlin/androidx/paging/integration/testapp/v3/OnPagesUpdatedTest.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3/V3Activity.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
Useful in cases relying on cachedIn multicasting to transform the stream based on some external signal - this makes it difficult to listen for when the new transform of PagingData is applied.
We should consider adding a new API to listen to when submitData is applied, or prevent dedupe of loadStateListener /flow emissions when coming from a new instance of PagingData.