make fetching some fields optional, used only at exporting
This commit is contained in:
parent
f81700c120
commit
7f11945af4
|
@ -358,7 +358,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
FilePickerDialog(this, pickFile = false, showFAB = true) {
|
||||
ExportContactsDialog(this, it) { file, contactSources ->
|
||||
Thread {
|
||||
ContactsHelper(this).getContacts {
|
||||
ContactsHelper(this).getContacts(true) {
|
||||
val contacts = it.filter { contactSources.contains(it.source) }
|
||||
if (contacts.isEmpty()) {
|
||||
toast(R.string.no_entries_for_exporting)
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.simplemobiletools.contacts.extensions.getPhotoThumbnailSize
|
|||
import com.simplemobiletools.contacts.models.*
|
||||
|
||||
class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||
fun getContacts(callback: (ArrayList<Contact>) -> Unit) {
|
||||
fun getContacts(addOptionalFields: Boolean = false, callback: (ArrayList<Contact>) -> Unit) {
|
||||
val contacts = SparseArray<Contact>()
|
||||
Thread {
|
||||
val uri = ContactsContract.Data.CONTENT_URI
|
||||
|
@ -75,22 +75,22 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
||||
}
|
||||
|
||||
val emails = getEmails()
|
||||
size = emails.size()
|
||||
for (i in 0 until size) {
|
||||
val key = emails.keyAt(i)
|
||||
contacts[key]?.emails = emails.valueAt(i)
|
||||
}
|
||||
if (addOptionalFields) {
|
||||
val emails = getEmails()
|
||||
size = emails.size()
|
||||
for (i in 0 until size) {
|
||||
val key = emails.keyAt(i)
|
||||
contacts[key]?.emails = emails.valueAt(i)
|
||||
}
|
||||
|
||||
val addresses = getAddresses()
|
||||
size = addresses.size()
|
||||
for (i in 0 until size) {
|
||||
val key = addresses.keyAt(i)
|
||||
contacts[key]?.addresses = addresses.valueAt(i)
|
||||
val addresses = getAddresses()
|
||||
size = addresses.size()
|
||||
for (i in 0 until size) {
|
||||
val key = addresses.keyAt(i)
|
||||
contacts[key]?.addresses = addresses.valueAt(i)
|
||||
}
|
||||
}
|
||||
|
||||
//getNotes()
|
||||
|
||||
activity.dbHelper.getContacts().forEach {
|
||||
contacts.put(it.id, it)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue