catch and show exceptions thrown at modifying groups

This commit is contained in:
tibbi 2020-04-15 12:47:52 +02:00
parent 855b4e0188
commit 8f890f4f54

View File

@ -1217,6 +1217,7 @@ class ContactsHelper(val context: Context) {
}
fun addContactsToGroup(contacts: ArrayList<Contact>, groupId: Long) {
try {
val operations = ArrayList<ContentProviderOperation>()
contacts.forEach {
ContentProviderOperation.newInsert(Data.CONTENT_URI).apply {
@ -1232,7 +1233,6 @@ class ContactsHelper(val context: Context) {
}
}
try {
context.contentResolver.applyBatch(AUTHORITY, operations)
} catch (e: Exception) {
context.showErrorToast(e)
@ -1240,6 +1240,7 @@ class ContactsHelper(val context: Context) {
}
fun removeContactsFromGroup(contacts: ArrayList<Contact>, groupId: Long) {
try {
val operations = ArrayList<ContentProviderOperation>()
contacts.forEach {
ContentProviderOperation.newDelete(Data.CONTENT_URI).apply {
@ -1255,6 +1256,9 @@ class ContactsHelper(val context: Context) {
}
}
context.contentResolver.applyBatch(AUTHORITY, operations)
} catch (e: Exception) {
context.showErrorToast(e)
}
}
fun insertContact(contact: Contact): Boolean {