Fix crash (" ".split("\\s+") is empty array)
2 files changed, 7 insertions(+), 3 deletions(-) M src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java M src/main/java/eu/siacs/conversations/utils/UIHelper.java
M src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java => src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +3 -2
@@ 204,8 204,9 @@ public class ConversationAdapter if (message.getStatus() == Message.STATUS_RECEIVED) { if (conversation.getMode() == Conversation.MODE_MULTI) { viewHolder.binding.senderName.setVisibility(View.VISIBLE); viewHolder.binding.senderName.setText( UIHelper.getMessageDisplayName(message).split("\\s+")[0] + ':'); final String dname = UIHelper.getMessageDisplayName(message); final String[] words = dname.split("\\s+"); viewHolder.binding.senderName.setText((words.length > 0 ? words[0] : dname) + ':'); } else { viewHolder.binding.senderName.setVisibility(View.GONE); }
M src/main/java/eu/siacs/conversations/utils/UIHelper.java => src/main/java/eu/siacs/conversations/utils/UIHelper.java +4 -1
@@ 542,7 542,10 @@ public class UIHelper { } else { if (conversation instanceof Conversation) { final MucOptions.User user = ((Conversation) conversation).getMucOptions().findUserByFullJid(message.getCounterpart()); if (user != null) return getDisplayName(user); if (user != null) { final String dname = getDisplayName(user); if (dname != null) return dname; } } return getDisplayedMucCounterpart(message.getCounterpart()); }