penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
580 stars 76 forks source link

use glide load apngDrawable can't callback(onAnimationEnd) properly #126

Closed Beseting closed 2 years ago

Beseting commented 2 years ago

New Issue Checklist

Issue Info

Info Value
Device Info e.g. Emulator&Android Pad
System Version e.g. 8.0
APNG4Android Library Version e.g. 2.16.0
Repro rate e.g. all the time (100%)
Repro with our demo project e.g. 100%happen
Demo project link e.g. see description

Issue Description and Steps

When I use Glide load apngDrawable,the AnimationCallback doesn't work,It's get back first. And Then,when I use imageView.setImageDrawable(apngDrawableExpression),it works! Demo code: val apngDrawable = APNGDrawable(FileLoader(filePath)) apngDrawable.setLoopLimit(3) apngDrawable.registerAnimationCallback(object: Animatable2Compat.AnimationCallback(){ override fun onAnimationEnd(drawable: Drawable?) { super.onAnimationEnd(drawable) ToastUtils.showShort("end") } }) apngDrawable.setAutoPlay(true) // use glide,callback doesn't work properly Glide.with(imageView).load(apngDrawable).into(imageView) // use imageView.setImageDrawable(),callback works imageView.setImageDrawable(apngDrawableExpression)

jingpeng commented 2 years ago

I'll check the logic

jingpeng commented 2 years ago

when you use glide to load apng drawable, please setAutoPlay(false) for accurate callback

Beseting commented 2 years ago

when you use glide to load apng drawable, please setAutoPlay(false) for accurate callback

Thanks for your reply,I follow your code,the callback accurate worked,thank you very much!

jingpeng commented 2 years ago

you are welcome!