Skip to content

Commit 5c6500d

Browse files
committed
Hide phone number field when there is none
1 parent ea5adfc commit 5c6500d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/AutoCompleteTextViewAdapter.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.bumptech.glide.Glide
1010
import com.bumptech.glide.load.engine.DiskCacheStrategy
1111
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
1212
import com.bumptech.glide.request.RequestOptions
13+
import com.simplemobiletools.commons.extensions.beGone
1314
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
1415
import com.simplemobiletools.commons.extensions.getProperTextColor
1516
import com.simplemobiletools.commons.extensions.normalizeString
@@ -44,8 +45,13 @@ class AutoCompleteTextViewAdapter(
4445

4546
tag = nameToUse.isNotEmpty()
4647
item_autocomplete_name.text = nameToUse
47-
item_autocomplete_number.text = contact.phoneNumbers.run {
48-
firstOrNull { it.isPrimary }?.normalizedNumber ?: firstOrNull()?.normalizedNumber
48+
contact.phoneNumbers.apply {
49+
val phoneNumber = firstOrNull { it.isPrimary }?.normalizedNumber ?: firstOrNull()?.normalizedNumber
50+
if (phoneNumber.isNullOrEmpty()) {
51+
item_autocomplete_number.beGone()
52+
} else {
53+
item_autocomplete_number.text = phoneNumber
54+
}
4955
}
5056

5157
val options = RequestOptions()

0 commit comments

Comments
 (0)