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.asDrawable
|
||||||
import coil3.imageLoader
|
import coil3.imageLoader
|
||||||
import coil3.request.crossfade
|
import coil3.request.crossfade
|
||||||
|
import coil3.size.Size
|
||||||
import com.hippo.ehviewer.ktbuilder.imageRequest
|
import com.hippo.ehviewer.ktbuilder.imageRequest
|
||||||
|
|
||||||
class CoilImageGetter(
|
class CoilImageGetter(
|
||||||
private val textView: TextView,
|
private val textView: TextView,
|
||||||
) : Html.ImageGetter {
|
) : Html.ImageGetter {
|
||||||
override fun getDrawable(source: String) = object : DrawableWrapper(null) {}.apply {
|
override fun getDrawable(source: String) = object : DrawableWrapper(null) {}.apply {
|
||||||
textView.context.imageLoader.enqueue(
|
with(textView.context) {
|
||||||
textView.context.imageRequest {
|
imageLoader.enqueue(
|
||||||
data(source)
|
imageRequest {
|
||||||
crossfade(false)
|
data(source)
|
||||||
target { drawable ->
|
crossfade(false)
|
||||||
setDrawable(drawable.asDrawable(textView.resources))
|
size(Size.ORIGINAL)
|
||||||
if (drawable is Animatable) drawable.start()
|
target { drawable ->
|
||||||
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
|
setDrawable(drawable.asDrawable(resources))
|
||||||
textView.text = textView.text
|
if (drawable is Animatable) drawable.start()
|
||||||
}
|
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
|
||||||
},
|
textView.text = textView.text
|
||||||
)
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user