Skip to content

Commit 9bbb6d6

Browse files
committed
change Boolean logic
1 parent 3aa0866 commit 9bbb6d6

2 files changed

Lines changed: 24 additions & 15 deletions

File tree

core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
1717
private var phone: String? = null
1818
private var phoneType: PhoneType? = null
1919
private var customPhoneType: String? = null
20-
private var phoneIsPrimary = false
20+
private var phoneIsPrimary: Boolean? = null
2121
private var secondaryPhone: String? = null
2222
private var secondaryPhoneType: PhoneType? = null
2323
private var customSecondaryPhoneType: String? = null
@@ -27,7 +27,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
2727
private var email: String? = null
2828
private var emailType: EmailAddressType? = null
2929
private var customEmailType: String? = null
30-
private var emailIsPrimary = false
30+
private var emailIsPrimary: Boolean? = null
3131
private var secondaryEmail: String? = null
3232
private var secondaryEmailType: EmailAddressType? = null
3333
private var customSecondaryEmailType: String? = null
@@ -36,7 +36,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
3636
private var customTertiaryEmailType: String? = null
3737
private var postal: String? = null
3838
private var postalType: String? = null
39-
private var postalIsPrimary = false
39+
private var postalIsPrimary: Boolean? = null
4040

4141
/**
4242
* Set the extra field for the contact name.
@@ -147,10 +147,11 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
147147
* Set the field for the phone isprimary flag.
148148
* <P>Type: boolean</P>
149149
*
150+
* @param phoneIsPrimary Boolean
150151
* @return This InsertContactIntentBuilder for method chaining
151152
*/
152-
fun phoneIsPrimary(): InsertContactIntentBuilder {
153-
this.phoneIsPrimary = true
153+
fun phoneIsPrimary(phoneIsPrimary: Boolean): InsertContactIntentBuilder {
154+
this.phoneIsPrimary = phoneIsPrimary
154155
return this
155156
}
156157

@@ -274,10 +275,11 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
274275
/**
275276
* Set the field for the email isprimary flag.
276277
*
278+
* @param emailIsPrimary Boolean
277279
* @return This InsertContactIntentBuilder for method chaining
278280
*/
279-
fun emailIsPrimary(): InsertContactIntentBuilder {
280-
this.emailIsPrimary = true
281+
fun emailIsPrimary(emailIsPrimary: Boolean): InsertContactIntentBuilder {
282+
this.emailIsPrimary = emailIsPrimary
281283
return this
282284
}
283285

@@ -385,10 +387,11 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
385387
/**
386388
* Set the extra field for the postal isprimary flag.
387389
*
390+
* @param postalIsPrimary Boolean
388391
* @return This InsertContactIntentBuilder for method chaining
389392
*/
390-
fun postalIsPrimary(): InsertContactIntentBuilder {
391-
this.postalIsPrimary = true
393+
fun postalIsPrimary(postalIsPrimary: Boolean): InsertContactIntentBuilder {
394+
this.postalIsPrimary = postalIsPrimary
392395
return this
393396
}
394397

@@ -432,7 +435,9 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
432435
}
433436
}
434437

435-
putExtra(PHONE_ISPRIMARY, phoneIsPrimary)
438+
phoneIsPrimary?.let {
439+
putExtra(PHONE_ISPRIMARY, it)
440+
}
436441

437442
secondaryPhone?.let {
438443
putExtra(SECONDARY_PHONE, it)
@@ -470,7 +475,9 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
470475
}
471476
}
472477

473-
putExtra(EMAIL_ISPRIMARY, emailIsPrimary)
478+
emailIsPrimary?.let {
479+
putExtra(EMAIL_ISPRIMARY, it)
480+
}
474481

475482
secondaryEmail?.let {
476483
putExtra(SECONDARY_EMAIL, it)
@@ -504,7 +511,9 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
504511
putExtra(POSTAL_TYPE, it)
505512
}
506513

507-
putExtra(POSTAL_ISPRIMARY, postalIsPrimary)
514+
postalIsPrimary?.let {
515+
putExtra(POSTAL_ISPRIMARY, it)
516+
}
508517

509518
}
510519
}

examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,21 @@ private void onInsertContactClicked() {
257257
.notes("notes")
258258
.phone("88000000008")
259259
.phoneType(PhoneType.TYPE_HOME)
260-
.phoneIsPrimary()
260+
.phoneIsPrimary(true)
261261
.secondaryPhone("88000001008")
262262
.secondaryPhoneType("YOUR_CUSTOM_TYPE")
263263
.tertiaryPhone("888888888")
264264
.tertiaryPhoneType(PhoneType.TYPE_WORK_MOBILE)
265265
.email("develop@omega-r.com")
266266
.emailType(EmailAddressType.TYPE_HOME)
267-
.emailIsPrimary()
267+
.emailIsPrimary(false)
268268
.secondaryEmail("secondaryEmail")
269269
.secondaryEmailType(EmailAddressType.TYPE_WORK)
270270
.tertiaryEmail("tertiaryEmail")
271271
.tertiaryEmailType("YOUR_CUSTOM_EMAIL_TYPE")
272272
.postal("postal")
273273
.postalType("Home")
274-
.postalIsPrimary()
274+
.postalIsPrimary(true)
275275
.createIntentHandler(this)
276276
.startActivity();
277277
}

0 commit comments

Comments
 (0)