Add some comments and default values

This commit is contained in:
Benoit Marty 2021-12-13 20:34:44 +01:00
parent 78a7a61d07
commit 6e646b12b5
2 changed files with 7 additions and 8 deletions

View File

@ -17,6 +17,8 @@
package im.vector.app.features.home.room.detail.timeline.item
data class BindingOptions(
val canUseTextFuture: Boolean,
val preventMutation: Boolean
// Allowed by default
val canUseTextFuture: Boolean = true,
// No need to prevent mutation by default
val preventMutation: Boolean = false
)

View File

@ -30,15 +30,12 @@ class SpanUtils @Inject constructor() {
val emojiCharSequence = EmojiCompat.get().process(charSequence)
if (emojiCharSequence !is Spanned) {
return BindingOptions(
canUseTextFuture = true,
preventMutation = false
)
return BindingOptions()
}
return BindingOptions(
canUseTextFuture = canUseTextFuture(emojiCharSequence),
preventMutation = preventMutation(emojiCharSequence)
preventMutation = mustPreventMutation(emojiCharSequence)
)
}
@ -55,7 +52,7 @@ class SpanUtils @Inject constructor() {
}
// Workaround for setting text during binding which mutate the text itself
private fun preventMutation(spanned: Spanned): Boolean {
private fun mustPreventMutation(spanned: Spanned): Boolean {
return spanned
.getSpans(0, spanned.length, Any::class.java)
.any { it is MetricAffectingSpan }