Paging library - Boundary callback for network + db with API taking page and size

后端 未结 4 1138
小蘑菇
小蘑菇 2021-02-03 16:35

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

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 17:22

    Lets say you always fetch N=10 items per page from the server & then store it in db. You can get the number of items in db using the sql query SELECT COUNT(*) FROM tbl & store it in variable count. Now to get the page number that should be requested next, use:

    val nextPage: Int = (count / N) + 1
    

提交回复
热议问题