Status Update
Comments
du...@google.com <du...@google.com> #2
Could you clarify what you mean by for processing?
If you want to react as items are loaded you could try using PagingData.map
. If you want to fetch a specific item you could use adapter.getItem(position), but not e that this will trigger fetches and drops based on prefetchDistance. We're looking into some better ways to expose the loaded data as the library is still alpha, so if you could let us know your use-case it would definitely help!
[Deleted User] <[Deleted User]> #3
In our case we have "search" feature that works with a recycler view. When user clicks a search result item, we want to check if the item is already loaded (say, in PagingData) so we don't have to invalidate the whole paged data if already loaded. Also we want to make sure the searched item is visible on the screen, so we need to find the position of the item in the loaded list (e.g. PagingData), so that we can scroll the recycler view (scrollToPosition) to the item so it's visible. I think we can achieve these with what you mentioned (PagingData.map
or adapter.getItem(position)
) but I'm not sure if it's the best option or if it'd work well.
du...@google.com <du...@google.com> #4
It should work as a stop-gap except for pages getting dropped due to maxSize (default value of PagingConfig.maxSize
is unbounded).
I agree that Paging could provide some better ways to allow access to the loaded / presented data though, but we're still investigating the best way to expose that.
[Deleted User] <[Deleted User]> #5
We've since been trying with the stop-gaps and it turned out they're not as useful as it seemed. PagingData.map
doesn't do much help since we can't reliably associate the items from Paging.map
with their corresponding positions in the adapter. Also Adapter.getItem
initiating loadAround
has turned out to be really problematic for our use case. I think calling loadAround
from getItem
is maybe too much of a side effect from a getter method. I wonder if you guys considered calling loadAround(i)
when the view at the position i is bound?
du...@google.com <du...@google.com> #7
This will allow access to the presented data, after transformations. For processing dependent on loaded pages, you should still use PagingData.map { } to ensure transformations don't remove items you need to process.
Description
Version used:3.0.0
Devices/Android versions reproduced on:
Hi, Can anyone guide me to a source on how to access the fetched data for processing. Now PagingData is set to adapter and accessed on onBindViewHolder, but I couldn't find a way to get the fetched data.