-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot stop gif onClick- Getting TransitionDrawable instead of Animate/GifDrawable #1065
Labels
Comments
The better approach here is this:
Here's some code: final Uri uri = Uri.parse("https://media.giphy.com/media/TcKmUDTdICRwY/giphy.gif");
final BitmapRequestBuilder<Uri, GlideDrawable> thumbRequest = Glide
.with(context)
.load(uri)
.asBitmap() // force first frame for Gif
.transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)
.override(params.width, params.height)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.image_placeholder)
.error(R.drawable.image_error)
.fitCenter()
;
thumbRequest.into(feed.imgFeed);
feed.imgFeed.setOnClickListener(new OnClickListener() { // or any parent of imgFeed
@Override public void onClick(View v) {
Glide
.with(context)
.load(uri) // load as usual (Gif as animated, other formats as Bitmap)
.override(params.width, params.height)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.placeholder(R.drawable.image_placeholder)
.error(R.drawable.image_error)
.thumbnail(thumbRequest)
.dontAnimate()
.into(feed.imgFeed);
}
}); Few things to note:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am loading gif image in Imageview with container recyclerview.
Currently the recyclerview has only 1 gif and other are bitmaps.
I am loading gif as
I want on Demand gif loading i.e When gif image is completely downloaded i don't want to start it on it's own rather when user clicks it.
In click event i am checking drawable instance if it's Animated/GifDrawable to start the animation.
But i am receiving TransitionDrawable that does not allow animation.
Tried loading other gifs but same issue was reproduced.
Is there any workound?
The text was updated successfully, but these errors were encountered: