Search in sources :

Example 1 with JabberIdContact

use of eu.siacs.conversations.android.JabberIdContact in project Conversations by siacs.

the class XmppConnectionService method loadPhoneContacts.

public void loadPhoneContacts() {
    mContactMergerExecutor.execute(() -> {
        Map<Jid, JabberIdContact> contacts = JabberIdContact.load(this);
        Log.d(Config.LOGTAG, "start merging phone contacts with roster");
        for (Account account : accounts) {
            List<Contact> withSystemAccounts = account.getRoster().getWithSystemAccounts(JabberIdContact.class);
            for (JabberIdContact jidContact : contacts.values()) {
                final Contact contact = account.getRoster().getContact(jidContact.getJid());
                boolean needsCacheClean = contact.setPhoneContact(jidContact);
                if (needsCacheClean) {
                    getAvatarService().clear(contact);
                }
                withSystemAccounts.remove(contact);
            }
            for (Contact contact : withSystemAccounts) {
                boolean needsCacheClean = contact.unsetPhoneContact(JabberIdContact.class);
                if (needsCacheClean) {
                    getAvatarService().clear(contact);
                }
            }
        }
        Log.d(Config.LOGTAG, "finished merging phone contacts");
        mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true));
        updateRosterUi();
        mQuickConversationsService.considerSync();
    });
}
Also used : Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.Jid) JabberIdContact(eu.siacs.conversations.android.JabberIdContact) Contact(eu.siacs.conversations.entities.Contact) JabberIdContact(eu.siacs.conversations.android.JabberIdContact)

Aggregations

JabberIdContact (eu.siacs.conversations.android.JabberIdContact)1 Account (eu.siacs.conversations.entities.Account)1 Contact (eu.siacs.conversations.entities.Contact)1 Jid (eu.siacs.conversations.xmpp.Jid)1