mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +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
|
||||
|
||||
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
|
||||
)
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in a new issue