add handling for updating local private contacts
This commit is contained in:
parent
097344dd26
commit
dc43fb93f8
|
@ -328,7 +328,9 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateContact(contact: Contact, photoUpdateStatus: Int): Boolean {
|
fun updateContact(contact: Contact, photoUpdateStatus: Int): Boolean {
|
||||||
return try {
|
return if (contact.source == SMT_PRIVATE) {
|
||||||
|
activity.dbHelper.update(contact)
|
||||||
|
} else try {
|
||||||
activity.toast(R.string.updating)
|
activity.toast(R.string.updating)
|
||||||
val operations = ArrayList<ContentProviderOperation>()
|
val operations = ArrayList<ContentProviderOperation>()
|
||||||
ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).apply {
|
ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).apply {
|
||||||
|
|
|
@ -61,6 +61,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
return id != -1
|
return id != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun update(contact: Contact): Boolean {
|
||||||
|
val contactValues = fillContactValues(contact)
|
||||||
|
val selection = "$COL_ID = ?"
|
||||||
|
val selectionArgs = arrayOf(contact.id.toString())
|
||||||
|
return mDb.update(CONTACTS_TABLE_NAME, contactValues, selection, selectionArgs) == 1
|
||||||
|
}
|
||||||
|
|
||||||
private fun fillContactValues(contact: Contact): ContentValues {
|
private fun fillContactValues(contact: Contact): ContentValues {
|
||||||
return ContentValues().apply {
|
return ContentValues().apply {
|
||||||
put(COL_FIRST_NAME, contact.firstName)
|
put(COL_FIRST_NAME, contact.firstName)
|
||||||
|
|
Loading…
Reference in New Issue