Getting Picasso to pre-fetch forthcoming images

前端 未结 1 1058
不思量自难忘°
不思量自难忘° 2020-12-15 21:34

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 sta

相关标签:
1条回答
  • 2020-12-15 21:58

    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();
              }
         }
    }
    
    0 讨论(0)
提交回复
热议问题