In my app for Android I\'m using Volley for loading images in custom listview.
when i refresh(delete all items and load tiems) listview many times, my app is killed with
I was having a very similar issue with loading images into a ListView. It seems you have to handle pulling from the cache yourself.
Below is my implementation which I have in my public View getView(int position, View convertView, ViewGroup parent)
adapter method:
Bitmap cachedBitmap = imageCache.getBitmap(item.getPhotoUrl());
if (cachedBitmap != null)
{
holder.photo.setImageBitmap(cachedBitmap);
}
else {
ImageLoader imageLoader = new ImageLoader(Volley.newRequestQueue(this.context), imageCache);
imageLoader.get(item.getPhotoUrl(), new ImageLoader.ImageListener() {
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
if (item.getPhotoUrl() != null && response.getBitmap() != null)
imageCache.putBitmap(item.getPhotoUrl(), response.getBitmap());
}
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
//This is a custom imageview, you can create your own implementation for loading the image url to the imageview
holder.photo.setImageUrl(item.getPhotoUrl(), imageLoader);
}
Have you tried
RequestQueue volleyQueue = Volley.newRequestQueue(this);
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
volleyQueue.start();
from
https://stackoverflow.com/a/21299261/3399432
This changes the cache size