From bc8915cc3f270142f0ee8860aba118ce9ca13a0b Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Fri, 2 Mar 2018 00:22:36 +0100 Subject: [PATCH] Trying to fix a message color bug --- .../util/irc/format/IrcFormatSerializer.kt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/util/irc/format/IrcFormatSerializer.kt b/app/src/main/java/de/kuschku/quasseldroid_ng/util/irc/format/IrcFormatSerializer.kt index 294c09789..ced8e7699 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/util/irc/format/IrcFormatSerializer.kt +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/util/irc/format/IrcFormatSerializer.kt @@ -134,19 +134,19 @@ class IrcFormatSerializer internal constructor(private val context: Context) { if (text.getSpanFlags(aStyle) and Spanned.SPAN_COMPOSING != 0) continue - if (aStyle is StyleSpan) { - afterBold = (aStyle.style and Typeface.BOLD != 0) - afterItalic = (aStyle.style and Typeface.ITALIC != 0) - } else if (aStyle is UnderlineSpan) { - afterUnderline = true - } else if (aStyle is StrikethroughSpan) { - afterStrikethrough = true - } else if (aStyle is TypefaceSpan) { - afterMonospace = aStyle.family == "monospace" - } else if (aStyle is ForegroundColorSpan) { - afterForeground = aStyle.foregroundColor - } else if (aStyle is BackgroundColorSpan) { - afterBackground = aStyle.backgroundColor + if (text.getSpanEnd(aStyle) <= i) + continue + + when (aStyle) { + is StyleSpan -> { + afterBold = (aStyle.style and Typeface.BOLD != 0) + afterItalic = (aStyle.style and Typeface.ITALIC != 0) + } + is UnderlineSpan -> afterUnderline = true + is StrikethroughSpan -> afterStrikethrough = true + is TypefaceSpan -> afterMonospace = aStyle.family == "monospace" + is ForegroundColorSpan -> afterForeground = aStyle.foregroundColor + is BackgroundColorSpan -> afterBackground = aStyle.backgroundColor } } -- GitLab