Fix contacts management
This commit is contained in:
parent
07fe05e532
commit
d2ede2973d
2 changed files with 6 additions and 6 deletions
|
@ -264,7 +264,7 @@ public class ContactsManager extends ContentObserver {
|
|||
}
|
||||
|
||||
public synchronized void setContacts(List<LinphoneContact> c) {
|
||||
if (contacts.isEmpty()) {
|
||||
if (contacts.isEmpty() || contacts.size() > c.size()) {
|
||||
contacts = c;
|
||||
} else {
|
||||
for (LinphoneContact contact : c) {
|
||||
|
@ -273,10 +273,11 @@ public class ContactsManager extends ContentObserver {
|
|||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(contacts);
|
||||
}
|
||||
|
||||
public synchronized void setSipContacts(List<LinphoneContact> c) {
|
||||
if (sipContacts.isEmpty()) {
|
||||
if (sipContacts.isEmpty() || sipContacts.size() > c.size()) {
|
||||
sipContacts = c;
|
||||
} else {
|
||||
for (LinphoneContact contact : c) {
|
||||
|
@ -285,6 +286,7 @@ public class ContactsManager extends ContentObserver {
|
|||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(sipContacts);
|
||||
}
|
||||
|
||||
public synchronized void refreshSipContact(Friend lf) {
|
||||
|
@ -466,8 +468,6 @@ public class ContactsManager extends ContentObserver {
|
|||
Log.w("[Permission] Read contacts permission wasn't granted, only fetch Friends");
|
||||
}
|
||||
|
||||
Collections.sort(contacts);
|
||||
Collections.sort(sipContacts);
|
||||
setContacts(contacts);
|
||||
setSipContacts(sipContacts);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class LinphoneNumberOrAddress implements Serializable, Comparable<Linphon
|
|||
|
||||
@Override
|
||||
public int compareTo(LinphoneNumberOrAddress noa) {
|
||||
if (noa.isSIPAddress() == isSIPAddress()) {
|
||||
if (noa.isSIPAddress() == isSIPAddress() && noa.getValue() != null) {
|
||||
return noa.getValue().compareTo(getValue());
|
||||
} else {
|
||||
return isSIPAddress() ? -1 : 1;
|
||||
|
@ -51,7 +51,7 @@ public class LinphoneNumberOrAddress implements Serializable, Comparable<Linphon
|
|||
public boolean equals(Object obj) {
|
||||
if (obj.getClass() != LinphoneNumberOrAddress.class) return false;
|
||||
LinphoneNumberOrAddress noa = (LinphoneNumberOrAddress) obj;
|
||||
return (this.compareTo(noa) == 0);
|
||||
return (this != null && this.compareTo(noa) == 0);
|
||||
}
|
||||
|
||||
public boolean isSIPAddress() {
|
||||
|
|
Loading…
Reference in a new issue