2

I am able to keep GIF file in drawable folder and use :

fun showGif(gifView: SimpleDraweeView?, resourceId: Int) {
    val draweeController: DraweeController = Fresco.newDraweeControllerBuilder()
        .setUri(UriUtil.getUriForResourceId(resourceId))
        .setAutoPlayAnimations(true)
        .build()
    gifView?.controller = draweeController
}

call it like :

 showGif(binding.mic, R.drawable.mic_recording)

Now the GIF file is https://lottiefiles.com/share/gordjiyb, the downloaded GIF size is 600kb. There is another way to keep JSON file which is 20 kb, I tried loading with Lottie and it worked, but With fresco library haven't found a solution. I tried loading URL by this method :

fun showGif(myDraweeView: SimpleDraweeView?, uri: String) =
    myDraweeView?.apply {
        controller = Fresco.newDraweeControllerBuilder()
            .setUri(uri)
            .setAutoPlayAnimations(true)
            .build()
    }

I tried passing https://lottiefiles.com/share/gordjiyb and other examples URLs to this method, but it does not work.

I want to load GIF through URL only with fresco library, is it possible? Please let me know If you have achieved this.

I have seen it working with GLIDE and LOTTIEs, but I have fresco used it in the app already, so we want to use only this library.

Vikas Pandey
  • 1,115
  • 1
  • 15
  • 25

1 Answers1

1

In order to enable animated GIF support for Fresco, you have to add the following Gradle dependency to your app:

// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.6.0'

as described here: https://frescolib.org/docs/

Alexander Oprisnik
  • 1,212
  • 9
  • 9