mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-18 20:40:46 +01:00
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) {
|
if (contactId != 0) {
|
||||||
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
Thread {
|
||||||
if (contact == null) {
|
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
||||||
toast(R.string.unknown_error_occurred)
|
if (contact == null) {
|
||||||
finish()
|
toast(R.string.unknown_error_occurred)
|
||||||
return
|
finish()
|
||||||
}
|
} else {
|
||||||
|
runOnUiThread {
|
||||||
|
gotContact()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
} else {
|
||||||
|
gotContact()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun gotContact() {
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
setupNewContact()
|
setupNewContact()
|
||||||
} else {
|
} else {
|
||||||
setupEditContact()
|
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) {
|
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)
|
val phone = intent.extras.get(KEY_PHONE)
|
||||||
if (phone != null) {
|
if (phone != null) {
|
||||||
|
@ -98,21 +98,28 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (contactId != 0 && !wasLookupKeyUsed) {
|
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) {
|
if (contact == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
|
||||||
finish()
|
finish()
|
||||||
return
|
} else {
|
||||||
|
gotContact()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (contact == null) {
|
private fun gotContact() {
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setupViewContact()
|
setupViewContact()
|
||||||
|
|
||||||
contact_send_sms.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
contact_send_sms.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
||||||
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
||||||
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
|
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user