Skip to content

Commit

Permalink
Merge pull request #81 from jeziellago/changed/coil-to-singleton
Browse files Browse the repository at this point in the history
Change ImageLoader to get singleton
  • Loading branch information
jeziellago authored Jan 12, 2024
2 parents c990ceb + a86fb32 commit fb173bc
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.jeziellago.compose.markdowntext

import android.content.Context
import coil.ImageLoader
import coil.imageLoader
import io.noties.markwon.AbstractMarkwonPlugin
import io.noties.markwon.Markwon
import io.noties.markwon.MarkwonConfiguration
Expand All @@ -20,7 +21,7 @@ internal object MarkdownRender {
linkifyMask: Int,
onLinkClicked: ((String) -> Unit)? = null
): Markwon {
val coilImageLoader = imageLoader ?: createCoilImageLoader(context)
val coilImageLoader = imageLoader ?: context.imageLoader
return Markwon.builder(context)
.usePlugin(HtmlPlugin.create())
.usePlugin(CoilImagesPlugin.create(context, coilImageLoader))
Expand All @@ -43,9 +44,4 @@ internal object MarkdownRender {
})
.build()
}

private fun createCoilImageLoader(context: Context) =
ImageLoader.Builder(context)
.crossfade(true)
.build()
}

0 comments on commit fb173bc

Please sign in to comment.