下载从XML内容的图像的最佳方法 [英] Best way to download images from XML content

查看:150
本文介绍了下载从XML内容的图像的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计这将展示一些消息,将在XML格式的远程URL检索一个Android应用程序,比如 HTTP ://adomain/latest.xml

I am designing an Android application which will be displaying some news that will be retrieved from a remote URL in xml format, say http://adomain/latest.xml

XML文件的格式如下:

The XML file has the following format:

<articles>
<article>
    <id>6</id>
    <title>A sample title</title>
    <image>http://adomain/images/anImage.jpg</image>
    <lastupdate>1326938231</lastupdate>
    <content><![CDATA[Sample content]]></content>
</article>
...
</articles>

我创建了侦听连接变化,当系统通过互联网连接,它会尝试下载该XML文件的更新服务。然后分析它并保存数据。更新程序在一个单独的线程上运行,每10分钟一班。

I have created an Updater Service which listens to Connectivity Changes and when the system has a connection over the internet, it tries to download the xml file. Then parse it and save data. The Updater runs on a separate thread, every 10 minutes.

我的问题是:
什么是处理图像的最佳方法是什么?

My question is: What is the best way to handle the images?

一)我应该对图像延迟加载时,将显示一条新闻

a) Should I perform lazy loading on images when a news item is displayed

b)如果我下载的图片时,我解析xml文件?

b) Should I download the image when I parse the xml file?

推荐答案

我推荐的新闻条目显示延迟加载,所以您不要使用过多的带宽(和潜在成本,为用户)。在下载图像无点,如果用户从来不愿意看他们。

I recommend lazy loading as the news item is displayed, so you don't use excessive bandwidth (and potentially cost for the user). No point in downloading images if the user never wants to look at them.

这篇关于下载从XML内容的图像的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆