1 回答
TA贡献1811条经验 获得超4个赞
Glide 4.9.0 可以设置默认请求Listener。
链接 https://github.com/bumptech/glide/releases/tag/v4.9.0 https://github.com/bumptech/glide/commit/37127f0f817d4a11dfdcc447946397b5288de593
在自定义 AppGlideModule 中
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.addGlobalRequestListener(new RequestListener<Object>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Object> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Object resource, Object model, Target<Object> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
});
}
}
在自定义活动片段中
GlideApp.with(object).addDefaultRequestListener()
Glide.with(object).addDefaultRequestListener()
添加回答
举报