Improved sorting & listener calls on presence received
This commit is contained in:
parent
012a31cf49
commit
a88fe1f8f2
1 changed files with 12 additions and 6 deletions
|
@ -403,21 +403,18 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
if (lf.hasCapability(FriendCapability.GroupChat)
|
if (lf.hasCapability(FriendCapability.GroupChat)
|
||||||
&& !mGroupChatContacts.contains(contact)) {
|
&& !mGroupChatContacts.contains(contact)) {
|
||||||
mGroupChatContacts.add(contact);
|
mGroupChatContacts.add(contact);
|
||||||
Collections.sort(mGroupChatContacts);
|
|
||||||
Log.i("[Contacts Manager] Contact " + contact + " has group chat capability");
|
Log.i("[Contacts Manager] Contact " + contact + " has group chat capability");
|
||||||
|
|
||||||
// Contact may only have LimeX3DH capability if it already has GroupChat capability
|
// Contact may only have LimeX3DH capability if it already has GroupChat capability
|
||||||
if (lf.hasCapability(FriendCapability.LimeX3Dh)
|
if (lf.hasCapability(FriendCapability.LimeX3Dh)
|
||||||
&& !mLimeX3dhContacts.contains(contact)) {
|
&& !mLimeX3dhContacts.contains(contact)) {
|
||||||
mLimeX3dhContacts.add(contact);
|
mLimeX3dhContacts.add(contact);
|
||||||
Collections.sort(mLimeX3dhContacts);
|
|
||||||
Log.i("[Contacts Manager] Contact " + contact + " has lime x3dh capability");
|
Log.i("[Contacts Manager] Contact " + contact + " has lime x3dh capability");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSipContacts.contains(contact)) {
|
if (!mSipContacts.contains(contact)) {
|
||||||
mSipContacts.add(contact);
|
mSipContacts.add(contact);
|
||||||
Collections.sort(mSipContacts);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,12 +465,21 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPresenceReceived(FriendList list, Friend[] friends) {
|
public void onPresenceReceived(FriendList list, Friend[] friends) {
|
||||||
|
boolean updated = false;
|
||||||
for (Friend lf : friends) {
|
for (Friend lf : friends) {
|
||||||
boolean newContact = ContactsManager.getInstance().refreshSipContact(lf);
|
boolean newContact = ContactsManager.getInstance().refreshSipContact(lf);
|
||||||
if (newContact) {
|
if (newContact) {
|
||||||
for (ContactsUpdatedListener listener : mContactsUpdatedListeners) {
|
updated = true;
|
||||||
listener.onContactsUpdated();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updated) {
|
||||||
|
Collections.sort(mSipContacts);
|
||||||
|
Collections.sort(mGroupChatContacts);
|
||||||
|
Collections.sort(mLimeX3dhContacts);
|
||||||
|
|
||||||
|
for (ContactsUpdatedListener listener : mContactsUpdatedListeners) {
|
||||||
|
listener.onContactsUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue