MarkoMilos / Paginate

Library for creating simple pagination functionality upon RecyclerView and AbsListView
Apache License 2.0
1.35k stars 225 forks source link

[Question] #20

Closed dimityrivanov closed 7 years ago

dimityrivanov commented 7 years ago

Hi @MarkoMilos ,

I am using you pagination librarie but one question come to my mind when revieing the sample source code. Let's say that for example we have 1milion records that needs to be scrolled and we load 100items per page, shouldn't we keep a buffer of 100 elements per page only inside the adapter and when going to the next page to load the first 100 items and remove the items that are not visible currently on screen. (Lets assume that the data we posses is infinite and at some point in time the device will return OOM exception if we only add data to the recycleView adapter)

So when we scroll down increase page by one add 100 elements. When returning by scrolling up decrease page by one and add 100 elements on top of the adapter data structure.

Can you put some light here, thanks :)

MarkoMilos commented 7 years ago

If you have a large collection of data like that (which is not scenario in most cases) then yes - you should think of some memory management strategy. You can release items that are far away from the items that are currently on screen and then load it again later.

That "memory optimization/management" part is not what this lib is doing so it won't solve the problem for you. This lib doesn't do much with the original/source adapter at all. It only wraps it to check and manage item count and loading list item. All data/items management is still left for you to handle in your adapter or some other class wich is dedicated for managing data that is displayed in the list.

I will close this for now since its not the issue with the library... feel free to ask additional questions :)