1

This problem is not similar to Loading images using picasso on a slow connection.

I have a view pager in which fragments are loading dynamical (I am using FragmentStatePagerAdapter as there are a lot of fragments depending upon the number of images in the array of images). Each fragment contains an Image View. I am calling Picasso.with(mContext).load(url).into(imageView); it puts the request in a queue, and when I keep scrolling it keeps putting requests in queue. The problem is when internet connection is slow, previous requests take time and current image loading request (on current page) is served after a long time and meanwhile screen shows place holder image. So, my question is ,is there any way to cancel requests made for previous fragments and just execute the current request? Also, at a time view pager is keeping 3 fragments in memory (default behaviour), so if other fragments (off screen fragments) are getting destroyed, does picasso cancel those requests (related to fragments which are getting destroyed) automatically? If these requests are not getting cancelled automatically, is there any way to do that?

I know there are functions to cancle requests but I don't know how to use them in case of view pager as view pager will keep atleast 3 fragments in memory by default.

I am using Picasso 2.4.0. I am not using Picasso 2.5.2 as it has issues in loading camera images (the bug is already locked regarding this camera image issue and I also haven't found any solution yet)

Links Visited

Loading images using picasso on a slow connection.

ViewPager unable to load images lazily with Picasso

First time error loading picture with Picasso

Thanks and regards

Community
  • 1
  • 1
Ankit Aggarwal
  • 2,941
  • 2
  • 17
  • 26

0 Answers0