Fix contacts duplication

This commit is contained in:
Erwan Croze 2018-06-04 11:33:18 +02:00
parent c7640ab1d4
commit 99dd1167a5
3 changed files with 23 additions and 1 deletions

View file

@ -264,7 +264,15 @@ public class ContactsManager extends ContentObserver {
}
public synchronized void setContacts(List<LinphoneContact> c) {
contacts = c;
if (contacts.isEmpty()) {
contacts = c;
} else {
for (LinphoneContact contact : c) {
if (!contacts.contains(contact)) {
contacts.add(contact);
}
}
}
}
public synchronized void setSipContacts(List<LinphoneContact> c) {

View file

@ -75,6 +75,13 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
return fullName.compareTo(contactFullName);
}
@Override
public boolean equals(Object obj) {
if (obj.getClass() != LinphoneContact.class) return false;
LinphoneContact contact = (LinphoneContact) obj;
return (this.compareTo(contact) == 0);
}
public void setFullName(String name) {
fullName = name;
}

View file

@ -47,6 +47,13 @@ public class LinphoneNumberOrAddress implements Serializable, Comparable<Linphon
}
}
@Override
public boolean equals(Object obj) {
if (obj.getClass() != LinphoneNumberOrAddress.class) return false;
LinphoneNumberOrAddress noa = (LinphoneNumberOrAddress) obj;
return (this.compareTo(noa) == 0);
}
public boolean isSIPAddress() {
return isSIPAddress;
}