android-smart-image-view icon indicating copy to clipboard operation
android-smart-image-view copied to clipboard

How can i disable using cache for super fast loading

Open knighthell opened this issue 12 years ago • 8 comments

When image in web-server changed,

Smart image view doesn't realize that changed.

I think, The reason is cache for super fast loading.

How can i disable using cache for super fast loading

or

realize changed-image.

knighthell avatar Jun 20 '12 20:06 knighthell

I would like that functionnality too ! It would be great if we would be able to put the componant with two attributes: CACHE and NO-CACHE

quentin-st avatar Jun 21 '12 08:06 quentin-st

You can clear the cache and it will reload the images from the server

WebImageCache cache = new WebImageCache(context); cache.clear();

So you could do it manually(I do mine when the user logs out) or you could do some sort of http request that checks if the image should be cleared.

You could also just use the source files in your program and remove all the cache calls.

meynet avatar Jun 21 '12 19:06 meynet

Thanks for the answer ! :D I'll use the cache.clear() method ! Very useful if we need to refresh the picture from the server. I think this should be on the documentation !

Thanks !

quentin-st avatar Jun 21 '12 19:06 quentin-st

Actually, I try to refresh the picture from the Internet. So here is my code: WebImageCache cache = new WebImageCache(getBaseContext()); cache.clear(); myImage2.setImageUrl(/* URL */);

But it does not work :s What is wrong ? :s

quentin-st avatar Jun 21 '12 20:06 quentin-st

I noticed this also with my images in a list view even though I verified that my cache was empty. I believe that it is due to the way android recycles views so they aren't refreshed until I scroll down then back up.

You might try myImage2.img.setImageResource(0); to clear the image then myImage2.setImageUrl("http..."); to refresh it. you would still need to clear the cache though because otherwise it would keep filling up.

If your image is going to be changing every time you app needs it you would be better off just using the source code in your project and removing the cache calls(faster than dealing with clearing cache all the time).

edit: You can even for off this repo and create your own version without caching

meynet avatar Jun 21 '12 21:06 meynet

Thanks ! :) I tried "myImage2.img.setImageResource(0);" , but it didn't worked. So I checked WebImage.java's code, and commented the two lines

"bitmap = webImageCache.get(url);" (line 32) and "webImageCache.put(url, bitmap);" (line 36),

and now it works !

Thanks a lot ! :) I hope this thread will help someone

quentin-st avatar Jun 22 '12 06:06 quentin-st

FAIK, it will be getting images from external also isn't it?

ricardo-nakayama-movile avatar Apr 02 '13 19:04 ricardo-nakayama-movile

WebImageCache cache = new WebImageCache(getActivity()); cache.clear(); Use this code inside the viewHolder where the data is populating.

rajeesh7 avatar Jun 27 '14 10:06 rajeesh7