mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-17 21:22:24 -05:00
improved ordering of muc participants
This commit is contained in:
parent
61726f4994
commit
b478eca315
@ -133,7 +133,7 @@ public class MucOptions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class User {
|
public static class User implements Comparable<User> {
|
||||||
private Role role = Role.NONE;
|
private Role role = Role.NONE;
|
||||||
private Affiliation affiliation = Affiliation.NONE;
|
private Affiliation affiliation = Affiliation.NONE;
|
||||||
private Jid realJid;
|
private Jid realJid;
|
||||||
@ -222,7 +222,13 @@ public class MucOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Contact getContact() {
|
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) {
|
public boolean setAvatar(Avatar avatar) {
|
||||||
@ -278,6 +284,21 @@ public class MucOptions {
|
|||||||
public boolean realJidMatchesAccount() {
|
public boolean realJidMatchesAccount() {
|
||||||
return realJid != null && realJid.equals(options.account.getJid().toBareJid());
|
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;
|
private Account account;
|
||||||
|
@ -83,7 +83,7 @@ public abstract class AbstractParser {
|
|||||||
fullJid = null;
|
fullJid = null;
|
||||||
}
|
}
|
||||||
Jid realJid = item.getAttributeAsJid("jid");
|
Jid realJid = item.getAttributeAsJid("jid");
|
||||||
MucOptions.User user = new MucOptions.User(conference.getMucOptions(), fullJid);
|
MucOptions.User user = new MucOptions.User(conference.getMucOptions(), nick == null ? null : fullJid);
|
||||||
user.setRealJid(realJid);
|
user.setRealJid(realJid);
|
||||||
user.setAffiliation(affiliation);
|
user.setAffiliation(affiliation);
|
||||||
user.setRole(role);
|
user.setRole(role);
|
||||||
|
@ -579,12 +579,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
membersView.removeAllViews();
|
membersView.removeAllViews();
|
||||||
final ArrayList<User> users = mucOptions.getUsers();
|
final ArrayList<User> users = mucOptions.getUsers();
|
||||||
Collections.sort(users,new Comparator<User>() {
|
Collections.sort(users);
|
||||||
@Override
|
|
||||||
public int compare(User l, User r) {
|
|
||||||
return l.getName() == null || r.getName() == null ? 0 : l.getName().compareToIgnoreCase(r.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (final User user : users) {
|
for (final User user : users) {
|
||||||
View view = inflater.inflate(R.layout.contact, membersView,false);
|
View view = inflater.inflate(R.layout.contact, membersView,false);
|
||||||
this.setListItemBackgroundOnView(view);
|
this.setListItemBackgroundOnView(view);
|
||||||
|
Loading…
Reference in New Issue
Block a user