mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Merge pull request #4790 from vector-im/feature/adm/emoji-recycling
Timeline recycling crash
This commit is contained in:
commit
296929e179
2 changed files with 13 additions and 14 deletions
1
changelog.d/4789.bugfix
Normal file
1
changelog.d/4789.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fixing crashes when quickly scrolling or restoring the room timeline
|
|
@ -92,29 +92,27 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
|
|||
it.bind(holder.messageView)
|
||||
}
|
||||
}
|
||||
val textFuture = if (bindingOptions?.canUseTextFuture.orFalse()) {
|
||||
PrecomputedTextCompat.getTextFuture(
|
||||
message?.charSequence ?: "",
|
||||
TextViewCompat.getTextMetricsParams(holder.messageView),
|
||||
null)
|
||||
} else {
|
||||
null
|
||||
message?.charSequence.let { charSequence ->
|
||||
markwonPlugins?.forEach { plugin -> plugin.beforeSetText(holder.messageView, charSequence as Spanned) }
|
||||
}
|
||||
markwonPlugins?.forEach { plugin -> plugin.beforeSetText(holder.messageView, message?.charSequence as Spanned) }
|
||||
super.bind(holder)
|
||||
holder.messageView.movementMethod = movementMethod
|
||||
renderSendState(holder.messageView, holder.messageView)
|
||||
holder.messageView.onClick(attributes.itemClickListener)
|
||||
holder.messageView.onLongClickIgnoringLinks(attributes.itemLongClickListener)
|
||||
|
||||
if (bindingOptions?.canUseTextFuture.orFalse()) {
|
||||
holder.messageView.setTextFuture(textFuture)
|
||||
} else {
|
||||
holder.messageView.text = message?.charSequence
|
||||
}
|
||||
holder.messageView.setTextWithEmojiSupport(message?.charSequence, bindingOptions)
|
||||
markwonPlugins?.forEach { plugin -> plugin.afterSetText(holder.messageView) }
|
||||
}
|
||||
|
||||
private fun AppCompatTextView.setTextWithEmojiSupport(message: CharSequence?, bindingOptions: BindingOptions?) {
|
||||
if (bindingOptions?.canUseTextFuture.orFalse() && message != null) {
|
||||
val textFuture = PrecomputedTextCompat.getTextFuture(message, TextViewCompat.getTextMetricsParams(this), null)
|
||||
setTextFuture(textFuture)
|
||||
} else {
|
||||
text = message
|
||||
}
|
||||
}
|
||||
|
||||
override fun unbind(holder: Holder) {
|
||||
super.unbind(holder)
|
||||
previewUrlViewUpdater.previewUrlView = null
|
||||
|
|
Loading…
Reference in a new issue