简体   繁体   中英

how to avoid waiting too long for the server's data when using recyclerview

I managed to set up a recyclerview that displays server's data regarding some articles ( total 328 ). The problem is the waiting time. I have to wait about 40 seconds for the recyclerview to display completely. Is there a way to display a small portion of this data directly without having to retrieve all the data ? For instance, displaying data for the top 10 articles , scrolling down to the bottom , loading the next 10 articles and so on .. ANy recommendations ?

First of all, backend api should be able to provide results in a paginated way. So, when you load screen, you load first page. When you scroll down, you show a spinner and request the next page.

You can find a sample here

Another point would be store articles in local database.

If you are using Room library as database, you can use the pagination library

If you use another database, you have to implement your own solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM