Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Android Development Tutorial: Lazy Loading and Caching Images (codehenge.net)
21 points by cacois on June 16, 2011 | hide | past | favorite | 6 comments


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.


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


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.


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


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..


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: