I'm trying to use PagingSource
, LazyPagingItems
and LazyColumn
to display a dataset that extends into the past and the future.
I want the initial load of my list to be centered on "today", and allow the user to scroll up to go back in time, down to go forward in time. My paging source does this with a custom key, but the principle is the same as starting on the not-first page.
So for example, if my first page is 5
, the first LoadResult.Page
I return would look like this:
LoadResult.Page(
data = list,
prevKey = 4,
nextKey = 6
)
If I do this, though, when the first page is loaded the LazyColumn
immediately triggers the previous page load. I assume this is because after updating it is initially scrolled to the top, triggering the prev page load. This then continues to happen as more data is loaded and the list jumps to the new top over and over. This happens forever, loading every page in the past until there are no more.
How can I prevent the Column from jumping to the top when a previous page is loaded? Is Paging3 not suited to having a bi-directional set of data?