

Android Development Tutorial: Lazy Loading and Caching Images - cacois
http://codehenge.net/blog/2011/06/android-development-tutorial-asynchronous-lazy-loading-and-caching-of-listview-images/

======
mattgreenrocks
If you're lazy like me, you can use something like GreenDroid
(<https://github.com/cyrilmottier/GreenDroid>) or Droid-Fu's WebImageView
(<https://github.com/kaeppler/droid-fu>) to do this for you.

~~~
shareme
they have the same problem of not being kind to device orientation events

~~~
mattgreenrocks
You mean if you change from horizontal to vertical? Droid-Fu uses a two-level
cache so it should handle this case relatively well: the bitmaps are weak-
referenced and kept around if RAM permits, otherwise the disk is consulted.

IMO, Android handles the whole orientation thing poorly. Destroying an entire
activity because the orientation changed violates the principle of least
surprise.

------
cageface
Very interesting to see how this kind of thing is done on Android. GCD makes
this pretty easy on the iOS side.

------
shareme
the author makes a mistake...in async tasks you want to handle the device
orientation properly so that when the activity recreates upon device changing
form landscape to portrait that one can resume the asynctask and still
retrieve the cached images..

~~~
cacois
This is a very good point, just beyond the level I have gone to with these
tutorials thus far. When I first considered an example app, to do it "right"
was a fairly large project that wasn't easily digestible in tutorial form.
This is a limitation I plan to address in the future, though the whole
progression of adding more and more code to take care of such things
underscores the need for more comprehensive development frameworks for
android.

I'm hoping to move towards using one of the better frameworks like DroidFu
soon, and hopefully I will get most of this sort of functionality for free. If
not, at least I can help contribute some code to the cause.

