From 9ba5335ae7001dbc88b3a98b922c983669965da3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 6 Mar 2017 19:06:16 +0100 Subject: [PATCH] cleaned code of muc name generator --- .../siacs/conversations/entities/MucOptions.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index bee5fa44..3b1b64f9 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -598,20 +598,16 @@ public class MucOptions { public String createNameFromParticipants() { if (getUserCount() >= 2) { - List names = new ArrayList<>(); + StringBuilder builder = new StringBuilder(); for (User user : getUsers(5)) { + if (builder.length() != 0) { + builder.append(", "); + } Contact contact = user.getContact(); if (contact != null && !contact.getDisplayName().isEmpty()) { - names.add(contact.getDisplayName().split("\\s+")[0]); + builder.append(contact.getDisplayName().split("\\s+")[0]); } else if (user.getName() != null){ - names.add(user.getName()); - } - } - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < names.size(); ++i) { - builder.append(names.get(i)); - if (i != names.size() - 1) { - builder.append(", "); + builder.append(user.getName()); } } return builder.toString();