列表视图懒加载图像组件的设计视图、组件、图像、加载

2023-09-12 10:36:48 作者:源来凯始玺欢你

我有,我认为是在Android应用程序pretty的常见的场景。我知道解决作了问题的部分尝试,但到现在为止我还没有在全面实施栽了跟头。我打算尝试之后实现这种组件和开源的,但我在它的设计需要你的帮助。

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:

汤姆·范Zummeren的实施类似的组件与多家知名的问题 的杰里米Wadsack的细化中的概念,这是或多或少工作 懒惰可绘制源锻造项目。 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.

我也看到了一些关于这个问题的StackOverflow问题: 1 ,2, 3

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:

在一个应用程序,列出用户的YouTube视频 在为Facebook的应用程序 - 考虑朋友的图片 在支持用户的收藏夹等的应用服务新闻

请注意,我要开始获取与用户的主屏幕上的新数据,以提供更好的用户体验。我会继续保存在用户相关的数据在本地,直到永远。

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.

问题

所以,我的基本问题是什么方法,我应该使用的下载图像的实施?我知道,在Android手册说服务应该只使用时,我想,即使执行任务时,应用程序没有运行。在另一边,我将开始图像下载在主屏幕上,并链接下载到UI元素只是当用户导航到新屏幕(活动) - 用户相关列表视图,我不知道该如何实现与的AsyncTask (不,我有一个非常precise知道如何使用做服务无论是)。

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

任何建议将大大AP preciated,包括链接。

Any suggestion will be greatly appreciated, including links.

推荐答案

通用图像下载是一个好的图书馆,它可以帮助你做下载图像的背景设置。

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.