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.
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);