mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
catch and show exceptions thrown at modifying groups
This commit is contained in:
@ -1217,6 +1217,7 @@ class ContactsHelper(val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addContactsToGroup(contacts: ArrayList<Contact>, groupId: Long) {
|
fun addContactsToGroup(contacts: ArrayList<Contact>, groupId: Long) {
|
||||||
|
try {
|
||||||
val operations = ArrayList<ContentProviderOperation>()
|
val operations = ArrayList<ContentProviderOperation>()
|
||||||
contacts.forEach {
|
contacts.forEach {
|
||||||
ContentProviderOperation.newInsert(Data.CONTENT_URI).apply {
|
ContentProviderOperation.newInsert(Data.CONTENT_URI).apply {
|
||||||
@ -1232,7 +1233,6 @@ class ContactsHelper(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
context.contentResolver.applyBatch(AUTHORITY, operations)
|
context.contentResolver.applyBatch(AUTHORITY, operations)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
context.showErrorToast(e)
|
context.showErrorToast(e)
|
||||||
@ -1240,6 +1240,7 @@ class ContactsHelper(val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun removeContactsFromGroup(contacts: ArrayList<Contact>, groupId: Long) {
|
fun removeContactsFromGroup(contacts: ArrayList<Contact>, groupId: Long) {
|
||||||
|
try {
|
||||||
val operations = ArrayList<ContentProviderOperation>()
|
val operations = ArrayList<ContentProviderOperation>()
|
||||||
contacts.forEach {
|
contacts.forEach {
|
||||||
ContentProviderOperation.newDelete(Data.CONTENT_URI).apply {
|
ContentProviderOperation.newDelete(Data.CONTENT_URI).apply {
|
||||||
@ -1255,6 +1256,9 @@ class ContactsHelper(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.contentResolver.applyBatch(AUTHORITY, operations)
|
context.contentResolver.applyBatch(AUTHORITY, operations)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
context.showErrorToast(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun insertContact(contact: Contact): Boolean {
|
fun insertContact(contact: Contact): Boolean {
|
||||||
|
Reference in New Issue
Block a user