mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-04-08 15:22:59 +02:00
report all exceptions thrown during exporting contacts
This commit is contained in:
parent
b617676c34
commit
197eb7b60c
@ -69,6 +69,7 @@ fun Context.getContactUriRawId(uri: Uri): Int {
|
|||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
return cursor.getIntValue(ContactsContract.Contacts.NAME_RAW_CONTACT_ID)
|
return cursor.getIntValue(ContactsContract.Contacts.NAME_RAW_CONTACT_ID)
|
||||||
}
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
} finally {
|
} finally {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import android.provider.MediaStore
|
|||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getFileOutputStream
|
import com.simplemobiletools.commons.extensions.getFileOutputStream
|
||||||
|
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||||
import com.simplemobiletools.commons.extensions.writeLn
|
import com.simplemobiletools.commons.extensions.writeLn
|
||||||
import com.simplemobiletools.contacts.helpers.VcfExporter.ExportResult.*
|
import com.simplemobiletools.contacts.helpers.VcfExporter.ExportResult.*
|
||||||
import com.simplemobiletools.contacts.models.Contact
|
import com.simplemobiletools.contacts.models.Contact
|
||||||
@ -24,6 +25,7 @@ class VcfExporter {
|
|||||||
private var contactsFailed = 0
|
private var contactsFailed = 0
|
||||||
|
|
||||||
fun exportContacts(activity: BaseSimpleActivity, file: File, contacts: ArrayList<Contact>, callback: (result: ExportResult) -> Unit) {
|
fun exportContacts(activity: BaseSimpleActivity, file: File, contacts: ArrayList<Contact>, callback: (result: ExportResult) -> Unit) {
|
||||||
|
try {
|
||||||
activity.getFileOutputStream(file) {
|
activity.getFileOutputStream(file) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
callback(EXPORT_FAIL)
|
callback(EXPORT_FAIL)
|
||||||
@ -78,6 +80,9 @@ class VcfExporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
activity.showErrorToast(e)
|
||||||
|
}
|
||||||
|
|
||||||
callback(when {
|
callback(when {
|
||||||
contactsExported == 0 -> EXPORT_FAIL
|
contactsExported == 0 -> EXPORT_FAIL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user