web-dev-qa-db-ja.com

Glide-4にGlideDrawableImageViewTargetが見つかりません

なぜGlideDrawableImageViewTargetがGlide4 +で見つからないのですか?代替手段は何ですか?

私のコード:

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


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

[〜#〜] update [〜#〜]

_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) {

                }
            });
_

これを試して

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);
                }
            });
_

これを試して

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() {

                }
            });
_
7
Nilesh Rathod

build.gradledependencyimplementation 'com.github.bumptech.glide:glide:4.5.0'に更新します

DrawableImageViewTargetの代わりにGlideDrawableImageViewTargetをインポートしてください

または、以下のコードを使用します。

Glide.with(context).load(R.drawable.common_google_signin_btn_icon_dark).apply(new RequestOptions().placeholder(R.drawable.common_google_signin_btn_icon_dark)).into(new DrawableImageViewTarget(holder.profileImage));

これが役立つことを願って

4
Sukhbir Singh

GlideDrawable are 非推奨、シンプルなDrawableを使用

            Glide.with(mContext)
                .load(item.getFriendUserPhotoUrl())
                .listener(new RequestListener<Drawable>() {
                    @Override
                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {

                        fullname.setVisibility(View.VISIBLE);
                        progressBar.setVisibility(View.GONE);
                        imageView.setImageResource(R.drawable.profile_default_photo);
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {

                        progressBar.setVisibility(View.GONE);
                        fullname.setVisibility(View.VISIBLE);
                        return false;
                    }
                })
                .into(holder.thumbnail);
0
Said Erraoudy

new SimpleTarget<Bitmap>()は非推奨です。 new CustomTarget<Bitmap>()を使用できます。

            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
            }

            @Override
            public void onLoadCleared(@Nullable Drawable placeholder) {
                super.onLoadFailed(placeholder);
            }

            @Override
            public void onLoadFailed(@Nullable Drawable errorDrawable) {
                super.onLoadFailed(errorDrawable);
            }
        };```
0
Abhilash Das