美文网首页
glide的error和placeholder支持.9patch

glide的error和placeholder支持.9patch

作者: tinyvampirepudg | 来源:发表于2020-03-09 09:41 被阅读0次

    代码如下:

    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

    相关文章

      网友评论

          本文标题:glide的error和placeholder支持.9patch

          本文链接:https://www.haomeiwen.com/subject/byfudhtx.html