简体   繁体   中英

Glide version 4.7.1 can't load Gif to ImageView when I add RequestListener

When I tried to load from a gif url to a ImageView, I added more condition by RequestListener, but It didn't work|

Glide version : 4.7.1 it worked when I coded: Glide.with(context).asGif().load(gifModel.url).into(ivGif);

I want after loading gif completely, ivPreGif GONE

I added more contition but I didn't work

Glide.with(context)
                                .asGif()
                                .load(gifModel.url)
                                .listener(new RequestListener<GifDrawable>() {
                                    @Override
                                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
                                        return false;
                                    }
                                    @Override
                                    public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
                                        ivPreGif.setVisibility(View.GONE);
                                        ivGif.setVisibility(View.VISIBLE);
                                        return false;
                                    }
                                })
                                .into(ivGif);

Try this..

load method give your gif url.

        Glide.with(this).load(R.drawable.user).into(imageView);

  Glide.with(this).load(R.drawable.user)
            .listener(new RequestListener<Drawable>() {
                @Override
                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                     ivPreGif.setVisibility(View.GONE);
                    return false;
                }
            })
            .into(imageView);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM