allowing nullable message content in order to reset the content when recycling and an item doesn't contain a message

This commit is contained in:
Adam Brown 2022-01-05 09:15:11 +00:00
parent 0df07d0a1e
commit 6380ee9176
1 changed files with 3 additions and 4 deletions

View File

@ -96,13 +96,12 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
renderSendState(holder.messageView, holder.messageView) renderSendState(holder.messageView, holder.messageView)
holder.messageView.onClick(attributes.itemClickListener) holder.messageView.onClick(attributes.itemClickListener)
holder.messageView.onLongClickIgnoringLinks(attributes.itemLongClickListener) holder.messageView.onLongClickIgnoringLinks(attributes.itemLongClickListener)
holder.messageView.setTextWithEmojiSupport(message?.charSequence, bindingOptions)
message?.let { holder.messageView.setTextWithEmojiSupport(it.charSequence, bindingOptions) }
markwonPlugins?.forEach { plugin -> plugin.afterSetText(holder.messageView) } markwonPlugins?.forEach { plugin -> plugin.afterSetText(holder.messageView) }
} }
private fun AppCompatTextView.setTextWithEmojiSupport(message: CharSequence, bindingOptions: BindingOptions?) { private fun AppCompatTextView.setTextWithEmojiSupport(message: CharSequence?, bindingOptions: BindingOptions?) {
if (bindingOptions?.canUseTextFuture.orFalse()) { if (bindingOptions?.canUseTextFuture.orFalse() && message != null) {
val textFuture = PrecomputedTextCompat.getTextFuture(message, TextViewCompat.getTextMetricsParams(this), null) val textFuture = PrecomputedTextCompat.getTextFuture(message, TextViewCompat.getTextMetricsParams(this), null)
setTextFuture(textFuture) setTextFuture(textFuture)
} else { } else {