cleaned code of muc name generator

This commit is contained in:
Daniel Gultsch 2017-03-06 19:06:16 +01:00
parent 1c56b74e41
commit 9ba5335ae7
1 changed files with 6 additions and 10 deletions

View File

@ -598,20 +598,16 @@ public class MucOptions {
public String createNameFromParticipants() { public String createNameFromParticipants() {
if (getUserCount() >= 2) { if (getUserCount() >= 2) {
List<String> names = new ArrayList<>(); StringBuilder builder = new StringBuilder();
for (User user : getUsers(5)) { for (User user : getUsers(5)) {
if (builder.length() != 0) {
builder.append(", ");
}
Contact contact = user.getContact(); Contact contact = user.getContact();
if (contact != null && !contact.getDisplayName().isEmpty()) { 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){ } else if (user.getName() != null){
names.add(user.getName()); builder.append(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(", ");
} }
} }
return builder.toString(); return builder.toString();