Status Update
Comments
ae...@google.com <ae...@google.com>
an...@google.com <an...@google.com>
du...@google.com <du...@google.com> #2
With paging2 and the PagedListAdapter, I was simply checking if the list was empty before sending it to the adapter so I wasn't handle it with the adapter (which is probably wrong).
I tried to migrate to paging3 but I couldn't because I don't know how to check if the list is empty, as the PagingData that we send to the new adapter doesn't expose the list or an isEmpty method.
ri...@gmail.com <ri...@gmail.com> #3
Thanks for this, this is something we are definitely interested in! As a workaround, you can check adapter.itemCount
.
ri...@gmail.com <ri...@gmail.com> #4
We have a sample snippet showing how to use adapter.itemCount
in this way, but forgot to link it in KDocs (whoops):
Will fix.
an...@google.com <an...@google.com> #5
To be clear, adapter.itemCount
will only work if placeholdersEnabled
is false
.
We held off on this change because we wanted to take some time to properly explore what it would look like to provide a public API to view the PagingState or the internal PageEvent stream, but it's clear there's immediate need for this.
In the meantime, here's an idea for a CL which adds a Boolean
to dataRefreshFlow
, which we could merge for alpha02:
ri...@gmail.com <ri...@gmail.com> #6
Branch: androidx-master-dev
commit 0deeb4e05177350b8c2b444e6db418b9fc7aa66b
Author: Chris Craik <ccraik@google.com>
Date: Tue Jun 16 08:26:09 2020
Actually link addLoadStateListenerSample in kdocs
Bug: 159054196
Test: Ctrl-Q in Studio
Change-Id: Ieabb25de3625a22f8107f1192af54e986a50d1d3
M paging/runtime/src/main/java/androidx/paging/PagingDataAdapter.kt
an...@gmail.com <an...@gmail.com> #7
Branch: androidx-master-dev
commit 38a9eb05e73e822f70348aa22264b36e6790dba8
Author: Dustin Lam <dustinlam@google.com>
Date: Tue Jun 16 09:24:15 2020
Add isEmpty param to dataRefreshFlow / listener
RelNote: "The adapter APIs, dataRefreshFlow and dataRefreshListener
now pass a Boolean to signal whether a PagingData is empty"
Fixes: 159054196
Test: ./gradlew paging:paging-runtime:cC
Change-Id: I6e37e844cf9f947aeefaaa99d22b2672e04f207d
M paging/common/src/main/kotlin/androidx/paging/PagingDataDiffer.kt
M paging/common/src/test/kotlin/androidx/paging/PagingDataDifferTest.kt
M paging/runtime/api/3.0.0-alpha02.txt
M paging/runtime/api/current.txt
M paging/runtime/api/public_plus_experimental_3.0.0-alpha02.txt
M paging/runtime/api/public_plus_experimental_current.txt
M paging/runtime/api/restricted_3.0.0-alpha02.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
de...@gmail.com <de...@gmail.com> #8
to...@gmail.com <to...@gmail.com> #9
Workaround is to create another Compose function which takes regular List<T> instead of LazyPagingItems<T> for previewing purposes.
ke...@gmail.com <ke...@gmail.com> #10
ja...@gmail.com <ja...@gmail.com> #11
ma...@migrosonline.ch <ma...@migrosonline.ch> #12
be...@swile.co <be...@swile.co> #13
be...@swile.co <be...@swile.co> #14
(I'm on Chipmunk Beta 2)
th...@palringo.com <th...@palringo.com> #15
da...@gmail.com <da...@gmail.com> #16
With compose 1.2.0-beta01, constructing a static LazyPagingItems like this works for me in interactive preview.
val ordersFlow = flowOf(PagingData.from(orders))
val pagingItems = ordersFlow.collectAsLazyPagingItems()
However, the static preview will only show an empty list of items.
wo...@gmail.com <wo...@gmail.com> #17
I still cannot preview the list. Interactive preview doesn't show it as well.
du...@google.com <du...@google.com> #18
Preview doesn't work in paging-compose at the moment with PagingData
because it has to wait for some work to be done before any items show up, so the first frame is always empty as mentioned in #5. However, it's worth investigating if we can get it to work with static PagingData
like PagingData.from
ai...@googlemail.com <ai...@googlemail.com> #19
ro...@cloudkitchens.com <ro...@cloudkitchens.com> #20
ki...@gmail.com <ki...@gmail.com> #21
+1 our snapshot tests became useless after moving from unpaged lists to paged lists, would be really nice to have a preview functionality so our snapshot tests can keep working
lu...@gmail.com <lu...@gmail.com> #22
Please reopen.
ki...@gmail.com <ki...@gmail.com> #23
Would be great to reopen this or give a reason why it won't be fixed. Seems like an important functionality since like it currently stands we cannot cover paged lists with paparazzi snapshot tests.
cl...@google.com <cl...@google.com> #24
Reopening as it's something we would want for paging-compose.
Paging currently can't support this because as
[Deleted User] <[Deleted User]> #25
[Deleted User] <[Deleted User]> #26
di...@gmail.com <di...@gmail.com> #27
cl...@google.com <cl...@google.com> #28
We are planning to include preview support as part of stable paging-compose.
ri...@gmail.com <ri...@gmail.com> #29
Any dates/timelines?
cl...@google.com <cl...@google.com> #30
Currently planned for Q2/Q3.
ap...@google.com <ap...@google.com> #31
Branch: androidx-main
commit 15fa26db22d9a0d2e00cb3847620bc6ae08561fc
Author: Clara Fok <clarafok@google.com>
Date: Mon May 01 16:53:10 2023
Add support for Paging preview in compose
Paging Compose now supports previewing a list of fake data by creating a PagingData.from(fakeData) and passing the PagingData to a MutableStateFlow. Call the MutableStateFlow<PagingData<Value>>.collectAsLazyPagingItems() to preview.
Test: ./gradlew paging:paging-compose:cC
Test: preview sample in PagingPreviewSample
Bug: 194544557
Relnote: "Paging Compose now supports previewing a list of fake data by creating a PagingData.from(fakeData) and passing the PagingData to a MutableStateFlow. Call the MutableStateFlow<PagingData<Value>>.collectAsLazyPagingItems() to get previewable LazyPagingItems."
Change-Id: I8a78db059776190b833773986825579e96e042d5
M paging/paging-common/src/main/kotlin/androidx/paging/PagingData.kt
M paging/paging-compose/build.gradle
M paging/paging-compose/samples/build.gradle
A paging/paging-compose/samples/src/main/java/androidx/paging/compose/samples/PagingPreviewSample.kt
A paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsPreviewTest.kt
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
cl...@google.com <cl...@google.com> #32
Fixed internally and will be available in the next Paging release. This bug will be updated with release version at the time.
k....@rebuy.com <k....@rebuy.com> #33
Is it already in 1.0.0-alpha19
? If yes, then could I get an example of how to use it?
cl...@google.com <cl...@google.com> #34
It will be available in the upcoming release on May 24th as paging-compose 1.0.0-alpha20
.
The change does include an example on how to set up
The example has DisplayPaging()
composable inlined within PagingPreview()
composable. This is ONLY FOR sample purposes because of how the @Preview
annotation is rendered in documents. In production code DisplayPaging()
should be its own separate, top-level declaration.
ju...@google.com <ju...@google.com> #35
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.paging:paging-common:3.2.0-alpha06
androidx.paging:paging-compose:1.0.0-alpha20
no...@gmail.com <no...@gmail.com> #36
One important point – inside @Preview
, you should use MutableStateFlow()
rather than builders like flowOf()
– the latter simply doesn’t work
Description
Jetpack Compose release version:1.0.0-rc02
Android Studio Build:Android Studio Bumblebee | 2021.1.1 Canary 4
Kotlin version:1.5.10
I think the title says it all.
LazyPagingItems
constructor is internal. I can't passLazyPagingItems
as parameter in Preview Composable, let alone passing sample data. But I want to show preview of my composable, how should I do this?