【发布时间】:2011-08-27 14:51:55
【问题描述】:
我为我的播客应用程序编写了一个 rss 解析器。如果我正在解析具有不同播客的 rss 提要并在 ListView 中显示结果,我的解析器解析整个提要大约需要 1-2 秒。
但是,如果我想在 ListView 中包含每个播客的缩略图,我需要先下载缩略图并使用 BitmapFactory 创建位图,然后我可以将位图存储到 ImageView 中。
不幸的是,这将我的执行时间从 1-2 秒延长到了 8-10 秒。
这就是我抓取缩略图的方式。有没有更好(更快)的方法来实现我想做的事情,如果有,我该如何实现?
提前致谢。
...
else if (name.equalsIgnoreCase(THUMBNAIL)) {
HttpGet get = new HttpGet(parser.nextText());
if (get != null && get.getURI().toString().length()>1) {
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
if (entity != null) {
byte[] bb = EntityUtils.toByteArray(entity);
currentItem.setBitmap(BitmapFactory.decodeByteArray(bb, 0, bb.length));
}
}
}
【问题讨论】:
标签: android xml parsing feedparser