Fixed presence issue in contacts list after contact has been added, removed or edited
This commit is contained in:
parent
339d58e51f
commit
9ff8d854ae
2 changed files with 15 additions and 13 deletions
|
@ -34,6 +34,7 @@ import android.widget.TextView;
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.SelectableAdapter;
|
import org.linphone.ui.SelectableAdapter;
|
||||||
import org.linphone.ui.SelectableHelper;
|
import org.linphone.ui.SelectableHelper;
|
||||||
|
|
||||||
|
|
|
@ -414,8 +414,8 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
LinphoneContact contact = (LinphoneContact) friend.getUserData();
|
LinphoneContact contact = (LinphoneContact) friend.getUserData();
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
contact.clearAddresses();
|
contact.clearAddresses();
|
||||||
contacts.add(contact);
|
|
||||||
if (contact.getAndroidId() != null) {
|
if (contact.getAndroidId() != null) {
|
||||||
|
contacts.add(contact);
|
||||||
mAndroidContactsCache.put(contact.getAndroidId(), contact);
|
mAndroidContactsCache.put(contact.getAndroidId(), contact);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -428,11 +428,11 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
contact.setFriend(friend);
|
contact.setFriend(friend);
|
||||||
contact.refresh();
|
contact.refresh();
|
||||||
contacts.add(contact);
|
contacts.add(contact);
|
||||||
|
if (contact.hasAddress()) {
|
||||||
|
sipContacts.add(contact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (contact != null && contact.hasAddress()) {
|
|
||||||
sipContacts.add(contact);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,14 +447,13 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
String data2 = c.getString(c.getColumnIndex("data2"));
|
String data2 = c.getString(c.getColumnIndex("data2"));
|
||||||
String data3 = c.getString(c.getColumnIndex("data3"));
|
String data3 = c.getString(c.getColumnIndex("data3"));
|
||||||
|
|
||||||
|
nativeIds.add(id);
|
||||||
boolean created = false;
|
boolean created = false;
|
||||||
LinphoneContact contact = mAndroidContactsCache.get(id);
|
LinphoneContact contact = mAndroidContactsCache.get(id);
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
created = true;
|
created = true;
|
||||||
contact = new LinphoneContact();
|
contact = new LinphoneContact();
|
||||||
contact.setAndroidId(id);
|
contact.setAndroidId(id);
|
||||||
nativeIds.add(id);
|
|
||||||
contact.setFullName(displayName);
|
contact.setFullName(displayName);
|
||||||
mAndroidContactsCache.put(id, contact);
|
mAndroidContactsCache.put(id, contact);
|
||||||
}
|
}
|
||||||
|
@ -477,14 +476,16 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (LinphoneContact contact : mAndroidContactsCache.values()) {
|
for (FriendList list : lc.getFriendsLists()) {
|
||||||
String id = contact.getAndroidId();
|
for (Friend friend : list.getFriends()) {
|
||||||
if (id != null && !nativeIds.contains(id)) {
|
LinphoneContact contact = (LinphoneContact) friend.getUserData();
|
||||||
// Has been removed since last fetch
|
if (contact != null && contact.isAndroidContact()) {
|
||||||
for (FriendList list : lc.getFriendsLists()) {
|
String id = contact.getAndroidId();
|
||||||
list.removeFriend(contact.getFriend());
|
if (id != null && !nativeIds.contains(id)) {
|
||||||
|
// Has been removed since last fetch
|
||||||
|
contacts.remove(contact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
contacts.remove(contact);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nativeIds.clear();
|
nativeIds.clear();
|
||||||
|
|
Loading…
Reference in a new issue