add support for updating local contacts
This commit is contained in:
parent
79e46c43d5
commit
23c5ab8297
|
@ -902,7 +902,7 @@ class ContactsHelper(val activity: Activity) {
|
|||
fun updateContact(contact: Contact, photoUpdateStatus: Int): Boolean {
|
||||
activity.toast(R.string.updating)
|
||||
if (contact.source == SMT_PRIVATE) {
|
||||
return activity.dbHelper.updateContact(contact)
|
||||
return LocalContactsHelper(activity).insertOrUpdateContact(contact)
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1213,7 +1213,7 @@ class ContactsHelper(val activity: Activity) {
|
|||
|
||||
fun insertContact(contact: Contact): Boolean {
|
||||
if (contact.source == SMT_PRIVATE) {
|
||||
return LocalContactsHelper(activity).insertContact(contact)
|
||||
return LocalContactsHelper(activity).insertOrUpdateContact(contact)
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -16,10 +16,9 @@ class LocalContactsHelper(val activity: Activity) {
|
|||
|
||||
fun getContactWithId(id: Int) = convertLocalContactToContact(activity.contactsDB.getContactWithId(id))
|
||||
|
||||
fun insertContact(contact: Contact): Boolean {
|
||||
fun insertOrUpdateContact(contact: Contact): Boolean {
|
||||
val localContact = convertContactToLocalContact(contact)
|
||||
activity.contactsDB.insertOrUpdate(localContact)
|
||||
return true
|
||||
return activity.contactsDB.insertOrUpdate(localContact) > 0
|
||||
}
|
||||
|
||||
private fun getPhotoByteArray(uri: String): ByteArray {
|
||||
|
|
|
@ -15,7 +15,7 @@ interface ContactsDao {
|
|||
fun getContactWithId(id: Int): LocalContact
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOrUpdate(contact: LocalContact)
|
||||
fun insertOrUpdate(contact: LocalContact): Long
|
||||
|
||||
@Query("DELETE FROM contacts WHERE id IN (:ids)")
|
||||
fun deleteContactIds(ids: String)
|
||||
|
|
Loading…
Reference in New Issue