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();
}
Aggregations