获取毕加索以pre取即将到来图像 [英] Getting Picasso to pre-fetch forthcoming images

查看:154
本文介绍了获取毕加索以pre取即将到来图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是毕加索与GridView控件,加载200张图像在网络上。现在它看起来像毕加索没有触发的图像通过网络加载,直到图像开始映入眼帘,屏幕上。

I'm using Picasso with a GridView, loading 200 images over the network. Right now it looks like Picasso is not triggering an image load over the network until the image starts to come into view on the screen.

有没有办法让毕加索pre取随后的N图像列表中,这样的体验更好?我使用的是适配器把图像转换成GridView控件。

Is there a way to have Picasso pre-fetch the next N images in the list so that the experience is better? I am using an Adapter to put the images into the Gridview.

推荐答案

我是prefetching图像转换成非常成功地运用毕加索缓存像这样:

I am prefetching images into a cache very successfully using Picasso like so:

if (BuildConfig.DEBUG) {
     Picasso.with(getApplicationContext()).setIndicatorsEnabled(true);
     Picasso.with(getApplicationContext()).setLoggingEnabled(true);
}
for (Article article : articleList) {
     ArrayList<String> images = article.getImages();
     for (String url : images) {
          if (!TextUtils.isEmpty(url)) {
               Picasso.with(getApplicationContext())
                    .load(url)
                    .resizeDimen(R.dimen.article_image_preview_width, R.dimen.article_image_preview_height)
                    .centerCrop()
                    .fetch();
          }
     }
}

这篇关于获取毕加索以pre取即将到来图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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