I am having trouble implementing Image cache using the new Volley library. In the presentation, code look like this
mRequestQueue = Volley.newRequestQueue(context);
mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache());
The BitmapLruCache is obviously not included in the toolkit. Any idea how to implement it or point me to some resources?
http://www.youtube.com/watch?v=yhv8l9F44qo @14:38
Thanks!
Ficus provides this sample code for the Bitmap LRU:
https://gist.github.com/ficusk/5614325
this is comes in new API to handle the OOM
Here is an example of using a Disk based LRU cache with Volley. It is based on using a version of AOSP's DiskLruCache maintained by Jake Wharton. http://blogs.captechconsulting.com/blog/raymond-robinson/google-io-2013-volley-image-cache-tutorial
Edit: I have updated the project to include an in-memory LRU cache as the default implementation as this is the recommended method. Volley implicitly handles disk based cache in its own L2 cache. The image cache is just the L1 cache. I updated the original post and added some more detail here: http://www.thekeyconsultant.com/2013/06/update-volley-image-cache.html.
What I advise is using a Singleton Bitmap Cache so this cache is going to be available during all the life of your app.