properly refresh View Contact screen on resume

This commit is contained in:
tibbi 2018-03-21 18:21:16 +01:00
parent bd8dffb549
commit f9fb62366b

View File

@ -60,6 +60,7 @@ class ViewContactActivity : ContactActivity() {
} }
private fun initContact() { private fun initContact() {
var wasLookupKeyUsed = false
var contactId = intent.getIntExtra(CONTACT_ID, 0) var contactId = intent.getIntExtra(CONTACT_ID, 0)
val action = intent.action val action = intent.action
if (contactId == 0 && (action == ContactsContract.QuickContact.ACTION_QUICK_CONTACT || action == Intent.ACTION_VIEW)) { if (contactId == 0 && (action == ContactsContract.QuickContact.ACTION_QUICK_CONTACT || action == Intent.ACTION_VIEW)) {
@ -69,6 +70,7 @@ class ViewContactActivity : ContactActivity() {
val lookupKey = getLookupKeyFromUri(data) val lookupKey = getLookupKeyFromUri(data)
if (lookupKey != null) { if (lookupKey != null) {
contact = ContactsHelper(this).getContactWithLookupKey(lookupKey) contact = ContactsHelper(this).getContactWithLookupKey(lookupKey)
wasLookupKeyUsed = true
} }
getLookupUriRawId(data) getLookupUriRawId(data)
@ -82,7 +84,7 @@ class ViewContactActivity : ContactActivity() {
} }
} }
if (contactId != 0 && contact == null) { if (contactId != 0 && !wasLookupKeyUsed) {
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false)) contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
if (contact == null) { if (contact == null) {
toast(R.string.unknown_error_occurred) toast(R.string.unknown_error_occurred)