Status Update
Comments
cl...@google.com <cl...@google.com> #2
Hello, can you please attach a sample that reproduces your error?
ya...@gmail.com <ya...@gmail.com> #3
I’ve attached two screen recordings demonstrating the mediator's behavior during the first and second launches after installation. Additionally,
cl...@google.com <cl...@google.com> #4
Based on first_launch_after_installation.mp4
, your paging state is indeed showing null
for nextKey, so it makes sense that Paging concluded there are no more items to load.
So I think the question is why the PagingState
contains only an empty page and null
values. My guess is either
- RemoteMediator REFRESH actually returned empty data - what is the returned
allNewsItems
value on initial REFRESH? - RemoteMediator REFRESH successfully loaded data and inserted it into database, but Paging hasn't processed that yet by the time Append is triggered, so PagingState is empty.
The second case doesn't seem likely though.
If you attach an executable app, I can look into this further.
Otherwise, you may gain more insight through Paging logs with adb shell setprop log.tag.Paging VERBOSE
. You can also try implementing RemoteKeys
in this
ev...@tatarka.me <ev...@tatarka.me> #5
Hey! I ran into this same issue. It is in fact the second case you mentioned and is documented
I've published a repo
Description
The Paging 3 library (v3.3.4) have unexpected behavior when the app is run for the first time after installation. According to the official documentation , inside
LoadtType.APPEND
block ofload()
method:Based on this, I used the following logic:
Problem:
This logic works as intended in all cases except during the app's first run after installation, it only loads a single page (triggered by
LoadType.REFRESH
) and incorrectly concludes that there are no more items to load becausestate.lastItemOrNull()
returnnull
(PagingState
: first_launch_first_append.png). This results in the app failing to load subsequent pages of data.Once the app is restarted or the user manually refreshes the page, the behavior works as expected (PagingState: nth_launch_first_append.png)
Steps to Reproduce:
LoadType.REFRESH
is triggered.Expected Behavior:
LoadType.REFRESH
, the Paging 3 library should correctly continue loading subsequent pages, even on the app's first run.Actual Behavior:
LoadType.REFRESH
, the library incorrectly determines that no more data needs to be loaded.