I recently saw that google has a great library for paginating data.
In this Google IO:
Android Jetpack: manage infinite lists with RecyclerView and Paging (Google I/O '18)
They explained how to make Data + Network DataSource and grab data from database as Single Source of Truth and when the database is out of data it request for more data from the network with BoundaryCallback.
So assume that I have a list of Movies on the server. And client (Android user) can sort them by popularity, title, date_release and ...
So in the first time if the user sort movies by titles everything will work great because there is no data in database and data will be requested from the server to sort them by title and send them back. But what if after that user tries to sort them by popularity for example? Because of the availability of chunk of movies in database (for example 50 movies), it will sort this small amount of movies by popularity and then tries to grab data from server and this is not a good experience.
I cant make table for every sort type because it is not a good practice. So how can I overcome to this problem?
Thanks very much
from Android Paging Library - Data + Network with multiple sorting types
No comments:
Post a Comment