Closed Demin92 closed 3 years ago
Any updates on this?
I have very similar issue, but in my case list jumps few items ahead after putting next page into database.
E.g. user sees items from 20 to 25 on the screen, page size is 10. In the meantime items from 40 to 50 are downloaded and pushed to database. Then list immediately jumps that the user sees items from 30 to 35.
After debugging I found out that PagedListAdapter
gets notified about weird removal operation of items 0 to 30, and then there are two inserts of 10 items at the front:
16:35:38.623: onItemRangeInserted: positionStart=40, itemCount=10
16:35:38.623: onItemRangeRemoved: positionStart=0, itemCount=30
16:35:38.665: onItemRangeInserted: positionStart=0, itemCount=10
16:35:39.212: onItemRangeInserted: positionStart=0, itemCount=10
In other words, adapter removes items from 0 to 30, and then adds again items from 10 to 30 in two batches.
EDIT:
More insights on this issue:
This problem happens only if room database gets populated with pages that are bigger than set in PagedList.Config
. In my case I have PagedList.Config.setPageSize(10)
, and after each request from BoundaryCallback
I'm inserting 10-14 elements to database. This is because I need to add some extra items (like labels to divide sections in listing).
The issue does not occur if I insert exactly the same items count to database, as page size.
In order for DiffUtil
to consolidate the initial load of next generation with previous one, the initial load must load enough items to cover the viewport - this doesn't change with Paging3, but the existing integrations with Room should have better defaults for this and it can be manually controlled by overriding PagingSource.getRefreshKey()
to return a key that would load about the user's position based on PagingState.anchorPosition
.
Since this seems to be mostly paging2 related and will soon be replaced by fixed in paging3, especially regarding porting existing legacy datasources to pagingsource with correct getRefreshKey()
implementations - I'm going to close this, but feel free to comment here and I'm happy to help you debug your setup to find the root cause.
Hello, I want to integrate Paging library in my project, in my case items of lists is able to be deleted^ but I do not know total count of it, so i need to set EnablePlaceHolders to false. If I do it in sample project sometimes animation look like this https://drive.google.com/file/d/1l_pgyuDf6JBNPvV8Lc0NHECjpIXy9f5w/view I added the id to text to clarify that animation is wrong: how you can see on video I have deleted 87th item, but the first visible item became 92th