Fixed
Status Update
Comments
an...@google.com <an...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 71af8f6a01a88a1f2c961d7054a787c3983f879b
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Wed Jun 09 15:21:14 2021
Refactor LazyPagingItems to work similarly to mutableStateListOf()
The idea of keeping state objects for only visible items doesn't seems to work nicely, especially when we try to add keys() support as in order to be notified when the key of the item on the given position changes this should also be backed by the state and the key callback is not a composable function.
Instead we should try to not create new concepts only for paging and try to work with Lazy lists similarly to how it works with just regular lists. Namely we can borrow the idea from mutableStateListOf() where it is essentially a snapshot based mutable state of the immutable lists. We can follow the same pattern if on every update from the datasource we will update our state with the new snapshot list. And as a result of this change all the usages will be re-executed.
Some follow up changes will be required on PagingDataDiffer side in order to make it work more efficient as there is currently no single callback when the differ handling finished.
Relnote: Function lazyPagingItems.getAsState(index) is now deprecated. Use lazyPagingItems[index] instead.
Test: run LazyPagingItemsTest
Bug: 187339372
Change-Id: I086cbb113a0c4ddcc333c78fa1346612e4496a5b
M paging/paging-compose/api/current.txt
M paging/paging-compose/api/public_plus_experimental_current.txt
M paging/paging-compose/api/restricted_current.txt
M paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
https://android-review.googlesource.com/1749960
Branch: androidx-main
commit 71af8f6a01a88a1f2c961d7054a787c3983f879b
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Wed Jun 09 15:21:14 2021
Refactor LazyPagingItems to work similarly to mutableStateListOf()
The idea of keeping state objects for only visible items doesn't seems to work nicely, especially when we try to add keys() support as in order to be notified when the key of the item on the given position changes this should also be backed by the state and the key callback is not a composable function.
Instead we should try to not create new concepts only for paging and try to work with Lazy lists similarly to how it works with just regular lists. Namely we can borrow the idea from mutableStateListOf() where it is essentially a snapshot based mutable state of the immutable lists. We can follow the same pattern if on every update from the datasource we will update our state with the new snapshot list. And as a result of this change all the usages will be re-executed.
Some follow up changes will be required on PagingDataDiffer side in order to make it work more efficient as there is currently no single callback when the differ handling finished.
Relnote: Function lazyPagingItems.getAsState(index) is now deprecated. Use lazyPagingItems[index] instead.
Test: run LazyPagingItemsTest
Bug: 187339372
Change-Id: I086cbb113a0c4ddcc333c78fa1346612e4496a5b
M paging/paging-compose/api/current.txt
M paging/paging-compose/api/public_plus_experimental_current.txt
M paging/paging-compose/api/restricted_current.txt
M paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
Description
Component used:Paging-Compose Version 1.0.0-alpha08
It would be nice to have item-keys support for LazyColumn