获取毕加索以pre取即将到来图像毕加索、图像、pre

2023-09-05 10:48:41 作者:用钱和婊子发生关系。

我使用的是毕加索与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();
          }
     }
}