Reputation: 33
I am using Glide to load a gif file from url, however it keeps looping. is there anyway to set a counter for looping for example just to play the animation 1 time.
Upvotes: 1
Views: 2965
Reputation: 1387
You may try like this -
Glide.with(getContext())
.load(R.drawable.some_gif)
.into(new GifDrawableImageViewTarget(mGifView, 1));
Upvotes: 0
Reputation: 2877
Add RequestListener
, here is the sample code
Glide.with(<context>)
.load(uri.toString())
.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) {
if (resource instanceof GifDrawable) {
((GifDrawable) resource).setLoopCount(1);
}
return false;
}
})
.into(<your imageview>);
Upvotes: 2