onLoadFailed
A callback that should never be invoked directly.
Called when an exception occurs during a load, immediately before onLoadFailed. Will only be called if we currently want to display an image for the given model in the given target. It is recommended to create a single instance per activity/fragment rather than instantiate a new object for each call to
Glide.with(fragment/activity).load()
to avoid object churn.
It is not safe to reload this or a different model in this callback. If you need to do so use error instead.
Although you can't start an entirely new load, it is safe to change what is displayed in the Target at this point, as long as you return true
from the method to prevent onLoadFailed from being called.
For threading guarantees, see the class comment.
For example:
public boolean onLoadFailed(Exception e, T model, Target target, boolean isFirstResource) {
target.setPlaceholder(R.drawable.a_specific_error_for_my_exception);
return true; // Prevent onLoadFailed from being called on the Target.
}
Return
true
to prevent onLoadFailed from being called on target
, typically because the listener wants to update the target
or the object the target
wraps itself or false
to allow onLoadFailed to be called on target
.
Parameters
The maybe null
exception containing information about why the request failed.
The model we were trying to load when the exception occurred.
The Target we were trying to load the image into.
true
if this exception is for the first resource to load.