views:

198

answers:

1

Hi guys,

In my application I use SoftReference to cache images, it is working fine with active internet connection. And now I need to cache images, so I could use it in offline mode.

What is the best way to implement it? Use complex solution with SoftReference and database? or maybe SoftReference and local storage (sdcard)?

I would appreciate your advices. Thanks.

A: 

2 level cache in memory and on disk. Check out the droid-fu project on github. It contains an ImageCache that works this way.

BrennaSoft
I tried WebImageView (from droid-fu) library but I cannot get it working, image is not loading. I have created Application extended from DroidFuApplication and configured it it manifest, even I've extended main activity from BetterDefaultActivity. But I still see only loading animation.Do you have working example?My code onCreate() of the Main activity is following: WebImageView img = (WebImageView) findViewById(R.id.webimage); img.setImageUrl("http://static.technorati.com/09/12/13/2291/android.jpg"); img.loadImage();What is wrong with it?
barmaleikin
that should work. Are there any exceptions in logcat? Does your app have the INTERNET permission?
BrennaSoft
Yes, internetn permission is here, also I added permission to write to local storage.
barmaleikin
In Log I see following:06-09 22:58:30.594: WARN/LocaleService(22485): onCreate06-09 22:58:30.684: WARN/LocaleService(22485): onStart06-09 22:58:30.964: WARN/ImageLoader(22447): download for http://static.technorati.com/09/12/13/2291/android.jpg failed (attempt 1)06-09 22:58:33.794: WARN/ImageLoader(22447): download for http://static.technorati.com/09/12/13/2291/android.jpg failed (attempt 2)06-09 22:58:36.704: WARN/ImageLoader(22447): download for http://static.technorati.com/09/12/13/2291/android.jpg failed (attempt 3)
barmaleikin
Why download is failed? May I ask you, do you have working example?
barmaleikin
Finally, I've got it working. I suspect there was problem with my internet connection.I have tried to implement ListView with WebImageView as item renderer and I found strange behavior. First time all images are loading into first list item, but after that when images are loading from cache it is working fine.Have you experienced such behavior?
barmaleikin