kkl260
kkl260

Reputation: 395

Cache Picasso Images in background

I'm fetching some data in the background to cache so my feed is always updated, but I'm having an issue with the Images. Right now images won't cache unless they have already been loaded onto the imageview. I'm wondering if there is a way to load/cache the images in the background?

Upvotes: 2

Views: 313

Answers (2)

Eric Cochran
Eric Cochran

Reputation: 8574

You are looking for fetch().

picasso.load(something).fetch() will warm the cache for you.

Upvotes: 5

Aamir Ali
Aamir Ali

Reputation: 203

How far I think you can use new ImageView for this. Once cached, then get the Image from the ImageView.

Code :

 ImageView mImageView = new ImageView();
 Picasso.with(rootView.getContext()).load("your file").into(mImageView);
 Bitmap mBitmap = mImageView.getDrawingCache();

then use the bitmap. Thanks.

Upvotes: 0

Related Questions