fix some threading issues at Edit and View screens
This commit is contained in:
parent
6b687a1890
commit
ba108340b1
|
@ -140,20 +140,30 @@ class EditContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
if (contactId != 0) {
|
||||
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
||||
if (contact == null) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
return
|
||||
}
|
||||
Thread {
|
||||
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
||||
if (contact == null) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
} else {
|
||||
runOnUiThread {
|
||||
gotContact()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
} else {
|
||||
gotContact()
|
||||
}
|
||||
}
|
||||
|
||||
private fun gotContact() {
|
||||
if (contact == null) {
|
||||
setupNewContact()
|
||||
} else {
|
||||
setupEditContact()
|
||||
}
|
||||
|
||||
val action = intent.action
|
||||
if ((contact!!.id == 0 && intent.extras != null && intent.extras.containsKey(KEY_PHONE) && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) {
|
||||
val phone = intent.extras.get(KEY_PHONE)
|
||||
if (phone != null) {
|
||||
|
|
|
@ -98,21 +98,28 @@ class ViewContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
if (contactId != 0 && !wasLookupKeyUsed) {
|
||||
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
||||
Thread {
|
||||
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
||||
if (contact == null) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
} else {
|
||||
runOnUiThread {
|
||||
gotContact()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
} else {
|
||||
if (contact == null) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
return
|
||||
} else {
|
||||
gotContact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contact == null) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
private fun gotContact() {
|
||||
setupViewContact()
|
||||
|
||||
contact_send_sms.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
||||
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
||||
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
|
||||
|
|
Loading…
Reference in New Issue