Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if an ImageView is done loading and image in android studio

I am trying to load a few (about 50) ImageViews with images from an array of URLs using Glide. But the loading seems to be slow. I think it is because it is trying to load all the images at once.

How do I check if an image is done loading from a URL in an ImageView?

Only after the first 4 images are loaded I would make the next 4 images load and so on.

Please help. Thanks in advance.

like image 817
Zohaib Hamdule Avatar asked Nov 14 '25 13:11

Zohaib Hamdule


1 Answers

Just add a callback from Glide:

Glide.with(getActivity())
     .load("your-image-url")
     .listener(new RequestListener<String, GlideDrawable>() {
         @Override
         public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
             // The Image failed to load here.
             return false;
         }

         @Override
         public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
             // The Image already loaded here.
             return false;
         }
     })
     .into(imageView);
like image 146
Mike Avatar answered Nov 17 '25 08:11

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!