azpublic
azpublic

Reputation: 1404

CWAC android endless list adapter for very big list

I was wondering how to handle very large lists using CWAC's endless adapter.

My main concern is about memory management. If I cache thousand's of items I will end up with an out of memory exception. So how do I handle that cache ? Can I clear earlier entries ?

As far as I understood it, the endless adapter will only fire its cacheInBackground() method and appendCachedData() when we scroll the list down. What if I want to clear the cache for earlier entries (top of the list) that are not visible anymore ?

How will the endless adapter behave when I scroll back up ? In other words is the endless adapter bi-directional ? If not, can I work around that limitation ?

Thanks in advance.

Upvotes: 2

Views: 789

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006859

EndlessAdapter has little to do with your problem. So long as your underlying adapter recycles its rows, the adapter framework will work as well as it can for handling "very large lists". However, eventually, your model data will consume too much heap space.

So how do I handle that cache ?

By not putting "thousand's of items" in a ListView in the first place. Give your user some means of finding things that does not involve sifting through a massive list.

Can I clear earlier entries ?

No, no more than you can do so in any other Adapter.

What if I want to clear the cache for earlier entries (top of the list) that are not visible anymore ?

Cook up your own AdapterView and Adapter framework that works under the principle that the Adapter is reporting the contents of some range of positions inside some larger data set.

How will the endless adapter behave when I scroll back up ?

The same as any other Adapter.

Upvotes: 2

Related Questions