From 644587a98c16e18a233ee8cb1aec6147ff671370 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 20 Dec 2023 09:38:59 +0100 Subject: [PATCH] Fix crash... --- .../home/room/detail/timeline/item/MessageTextItem.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageTextItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageTextItem.kt index 6ffaa6d896..4cfeef0bcf 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageTextItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageTextItem.kt @@ -35,6 +35,7 @@ import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlUiState import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlView import im.vector.app.features.media.ImageContentRenderer import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence +import io.element.android.wysiwyg.EditorStyledTextView import io.noties.markwon.MarkwonPlugin import org.matrix.android.sdk.api.extensions.orFalse @@ -138,13 +139,19 @@ abstract class MessageTextItem : AbsMessageItem() { val previewUrlView by bind(R.id.messageUrlPreview) private val richMessageStub by bind(R.id.richMessageTextViewStub) private val plainMessageStub by bind(R.id.plainMessageTextViewStub) - var richMessageView: AppCompatTextView? = null + var richMessageView: EditorStyledTextView? = null private set var plainMessageView: AppCompatTextView? = null private set fun requireRichMessageView(): AppCompatTextView { - val view = richMessageView ?: richMessageStub.inflate().findViewById(R.id.messageTextView) + val view = richMessageView ?: richMessageStub.inflate().findViewById(R.id.messageTextView).also { + // Required to ensure that `inlineCodeBgHelper` and `codeBlockBgHelper` are initialized + it.updateStyle( + styleConfig = it.styleConfig, + mentionDisplayHandler = null, + ) + } richMessageView = view return view }