I am using fresco 2.6.0 library for loading a gif animation into imageView, our requirement is to play animation just once and then show placeholder or source image in that image view. We don't want to use glide as the animations looks disturbed.
tried creating a controller and then passing it to view, but not getting when to call anim.stop()
val gifController: DraweeController = Fresco.newDraweeControllerBuilder()
.setUri(UriUtil.getUriForResourceId(R.drawable.save_draft))
.setControllerListener(object : BaseControllerListener<ImageInfo?>() {
override fun onFinalImageSet(
id: String,
imageInfo: ImageInfo?,
anim: Animatable?
) {
if (anim != null) {
anim.start()
}
}
})
.build()
iv.controller = gifController
Well, I haven't used fresco for GIF loading, but you can try the below code and it is working pretty well actually.
Library used :
Output :