aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-06-14 14:41:32 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-06-14 14:41:32 +0200
commitf9600b950fb8a038e8ebd325454b10e163202b82 (patch)
treeeafa5b7f404f06d5c40c111fd076ca48569c5c04
parent95a51ea2e07101b7c5e5643a9e66d34874b7c880 (diff)
sort muc users by affiliation, name. fixes #1913
-rw-r--r--src/main/java/eu/siacs/conversations/entities/MucOptions.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
index c71afd99..6f6cdf91 100644
--- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
@@ -296,16 +296,22 @@ public class MucOptions {
@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());
+ if (another.getAffiliation().outranks(getAffiliation())) {
+ return 1;
+ } else if (getAffiliation().outranks(another.getAffiliation())) {
+ return -1;
} else {
- return getName().compareToIgnoreCase(another.getName());
+ 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());
+ }
}
}