android - 在 Glide-4 中找不到 GlideDrawableImageViewTarget

标签 android android-glide

为什么在Glide4+中找不到GlideDrawableImageViewTarget?有什么替代方案吗?

我的代码:

import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;


Glide.with(getContext())
                    .load(R.drawable.loader_gif_image)
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .into(new GlideDrawableImageViewTarget(imageView));
        }

最佳答案

更新

Use below code if you are using glide:4.9.0

    Glide.with(this)
            .load("")
            .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
            .into(new DrawableImageViewTarget(imageView));


    // or use this

    Glide.with(this)
            .load("")
            .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
            .into(new CustomTarget<Drawable>() {
                @Override
                public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                    imageView.setImageDrawable(resource);
                }

                @Override
                public void onLoadCleared(@Nullable Drawable placeholder) {

                }
            });

试试这个

You can use new SimpleTarget<Drawable>()

    Glide.with(this)
            .load(R.drawable.ic_favorite)
            .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
            .into(new SimpleTarget<Drawable>() {
                @Override
                public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                    imageView.setImageDrawable(resource);
                }
            });

试试这个

You can use new Target<Drawable>()

    Glide.with(this)
            .load(R.drawable.ic_favorite)
            .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
            .into(new Target<Drawable>() {
                @Override
                public void onLoadStarted(@Nullable Drawable placeholder) {

                }

                @Override
                public void onLoadFailed(@Nullable Drawable errorDrawable) {

                }

                @Override
                public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                    imageView.setImageDrawable(resource);
                }

                @Override
                public void onLoadCleared(@Nullable Drawable placeholder) {

                }

                @Override
                public void getSize(@NonNull SizeReadyCallback cb) {

                }

                @Override
                public void removeCallback(@NonNull SizeReadyCallback cb) {

                }

                @Override
                public void setRequest(@Nullable Request request) {

                }

                @Nullable
                @Override
                public Request getRequest() {
                    return null;
                }

                @Override
                public void onStart() {

                }

                @Override
                public void onStop() {

                }

                @Override
                public void onDestroy() {

                }
            });

关于android - 在 Glide-4 中找不到 GlideDrawableImageViewTarget,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61427558/

相关文章:

android - 切换 Android 设备数据连接

java - 如何修复Android Studio中的 ‘null json data ’错误

android - 程序类型已经存在 : android. support.design.widget.CoordinatorLayout$Behavior

android - Glide : How to find if the image is already cached and use the cached version?

java - 尝试在 Transform() 中加载图像时 Glide 卡住

android - 使用 Glide 将图像加载到 Google map 标记

iphone - Android 开发在任何方面都像 iPhone 那样受到限制吗?

安卓:更新数据

android - Glide 不接受 GifDrawable 作为目标参数

java - 从 logcat 获得的 id 和用于测试的 AdRequest.DEVICE_ID_EMULATOR 之间有什么区别?