0

I'm using a volley singleton to load images

 private VolleySingleton(){ mRequestQueue = Volley.newRequestQueue(VolleyApplication.getAppContext()); mImageLoader = new ImageLoader(this.mRequestQueue, new ImageLoader.ImageCache() { private final LruCache<String, Bitmap> mCache = new LruCache<String, Bitmap>(10); public void putBitmap(String url, Bitmap bitmap) { mCache.put(url, bitmap); } public Bitmap getBitmap(String url) { return mCache.get(url); } }); } 

I need to flush the cache to update the imageView when the photo is changed.

I've read about MemoryCacheUtils here but can't seem to implment it in my code, can I use MemoryCacheUtils in my code? if not is there a way to flush the cache in my imageLoader?

Edit

Exposing the LruCache

 private VolleySingleton(){ mRequestQueue = Volley.newRequestQueue(VolleyApplication.getAppContext()); mImageLoader = new ImageLoader(this.mRequestQueue, new ImageLoader.ImageCache() { private final LruCache<String, Bitmap> mCache = new LruCache<String, Bitmap>(10); public void flushLruCache(){ mCache.evictAll();}; public void putBitmap(String url, Bitmap bitmap) { mCache.put(url, bitmap); } public Bitmap getBitmap(String url) { return mCache.get(url); } }); } 

I'm trying to access it with ImageLoader.ImageCache flush = (ImageLoader.ImageCache) mImageLoader;

I can't access it though.

1 Answer 1

1

LruCache has the method evictAll(), you could just expose this method in your ImageLoader subclass to clear the cache.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm having a bit of trouble accessing the new method, I've edit my code above, have I exposed it correctly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.