Reputation: 3400
Android paging library's PagingSource uses key like
PagingSource<Int, Item>
where the first parameter is the page number. What if the server, instead of using a page number, returns (for each request) a list of items ids the client should request for in the next request? Does Paging library support this scenario?
Upvotes: 0
Views: 1530
Reputation: 3895
PagingSource can support any arbitrary key type you want as you control both the generic type and the load() method.
If you are asking about Room's Paging integration, only positional keys (not page#) are supported with PagingSource<Int, Value>
, but what you write into the DB and the keys you use to load from DB are separate from what you use to load from network.
For network + DB scenario you should look into RemoteMediator
which powers Paging via DB and provides hooks for you to load from network when DB has no more cached items.
There is a great guide on DAC here: https://developer.android.com/topic/libraries/architecture/paging/v3-network-db
Upvotes: 2