diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-05-17 15:01:56 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-05-17 15:01:56 +0200 |
commit | b478eca315661c50d76052aafcbbcc041790300f (patch) | |
tree | 8cd3c535f8b4852cd151704fbaf176b124b7dea5 /src/main/java/eu/siacs/conversations/entities | |
parent | 61726f4994dffad0407bbc9dc539874ce9f79171 (diff) |
improved ordering of muc participants
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/MucOptions.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 8d7c5adbd..d26ecd7c1 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -133,7 +133,7 @@ public class MucOptions { } - public static class User { + public static class User implements Comparable<User> { private Role role = Role.NONE; private Affiliation affiliation = Affiliation.NONE; private Jid realJid; @@ -222,7 +222,13 @@ public class MucOptions { } public Contact getContact() { - return getAccount().getRoster().getContactFromRoster(getRealJid()); + if (fullJid != null) { + return getAccount().getRoster().getContactFromRoster(realJid); + } else if (realJid != null){ + return getAccount().getRoster().getContact(realJid); + } else { + return null; + } } public boolean setAvatar(Avatar avatar) { @@ -278,6 +284,21 @@ public class MucOptions { public boolean realJidMatchesAccount() { return realJid != null && realJid.equals(options.account.getJid().toBareJid()); } + + @Override + public int compareTo(User another) { + 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()); + } + } } private Account account; |