我使用一个凌空单身来装载图像
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);
}
});
}
我需要刷新缓存以在更改照片时更新imageView。
我在这里读过MemoryCacheUtils,但似乎无法在我的代码中实现它,我可以在代码中使用MemoryCacheUtils吗?如果没有办法在我的imageLoader中刷新缓存?
修改
公开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);
}
});
}
我尝试使用ImageLoader.ImageCache flush =(ImageLoader.ImageCache)mImageLoader;
我无法访问它。