Search in sources :

Example 21 with ContactChanges

use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.

the class DownloadServerContacts method syncContactChangesPage.

/**
 * Processes the response from the server. First separates new contacts from
 * existing ones, this is to optimise adding new contacts during first time
 * sync.
 *
 * @param changes The contact change information received from the server
 * @return SUCCESS or a suitable error code
 */
private ServiceStatus syncContactChangesPage(ContactChanges changes) {
    mContactsChangedList.clear();
    int i = 0;
    for (Contact contact : changes.mContacts) {
        i += 1;
        updateProgressUi(contact, i);
        if (Settings.ENABLED_CONTACTS_SYNC_TRACE) {
            if (contact.details.size() == 0 || contact.deleted != null) {
                LogUtils.logD("Contact In: " + contact.contactID + ", Del: " + contact.deleted + ", details: " + contact.details.size());
            }
            for (ContactDetail detail : contact.details) {
                LogUtils.logD("Contact In: " + contact.contactID + ", Detail: " + detail.key + ", " + detail.unique_id + ", " + detail.keyType + " = " + detail.value + ", del = " + detail.deleted);
            }
        }
        if (mServerIdSet.contains(contact.contactID)) {
            mContactsChangedList.add(contact);
        } else {
            if (contact.deleted != null && contact.deleted.booleanValue()) {
                if (EXTRA_DEBUG_TRACE) {
                    LogUtils.logD("DownloadServerContacts.syncDownContact() " + "Delete Contact (nothing to do) " + contact.contactID);
                }
            } else if (contact.details.size() > 0) {
                if (EXTRA_DEBUG_TRACE) {
                    LogUtils.logD("DownloadServerContacts.syncDownContact() Adding " + contact.contactID);
                }
                mAddContactList.add(contact);
                mSyncDataPending = true;
            } else {
                if (EXTRA_DEBUG_TRACE) {
                    LogUtils.logD("DownloadServerContacts.syncDownContact() Empty " + contact.contactID);
                }
            }
        }
    }
    if (mSyncDataPending || mContactsChangedList.size() > 0) {
        setTimeout(TIMEOUT_BETWEEN_PAGES_MS);
    }
    return ServiceStatus.SUCCESS;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) Contact(com.vodafone360.people.datatypes.Contact)

Aggregations

Contact (com.vodafone360.people.datatypes.Contact)15 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)15 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)11 ServiceStatus (com.vodafone360.people.service.ServiceStatus)7 ArrayList (java.util.ArrayList)5 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)2 NativeContactsApi (com.vodafone360.people.engine.contactsync.NativeContactsApi)2 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)1 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)1 ContactDetailDeletion (com.vodafone360.people.datatypes.ContactDetailDeletion)1 ContactListResponse (com.vodafone360.people.datatypes.ContactListResponse)1 Conversation (com.vodafone360.people.datatypes.Conversation)1 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)1 IdentityDeletion (com.vodafone360.people.datatypes.IdentityDeletion)1 ItemList (com.vodafone360.people.datatypes.ItemList)1 PresenceList (com.vodafone360.people.datatypes.PresenceList)1 SimpleText (com.vodafone360.people.datatypes.SimpleText)1 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)1 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)1 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)1