Load Gif without animating it in 4.0
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
Hi, I'm using Glide 4.0 RC1 and I dont know how to load a gif stopped at first with this version. At first, I only need the first frame of the gif. When I click on it, I want to animate it. And when the loop completes 3 times, I want to stop it and show a play button again. So I need to listen somehow when the loop ends.
I load my gif normally, and when onResourceReady() is invoked, I call resource.stop(), but it start playing the gif anyway.
My code looks like this:
RequestOptions options = new RequestOptions();
options.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC);
RequestBuilder request = Glide.with(getContext()).asGif().apply(options)
.listener(new RequestListener() {
@Override public boolean onLoadFailed(@Nullable GlideException e, Object model,
Target target, boolean isFirstResource) { }
@Override public boolean onResourceReady(GifDrawable resource, Object model,
Target target, DataSource dataSource, boolean isFirstResource) {
resource.setLoopCount(3);
resource.stop();
}
});
request.load(path).into(mImage);
Also, I dont know how to set a callback to be invoked when the gif finishes.
Thanks you so much.
Contributor guide
Assessment
This issue has not been assessed yet.