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 294c097896992b260e9a67c27d0fe7cc55ee2235..ced8e76992a33b252618bb1fb02343671c7367a0 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 } }