web-dev-qa-db-fra.com

GlideDrawableImageViewTarget introuvable dans Glide-4

Pourquoi GlideDrawableImageViewTarget est introuvable dans Glide4 +? Quelle est l'alternative?

Mon code:

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

[~ # ~] mise à jour [~ # ~]

Utilisez le code ci-dessous si vous utilisez 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) {

                }
            });

Essaye ça

Vous pouvez utiliser 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);
                }
            });

Essaye ça

Vous pouvez utiliser 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

Mettez à jour votre dependency dans build.gradle à implementation 'com.github.bumptech.glide:glide:4.5.0'

Essayez d'importer DrawableImageViewTarget au lieu de GlideDrawableImageViewTarget

Ou utilisez le code ci-dessous.

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

J'espère que cela vous aidera

4
Sukhbir Singh

GlideDrawable are obsolète, utilisez simple 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>() est obsolète. Vous pouvez utiliser 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