Short question:
What is the correct way to handle database + network on the Paging library from Architecture components, using an API that uses page + s
I have a similar API (pageNum + size), I have 2 extra fields in my data class
, pageNum
and pageSize
with defaults 1
and PAGE_SIZE
respectively.
If you're using Network+DB
then you'll have onZeroItemsLoaded
and onItemAtEndLoaded
,
In onZeroItemsLoaded
send pageNum
and pageSize
as it is, and in onItemAtEndLoaded
increment pageSize by 1
and then send.
Let's say you have a method fetchData(pageNum, pageSize)
when you receive result in this just update the pageNum
and pageSize
accordingly in each item of this page.