Handling Glide image load failed
suggest changeGlide
.with(context)
.load(currentUrl)
.error(SET_YOUR_DEFAULT_IMAGE)
.into(new BitmapImageViewTarget(profilePicture) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(context.getResources(), resource);
circularBitmapDrawable.setCornerRadius(radius);
profilePicture.setImageDrawable(circularBitmapDrawable);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
profilePicture.setImageDrawable(errorDrawable);
Log.e(TAG, e.getMessage(), e);
}
});
This is the Glide 3 Target API. Put any fallback Drawable in SET_YOUR_DEFAULT_IMAGE. .error(...) supplies that drawable to onLoadFailed when the load fails. radius and TAG are defined by the surrounding class.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents