本文介绍了让毕加索预取即将到来的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有 GridView 的 Picasso,通过网络加载 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.
有没有办法让 Picasso 预取列表中的下 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.
推荐答案
我使用 Picasso 非常成功地将图像预取到缓存中,如下所示:
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();
}
}
}
这篇关于让毕加索预取即将到来的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!