mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Add some comments and default values
This commit is contained in:
parent
78a7a61d07
commit
6e646b12b5
2 changed files with 7 additions and 8 deletions
|
@ -17,6 +17,8 @@
|
||||||
package im.vector.app.features.home.room.detail.timeline.item
|
package im.vector.app.features.home.room.detail.timeline.item
|
||||||
|
|
||||||
data class BindingOptions(
|
data class BindingOptions(
|
||||||
val canUseTextFuture: Boolean,
|
// Allowed by default
|
||||||
val preventMutation: Boolean
|
val canUseTextFuture: Boolean = true,
|
||||||
|
// No need to prevent mutation by default
|
||||||
|
val preventMutation: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
|
@ -30,15 +30,12 @@ class SpanUtils @Inject constructor() {
|
||||||
val emojiCharSequence = EmojiCompat.get().process(charSequence)
|
val emojiCharSequence = EmojiCompat.get().process(charSequence)
|
||||||
|
|
||||||
if (emojiCharSequence !is Spanned) {
|
if (emojiCharSequence !is Spanned) {
|
||||||
return BindingOptions(
|
return BindingOptions()
|
||||||
canUseTextFuture = true,
|
|
||||||
preventMutation = false
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return BindingOptions(
|
return BindingOptions(
|
||||||
canUseTextFuture = canUseTextFuture(emojiCharSequence),
|
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
|
// 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
|
return spanned
|
||||||
.getSpans(0, spanned.length, Any::class.java)
|
.getSpans(0, spanned.length, Any::class.java)
|
||||||
.any { it is MetricAffectingSpan }
|
.any { it is MetricAffectingSpan }
|
||||||
|
|
Loading…
Reference in a new issue