1

I'm using Picasso Square library in my android application. The app is a very simple one and shows a grid of pictures. When you touch one it opens it in full screen and when swiping to the right the next in line should be displayed.

My problem is that for every swipe, the image is loaded by picasso method:

Picasso.with(getApplicationContext()).load(Properties.IMAGE_URL + i).transform(transformation).centerCrop().fit().into(imageView);

I would like to avoid the load wait time and simply cache the next 2 images to be displayed. how would I go about doing this?

I know that picasso caches the images if they were loaded before. Is there a way to load the next image with picasso without attaching it to a specific ui element to be displayed?

tzuvy
  • 279
  • 1
  • 2
  • 8

1 Answers1

0

There is a way to do it – use fetch(). You can get more information from this question.

Community
  • 1
  • 1
Egor Neliuba
  • 14,784
  • 7
  • 59
  • 77
  • Hi, thanks for the answer. fetch() is not working for me. As you see, I'm calling the image with fit() and crop(). If I call the next image using fetch(), when calling it again with crop() and fit() it reloads it not using the cache. Does that make sense? – tzuvy Nov 08 '14 at 16:04
  • @tzuvy are you using a `ViewPager`? As a workaround, you could prepare more pages - `viewPager.setOffscreenPageLimit(n)`. The default value is `1` (one to the left and one to the right. – Egor Neliuba Nov 08 '14 at 20:23
  • @tzuvy I also found [this](http://stackoverflow.com/questions/24883034/getting-picasso-to-pre-fetch-forthcoming-images) question which might give you some directions. – Egor Neliuba Nov 08 '14 at 20:24