刷新通用图像加载器缓存
Flush Universal Image Loader cache
我正在使用 volley 单例加载图像
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;
访问它
不过我无法访问它。
LruCache has the method evictAll(),您可以在 ImageLoader 子类中公开此方法以清除缓存。
我正在使用 volley 单例加载图像
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;
访问它不过我无法访问它。
LruCache has the method evictAll(),您可以在 ImageLoader 子类中公开此方法以清除缓存。