So I'm just interested if I could prevent Glide from loading a white (null) image into an ImageView if the url provided is wrong.. I'd like to keep the image that I provide in XML if it can't find the image (because it might be wrong due to user input).
I've tried returning true in the listener, but I guess that's just for animation handling. Many thanks!
public static void loadImage(String url, Context c, ImageView target) {
Glide.with(c).load(url).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
e.printStackTrace();
return true;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).into(target);
}
}