Don't crash on empty message

If the message is empty, m.last() causes a NoSuchElementException.
Fixes https://github.com/SpiritCroc/SchildiChat-android/issues/17

Change-Id: I31ad5a8e4f8baf5d095cf34f430c5337737442b4
This commit is contained in:
SpiritCroc 2020-09-30 10:41:15 +02:00
parent 1cc4c7177f
commit 68ed05ae7f
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
message?.findPillsAndProcess(coroutineScope) { it.bind(holder.messageView) } message?.findPillsAndProcess(coroutineScope) { it.bind(holder.messageView) }
} }
var m = message var m = message
if (m != null) { if (m != null && m.isNotEmpty()) {
// Remove last trailing newline: looks especially bad in message bubble // Remove last trailing newline: looks especially bad in message bubble
if (m.last() == '\n') { if (m.last() == '\n') {
m = m.subSequence(0, m.length-1) m = m.subSequence(0, m.length-1)