-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeline recycling crash #4790
Timeline recycling crash #4790
Changes from 4 commits
4daef60
57e0ce2
0df07d0
6380ee9
22bab47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixing crashes when quickly scrolling or restoring the room timeline |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
|
||
package im.vector.app.features.home.room.detail.timeline.item | ||
|
||
import android.text.Spanned | ||
import android.text.method.MovementMethod | ||
import androidx.appcompat.widget.AppCompatTextView | ||
import androidx.core.text.PrecomputedTextCompat | ||
|
@@ -92,27 +91,22 @@ 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 | ||
} | ||
markwonPlugins?.forEach { plugin -> plugin.beforeSetText(holder.messageView, message?.charSequence as Spanned) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah 🤦 I got confused by https://github.com/vector-im/element-android/pull/4790/files#diff-473563ebe7dac7363901c094cc094bb438921f76a16bf13a020eefbff15d0c24R100 didn't realise there were two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 2 different methods There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from the default implementations in the markwon library, it seems they're mainly used for apply text movements (links) and measuring lists but custom plugins can make use of them if needed /**
* It can be useful to prepare a TextView for markdown. For example {@code ru.noties.markwon.image.ImagesPlugin}
* uses this method to unregister previously registered {@link AsyncDrawableSpan}
* (if there are such spans in this TextView at this point). Or {@link CorePlugin}
* which measures ordered list numbers
**/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also noticed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'm pretty sure |
||
super.bind(holder) | ||
holder.messageView.movementMethod = movementMethod | ||
renderSendState(holder.messageView, holder.messageView) | ||
holder.messageView.onClick(attributes.itemClickListener) | ||
holder.messageView.onLongClickIgnoringLinks(attributes.itemLongClickListener) | ||
holder.messageView.setTextWithEmojiSupport(message?.charSequence, bindingOptions) | ||
markwonPlugins?.forEach { plugin -> plugin.afterSetText(holder.messageView) } | ||
} | ||
|
||
if (bindingOptions?.canUseTextFuture.orFalse()) { | ||
holder.messageView.setTextFuture(textFuture) | ||
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 { | ||
holder.messageView.text = message?.charSequence | ||
text = message | ||
} | ||
markwonPlugins?.forEach { plugin -> plugin.afterSetText(holder.messageView) } | ||
} | ||
|
||
override fun unbind(holder: Holder) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering why we coputed that before the next line... Maybe there were a good reason, I do not remember