Search in sources :

Example 6 with PhoneBookContact

use of im.actor.core.entity.PhoneBookContact in project actor-platform by actorapp.

the class BookImportActor method onPhoneBookLoaded.

private void onPhoneBookLoaded(List<PhoneBookContact> phoneBook) {
    phoneBookReadingIsInProgress = false;
    if (ENABLE_LOG) {
        Log.d(TAG, "Book load completed");
    }
    int newPhones = 0;
    int newEmails = 0;
    for (PhoneBookContact record : phoneBook) {
        for (PhoneBookPhone phone : record.getPhones()) {
            if (storage.isImported(phone.getNumber())) {
                continue;
            }
            if (importingPhones.contains(phone.getNumber())) {
                continue;
            }
            importingPhones.add(phone.getNumber());
            importQueue.add(new ImportPhoneQueueItem(phone.getNumber(), record.getName()));
            newPhones++;
        }
        for (PhoneBookEmail email : record.getEmails()) {
            if (storage.isImported(email.getEmail().toLowerCase())) {
                continue;
            }
            if (importingEmails.contains(email.getEmail().toLowerCase())) {
                continue;
            }
            importingEmails.add(email.getEmail().toLowerCase());
            importQueue.add(new ImportEmailQueueItem(email.getEmail().toLowerCase(), record.getName()));
            newEmails++;
        }
    }
    if (ENABLE_LOG) {
        if (newPhones == 0 && newEmails == 0) {
            Log.d(TAG, "No new contacts found");
        } else {
            Log.d(TAG, "Founded new " + (newPhones + newEmails) + " contact records");
        }
    }
    performImportIfRequired();
}
Also used : PhoneBookContact(im.actor.core.entity.PhoneBookContact) PhoneBookEmail(im.actor.core.entity.PhoneBookEmail) PhoneBookPhone(im.actor.core.entity.PhoneBookPhone)

Aggregations

PhoneBookContact (im.actor.core.entity.PhoneBookContact)6 PhoneBookEmail (im.actor.core.entity.PhoneBookEmail)3 PhoneBookPhone (im.actor.core.entity.PhoneBookPhone)3 ArrayList (java.util.ArrayList)2 ContentResolver (android.content.ContentResolver)1 DialogInterface (android.content.DialogInterface)1 Cursor (android.database.Cursor)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1 TextView (android.widget.TextView)1 NumberParseException (com.google.i18n.phonenumbers.NumberParseException)1 Phonenumber (com.google.i18n.phonenumbers.Phonenumber)1 ApiAvatar (im.actor.core.api.ApiAvatar)1 ApiBotCommand (im.actor.core.api.ApiBotCommand)1 ApiContactRecord (im.actor.core.api.ApiContactRecord)1 ApiMapValue (im.actor.core.api.ApiMapValue)1 ApiUser (im.actor.core.api.ApiUser)1 ApiUserOutPeer (im.actor.core.api.ApiUserOutPeer)1 RequestLoadFullUsers (im.actor.core.api.rpc.RequestLoadFullUsers)1 ResponseLoadFullUsers (im.actor.core.api.rpc.ResponseLoadFullUsers)1