noties / Markwon

Android markdown library (no WebView)
https://noties.io/Markwon/
Apache License 2.0
2.68k stars 298 forks source link

Is it possible to cache .gif files? #400

Closed gcobc12677 closed 2 years ago

gcobc12677 commented 2 years ago

when i did this,

// init Coil image loader
ImageLoader.Builder(this)
  .componentRegistry {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
          add(ImageDecoderDecoder(this@MyApplication))
      } else {
          add(GifDecoder())
      }
  }
  .build()

val coilImagesPlugin = CoilImagesPlugin.create(context, context.imageLoader)

Markwon.builder(context)
    .usePlugins(coilImagesPlugin)
    .build()

all image files (like .png or .jpg ) display as expected, but .gif files are not playing (seems like just showing one of its frames). then I try this,

val imagesPlugin = ImagesPlugin.create { plugin ->
    plugin.addMediaDecoder(GifMediaDecoder.create())
}

Markwon.builder(context)
    .usePlugins(imagesPlugin)
    .build()

all images are showing as expected ( .gif files are playing), but they are not cached with the implementation. so I tried to combine them together like this,

Markwon.builder(context)
    .usePlugins(coilImagesPlugin)
    .usePlugins(imagesPlugin)
    .build()

the result is, all image files display without cache. I wonder that is it possible to play .gif files and show .png / .jpg files with cache?

gcobc12677 commented 2 years ago

after tried to start() manually in onSuccess , .gif files work fine and cache is available with Coil.

wax911 commented 1 year ago

@gcobc12677 would you mind sharing how you achieved this? I'm building a new image request and applying some transformations, at which point did you utilise start()