Design of list view lazy loading images component

回眸只為那壹抹淺笑 提交于 2019-11-27 08:21:41

问题


I have a scenario which I think is pretty common in Android applications. I know partial attempts of solving the issue were made, but until now I have not stumbled upon the full implementation. I intend to try to implement such component and open source it afterwards, but I need your help in its design.

So basically my case is the following: I have list view showing image loaded from the web and text per each row. I want to lazily load the images, placing default for each image and substituting it with the real one only when the image is downloaded. I also want to keep image cache avoiding the need to download the images multiple times in short period.

Up to now I have found several implementations that are partially working including:

  • Tom van Zummeren's implementation of similar component with several well known problems
  • Jeremy Wadsack's refinement of the concept, which is more or less working
  • Lazy drawables source forge project.

I also saw several stackoverflow questions regarding the problem: 1, 2, 3

However I have one more requirement which makes my task a bit more complex: I allow the user of my application to affiliate himself with some of the images. I want to load the new images associated to the user whenever the user navigates to the home screen. From it he should be able to go see his images, even before they have all been downloaded and in this case again default placeholders should be visible (Note the cross screen transition). Such use cases are:

  • An app listing user's youtube videos
  • An app for facebook - consider the images of friends
  • An app serving news that supports user's favorites etc

Note that I want to start fetching the new data related to the user on the home screen to provide better user experience. I will keep the user-related data stored locally forever.

The question

So my basic question is what approach should I use for the implementation of the image downloading? I know that the Android manuals say Service should be used only when I want to execute task even when application is not running. On the other side I will start the image downloading on the home screen and link the downloads to UI elements just when the user navigates to the new screen (Activity) - user-related list view and I do not know how to achieve that with AsyncTask (not that I have a very precise idea how to do it with Service either).

Any suggestion will be greatly appreciated, including links.


回答1:


Universal Image Downloader is a good library which helps you to do image downloading in background with your settings.

It has so many features that you can implement at your own way.



来源:https://stackoverflow.com/questions/13933529/design-of-list-view-lazy-loading-images-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!