sort muc users by affiliation, name. fixes #1913

This commit is contained in:
Daniel Gultsch 2016-06-14 14:41:32 +02:00
parent 95a51ea2e0
commit f9600b950f
1 changed files with 15 additions and 9 deletions

View File

@ -296,16 +296,22 @@ public class MucOptions {
@Override @Override
public int compareTo(User another) { public int compareTo(User another) {
Contact ourContact = getContact(); if (another.getAffiliation().outranks(getAffiliation())) {
Contact anotherContact = another.getContact(); return 1;
if (ourContact != null && anotherContact != null) { } else if (getAffiliation().outranks(another.getAffiliation())) {
return ourContact.compareTo(anotherContact); return -1;
} else if (ourContact == null && anotherContact != null) {
return getName().compareToIgnoreCase(anotherContact.getDisplayName());
} else if (ourContact != null) {
return ourContact.getDisplayName().compareToIgnoreCase(another.getName());
} else { } 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());
}
} }
} }