0

I have an activity where I show a viewpager with a few Images. These images are retrieved from a remote source using Glide.

Now i want that when the user clicks on an image, he/she is taken to a GalleryActivity where they can also swipe to see the rest of pictures.

How can I make it so these images are transferred to the GalleryActivity and not need to be downloaded again?

MichelReap
  • 5,630
  • 11
  • 37
  • 99

2 Answers2

0

You don't need to worry about that, glide cache your images, it will not download again if url is same.

The default strategy, AUTOMATIC, tries to use the optimal strategy for local and remote images. AUTOMATIC will store only the unmodified data backing your load when you’re loading remote data (like from URLs) because downloading remote data is expensive compared to resizing data already on disk. For local data AUTOMATIC will store the transformed thumbnail only because retrieving the original data is cheap if you need to generate a second thumbnail size or type.

You can see Glide Caching.

So just pass your image url array to next activity. and load with glide. See How to pass array to next activity.

Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
0

Make an ArrayList of files/paths/Uris in your activity and pass the image array to another activity as extras.

intent.putExtra("images", yourList);

Then you can receive the list from the key "images" in the GalleryActivity.

You can also pass the index of the current Image so that you can set the default position in the ViewPager.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59