Search code examples
androidandroid-imageviewpicasso

What's the fastest way to pass an image between two activities?


Say that I have:

Activity activity1 containing ImageView imageView1

and

Activity activity2 containing ImageView imageView2,

and I have a string url pointing to an image (cached by Picasso), which I already loaded into imageView1. How can I launch Activitiy2 and load the same image into ImageView2 in the fastest way?

Currently, I'm calling the Picasso.load().into() on the url as soon as the activity is launched. This is fast, but I'm looking for something faster.

Picasso.with(mContext)
        .load(myUrl)
        .into(imageView2);

Any suggestion would be really appreciated.


Solution

  • Picasso downloads the complete image and saves the original image in disk/memory. Suppose the original image dimension was 800x800 and you are trying to load this image into a view with dimension: 100x100, then Picasso will take some time for re-sizing. You might want to give Glide[1] a try. Glide has the option to cache both re-sized images and original image as well. (check Glide#diskCachingStratedgy)

    Also, with Picasso, if you use .noFade() option, then the image might appear to load a bit faster.

    [1] https://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en