Fix layout issue with comments that contain images
This commit is contained in:
1 parent
28279cc671
commit
e12897bd13
1 file changed
+16
-12
@@ -7,23 +7,27 @@ import android.widget.TextView
|
||||
import coil3.asDrawable
|
||||
import coil3.imageLoader
|
||||
import coil3.request.crossfade
|
||||
import coil3.size.Size
|
||||
import com.hippo.ehviewer.ktbuilder.imageRequest
|
||||
|
||||
class CoilImageGetter(
|
||||
private val textView: TextView,
|
||||
) : Html.ImageGetter {
|
||||
override fun getDrawable(source: String) = object : DrawableWrapper(null) {}.apply {
|
||||
textView.context.imageLoader.enqueue(
|
||||
textView.context.imageRequest {
|
||||
data(source)
|
||||
crossfade(false)
|
||||
target { drawable ->
|
||||
setDrawable(drawable.asDrawable(textView.resources))
|
||||
if (drawable is Animatable) drawable.start()
|
||||
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
|
||||
textView.text = textView.text
|
||||
}
|
||||
},
|
||||
)
|
||||
with(textView.context) {
|
||||
imageLoader.enqueue(
|
||||
imageRequest {
|
||||
data(source)
|
||||
crossfade(false)
|
||||
size(Size.ORIGINAL)
|
||||
target { drawable ->
|
||||
setDrawable(drawable.asDrawable(resources))
|
||||
if (drawable is Animatable) drawable.start()
|
||||
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
|
||||
textView.text = textView.text
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user