Perry Hoekstra
Perry Hoekstra

Reputation: 2783

Have Picasso load image before row is viewable

I am using Picasso to load images into a ListView cell and currently use a placeholder image. So, as the user scrolls down, the placeholder image in the ImageView is replaced with the true image that needs to be there (from a URL). However, that process of loading the true image/replacing the placeholder image does not happen until the cell is in view of the screen which means the user is constantly seeing the placeholder images change to the true images. Is there a way to have that process done offscreen so that user does not see that and achieve a better user experience?

Upvotes: 2

Views: 1838

Answers (1)

Kazuki
Kazuki

Reputation: 1492

You can use fetch() method to warm up cache

Picasso.with(context).load(urlToPrefetch).fetch();

Note this serves as best-effort basis. Cache may be removed before you really need this depending on your configuration, and even if disk cache exists, Picasso will display placeholder until it process image (though it must be completed faster than when loading image with remote server).

Upvotes: 2

Related Questions