Setup :
We are using PagedListEpoxyController, RxPagedListBuilder, ItemKeyedDataSource with a runtime Mockgenerator which just creates a user with respect to the index of data that is generated, for eg. user1, user100, user500 etc.
Paging configuration is :
val pageSize = 50
val initialLoadSizeHint = 80
val prefetchDistance = 16
Expected behaviour
Whenever we scroll down to the 400th item and come back to the 300th item and invalidate the list by clicking Follow/Unfollow the UI jumps. When the button is clicked the PagedList is invalidated like this:
followers.dataSource.invalidate()
loadInitial() inside ItemKeyedDataSource should be called with the value of params.key so we can get the same page that was previously displayed to be re-displayed. For example if user300 was visible in the screen, that item requestedInitialKey should be in the range of [user221,user280].
Where is the issue?
Paging Library tracks of the last item that was fetched in the pagedList before invalidation but does not provide a way to know which was the last item/range that was visible in the screen just before invalidation.
After invalidating the pagedList, The first callback which gets called after pagedList invalidation is loadInitial(params : LoadInitialParams, callback : LoadInitialCallback) with the params only holds the information about pageSize and placeholder along with requestedInitialKey as last item that was fetched before invalidation which is very misleading. Why, after invalidation a pagedList does request the last item to be fetched in the list as the requestedInitialKey / item in the firstPage rather than the last item that was displayed before invalidation?. Sorry if I have totally misunderstood this thing but couldn't really make sense of it.
Question :
I wish pagedList to start fetching the first page in new PagedList after invalidation from the previous scroll Location rather than the last item in the previous pagedList.
But if PagedList is not supposed to work this way then How can I know any of the item/index that was previously visible in the screen before invalidation?
If I can't do that currently either, what is the recommended way to achieve this requirement?
This issue can be found here :
To reproduce : Scroll down far enough (like 60th item) and press "Refresh" you will see the jump in the list. Link to github issue
