2

My code is like this:

String gifUrl = "http://i.kinja-img.com/gawker-media/image/upload/s--B7tUiM5l--/gf2r69yorbdesguga10i.gif";


Glide
   .with( mContext )
   .load( gifUrl )
   .error( R.drawable.sample )
   .into( imageViewTarget );

imageViewTarget is a normal imageview. But it is not loading the gif in the imageview.

Zoe
  • 27,060
  • 21
  • 118
  • 148
anand kumar
  • 69
  • 2
  • 5
  • Possible duplicate of [Show GIF file with Glide (image loading and caching library)](http://stackoverflow.com/questions/31082330/show-gif-file-with-glide-image-loading-and-caching-library) – crizzis May 20 '17 at 20:18

3 Answers3

0

use GlideDrawableImageViewTarget

ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(gifUrl).into(imageViewTarget);

or

 Glide.with(context)
.load(gifUrl)
.asGif()
.placeholder(R.drawable.sample)
.crossFade()
.into(imageView);
sasikumar
  • 12,540
  • 3
  • 28
  • 48
0

It works but may take time in loading gif.

ImageView imageView = (ImageView) findViewById(R.id.imageView);
    GlideDrawableImageViewTarget imageViewPreview = new GlideDrawableImageViewTarget(imageView);
    Glide.with(this)
            .load("http://i.kinja-img.com/gawker-media/image/upload/s--B7tUiM5l--/gf2r69yorbdesguga10i.gif")
            .listener(new RequestListener<String, GlideDrawable>() {
                @Override
                public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                    Log.e("MyApp", "onException: "+model+" Exception: "+e );
                    return false;
                }

                @Override
                public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                    Log.e("MyApp", "onResourceReady: "+model );
                    return false;
                }
            })
            .into(imageViewPreview);
Zeero0
  • 2,602
  • 1
  • 21
  • 36
  • is It the Download time or the loading time? gif is only 354kb , still taking time. Any work around for that? – anand kumar May 21 '17 at 03:18
  • It loads just fine from local but takes time from url. Try to add this: .diskCacheStrategy(DiskCacheStrategy.SOURCE) For more details check this issue: https://github.com/bumptech/glide/issues/600 – Zeero0 May 21 '17 at 10:23
0

Dont use transition or animation for Glide.It will solve your problem

Code :

Glide.with(context) .load(imgurl) 
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.RESOURCE) 
.error(R.drawable.no_image)) .into(holder.imageView);
Mohammad
  • 21,175
  • 15
  • 55
  • 84