0

To specify my question, for example, user searches with some keywords and the results come in from server, there might be 10,000 results, not all these 10,000 results should be displayed, that might cause performance issues, what we often see is that, every time, 20 results are displayed, and when use has reached the end, another 20 results are displayed, and this continues. I wonder how this is done? 1. Do we store all these 10,000 results somewhere first, let's say, an array list, and then load and display 20 of them each time when needed, or 2. Request only 20 results from server each time and then request more when needed? Either way, I don't think is perfect, maybe there are some other ways? Like in the first way, wouldn't it cause some performance issues? There are 10,000 results, we need to store all of them somewhere first. And the second way, each time we download only 20 results, how do we mark where we are right now?

K.Wu
  • 3,553
  • 6
  • 31
  • 55
  • Also, take a look at [Endless Scrolling with AdapterViews and RecyclerView](https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView) – Joshua Aug 18 '17 at 05:49
  • Thank you @Joshua, by reading the answer, I now know that I should request more results from server upon reaching the last item. Here's another problem though, my search is based on some keywords, each time I request results from server, wouldn't I get the same results? Then how do I discard the 20 results that have already been shown and get the next 20 instead? – K.Wu Aug 18 '17 at 06:00
  • It depends on what server are you use. But most search result are cached, they will not be change in a short period of theme and they usually have paging parameter. – Joshua Aug 18 '17 at 06:06
  • 1
    you have to implement pagination at the server end. every time when you request for 20 results you will get the next url parameter for next 20 results – Deepak Jangir Aug 18 '17 at 06:16
  • @DeepakJangir , thank you very much, I will go ahead and learn how to implement pagination first – K.Wu Aug 18 '17 at 15:52

0 Answers0