devunwired / recyclerview-playground

Examples of RecyclerView use and custom LayoutManager implementations
MIT License
1.25k stars 270 forks source link

Request - more complex sample from larger streamed data source #16

Closed RoundSparrow closed 9 years ago

RoundSparrow commented 9 years ago

Hi. First off, thanks for the great sample code!

One of the big things about RecyclerView is it's intelligence in viewing a subset of a large number of items. My request is that somebody extend this sample to show some approach to having a streamed data source. For example, if you had 1000 images loaded from a remote http server - it would show the first page of 20 and load more as you scroll down.

I know the add/remove kind of does this... but it tends to want to hold all of them in a single ArrayList in the sample. So if you scrolled up/down the page, the ArrayList would be fully populated with 1000 items. That wouldn't work very well for Android memory usage.

How would you approach making it "smart" to know there are 1000 total items for purposes of scrolling - but not have an ArrayList object that holds all 1000 after a full scroll up/down?

you could also use a SQL data source of 1000 items instead of a remote server. that might be easier to mock up. Thank you.

devunwired commented 9 years ago

Thanks for your interest. This sample code focuses more on the layout aspects of RecyclerView. Something like this would be implemented in a customized adapter implementation.