Handling Glide image load failed

suggest change
Glide
        .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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents