diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-07-04 19:30:19 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-07-04 19:30:19 +0200 |
commit | cdee91363c11b2eae920f7ebf443c022674fbb2c (patch) | |
tree | 23cb7fbf2978ed2a0faaa5f213508113202184cb /src/main | |
parent | ac8aa639164956cb2a9307df958a53d3423c4616 (diff) |
simplified muc users ordering
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/MucOptions.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index ec21ab80..0ae8b279 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -301,17 +301,18 @@ public class MucOptions { } else if (getAffiliation().outranks(another.getAffiliation())) { return -1; } else { - Contact ourContact = getContact(); - Contact anotherContact = another.getContact(); - if (ourContact != null && anotherContact != null) { - return ourContact.compareTo(anotherContact); - } else if (ourContact == null && anotherContact != null) { - return getName().compareToIgnoreCase(anotherContact.getDisplayName()); - } else if (ourContact != null) { - return ourContact.getDisplayName().compareToIgnoreCase(another.getName()); - } else { - return getName().compareToIgnoreCase(another.getName()); - } + return getComparableName().compareToIgnoreCase(another.getComparableName()); + } + } + + + private String getComparableName() { + Contact contact = getContact(); + if (contact != null) { + return contact.getDisplayName(); + } else { + String name = getName(); + return name == null ? "" : name; } } |