Skip to content

Commit

Permalink
avoid some null extras at third party intents
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Sep 27, 2018
1 parent 26061d8 commit 2f59a84
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,20 @@ class EditContactActivity : ContactActivity() {
setupEditContact()
}

if ((contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) {
val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: ""
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, ""))
if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) {
highlightLastPhoneNumber = true
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) {
val phoneNumber = phone.toString()
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, ""))
if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) {
highlightLastPhoneNumber = true
}
}

contact!!.firstName = intent.extras.get(KEY_NAME)?.toString() ?: ""
val firstName = intent.extras.get(KEY_NAME)
if (firstName != null) {
contact!!.firstName = firstName.toString()
}

val data = intent.extras.getParcelableArrayList<ContentValues>("data")
if (data != null) {
Expand Down

0 comments on commit 2f59a84

Please sign in to comment.