glide的error和placeholder支持.9patch

简介: glide的error和placeholder支持.9patch

代码如下:

Glide.with(mContext)
    .load(imgUrl)
    .into(new DrawableImageViewTarget(iv) {
        @Override
        public void onLoadStarted(@Nullable Drawable placeholder) {
            LogUtils.e(TAG, "onLoadStarted");
            super.onLoadStarted(placeholder);
            view.setBackground(mContext.getResources().getDrawable(R.drawable.common_img_imageloder_default));
        }

        @Override
        public void onLoadFailed(@Nullable Drawable errorDrawable) {
            LogUtils.e(TAG, "onLoadFailed");
            super.onLoadFailed(errorDrawable);
            view.setBackground(mContext.getResources().getDrawable(R.drawable.common_img_imageloder_default));
        }

        @Override
        public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
            LogUtils.e(TAG, "onResourceReady");
            view.setBackground(resource);
        }

        @Override
        public void onLoadCleared(@Nullable Drawable placeholder) {
            LogUtils.e(TAG, "onLoadCleared");
            super.onLoadCleared(placeholder);
            view.setBackground(null);
        }
    });

参考

https://github.com/bumptech/glide/issues/2786

相关文章
|
7月前
|
JavaScript
error Component name “Login“ should always be multi-word vue/multi-word-component-names【已解决】
error Component name “Login“ should always be multi-word vue/multi-word-component-names【已解决】
422 1
|
图形学 Windows
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
Unity2019操作对图集进行操作编辑出错:No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager.
1276 0
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
Flutter的setState的使用注意事项以及报错The method ‘setState‘ isn‘t defined for the type
Flutter的setState的使用注意事项以及报错The method ‘setState‘ isn‘t defined for the type
|
算法 Swift iOS开发
高级 SwiftUI 动画 — Part 1:Paths
在本文中,我们将深入探讨一些创建 SwiftUI 动画的高级技术。我将广泛讨论 Animatable 协议,它可靠的伙伴 animatableData,强大但经常被忽略的 GeometryEffect 以及完全被忽视但全能的 AnimatableModifier 协议。
232 0
|
Dart 开发工具 Kotlin
【错误记录】Flutter 编译报错 ( The parameter ‘‘ can‘t have a value of ‘null‘ because of its type, but the im )
【错误记录】Flutter 编译报错 ( The parameter ‘‘ can‘t have a value of ‘null‘ because of its type, but the im )
675 0
【错误记录】Flutter 编译报错 ( The parameter ‘‘ can‘t have a value of ‘null‘ because of its type, but the im )
|
Android开发
【错误记录】Tinker 热修复示例运行报错 ( patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -2)
【错误记录】Tinker 热修复示例运行报错 ( patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -2)
487 0
【错误记录】Tinker 热修复示例运行报错 ( patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -2)
|
Dart 开发者
【Flutter】Image 组件 ( 内存加载 Placeholder | transparent_image 透明图像插件 )
【Flutter】Image 组件 ( 内存加载 Placeholder | transparent_image 透明图像插件 )
343 0
【Flutter】Image 组件 ( 内存加载 Placeholder | transparent_image 透明图像插件 )
|
前端开发
前端 scss文件报错 Base-level rules cannot contain the parent-selector-referencing character '&'. 解决办法
前端 scss文件报错 Base-level rules cannot contain the parent-selector-referencing character '&'. 解决办法
449 0
|
Kotlin
【错误记录】布局组件加载错误 ( Attempt to invoke virtual method ‘xxx$Callback android.view.Window.getCallback()‘ )
【错误记录】布局组件加载错误 ( Attempt to invoke virtual method ‘xxx$Callback android.view.Window.getCallback()‘ )
319 0