Status Update
Comments
cl...@google.com <cl...@google.com> #2
Hello, can you please attach a sample that reproduces your error?
al...@gmail.com <al...@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
al...@gmail.com <al...@gmail.com> #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
du...@google.com <du...@google.com> #6
1 - run submitData on a background thread throws : java.lang.IllegalStateException: Method addObserver must be called on the main thread.
This doesn't seem related to Paging, what did you try exactly?
al...@gmail.com <al...@gmail.com> #7
I tried :
lifecycleScope.launch(Dispatchers.IO) {
viewModel.pagingDataFlow.collectLatest(showAdapter::submitData)
}
du...@google.com <du...@google.com> #8
Is your ViewModel lazily initialized? That must be done on main thread. Perhaps you can try:
val pagingDataFlow = viewModel.pagingDataFlow
lifecycleScope.launch(Dispatchers.IO) {
pagingDataFlow.collectLatest(showAdapter::submitData)
}
Description
Component used: Paging3 Version used: 3.1.0 Devices/Android versions reproduced on: Pixel4a API 31.
Sample project can be found here :https://github.com/alirezaeiii/Paging3-Sample
At the very 1st scroll it is laggy, and I can not figure out why. Would you please help out?
In my repository layer :
And in the ViewModel class :
In my Activity I submit the data in recyclerView as follow :
Is there something missed? why scrolling is laggy in 1st scroll?