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) {
|
FilePickerDialog(this, pickFile = false, showFAB = true) {
|
||||||
ExportContactsDialog(this, it) { file, contactSources ->
|
ExportContactsDialog(this, it) { file, contactSources ->
|
||||||
Thread {
|
Thread {
|
||||||
ContactsHelper(this).getContacts {
|
ContactsHelper(this).getContacts(true) {
|
||||||
val contacts = it.filter { contactSources.contains(it.source) }
|
val contacts = it.filter { contactSources.contains(it.source) }
|
||||||
if (contacts.isEmpty()) {
|
if (contacts.isEmpty()) {
|
||||||
toast(R.string.no_entries_for_exporting)
|
toast(R.string.no_entries_for_exporting)
|
||||||
|
|
|
@ -29,7 +29,7 @@ import com.simplemobiletools.contacts.extensions.getPhotoThumbnailSize
|
||||||
import com.simplemobiletools.contacts.models.*
|
import com.simplemobiletools.contacts.models.*
|
||||||
|
|
||||||
class ContactsHelper(val activity: BaseSimpleActivity) {
|
class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
fun getContacts(callback: (ArrayList<Contact>) -> Unit) {
|
fun getContacts(addOptionalFields: Boolean = false, callback: (ArrayList<Contact>) -> Unit) {
|
||||||
val contacts = SparseArray<Contact>()
|
val contacts = SparseArray<Contact>()
|
||||||
Thread {
|
Thread {
|
||||||
val uri = ContactsContract.Data.CONTENT_URI
|
val uri = ContactsContract.Data.CONTENT_URI
|
||||||
|
@ -75,6 +75,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addOptionalFields) {
|
||||||
val emails = getEmails()
|
val emails = getEmails()
|
||||||
size = emails.size()
|
size = emails.size()
|
||||||
for (i in 0 until size) {
|
for (i in 0 until size) {
|
||||||
|
@ -88,8 +89,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
val key = addresses.keyAt(i)
|
val key = addresses.keyAt(i)
|
||||||
contacts[key]?.addresses = addresses.valueAt(i)
|
contacts[key]?.addresses = addresses.valueAt(i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//getNotes()
|
|
||||||
|
|
||||||
activity.dbHelper.getContacts().forEach {
|
activity.dbHelper.getContacts().forEach {
|
||||||
contacts.put(it.id, it)
|
contacts.put(it.id, it)
|
||||||
|
|
Loading…
Reference in New Issue