diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt index 838d0aa9..205c8c0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt @@ -367,8 +367,12 @@ class ThreadAdapter( thread_mesage_attachments_holder.addView(vCardView) parseVCardFromUri(context, uri) { vCards -> - val title = vCards.first().formattedName.value - val imageIcon = SimpleContactsHelper(context).getContactLetterIcon(title) + val title = vCards.firstOrNull()?.formattedName?.value + val imageIcon = if (title != null) { + SimpleContactsHelper(context).getContactLetterIcon(title) + } else { + null + } activity.runOnUiThread { vCardView.apply { vcard_title.text = title diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/VCardViewerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/VCardViewerAdapter.kt index b094f517..1d63d84a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/VCardViewerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/VCardViewerAdapter.kt @@ -55,7 +55,7 @@ class VCardViewerAdapter( } private fun setupVCardView(view: View, item: VCardWrapper) { - val name = item.vCard.formattedName.value + val name = item.vCard.formattedName?.value view.apply { item_contact_name.apply { text = name @@ -64,7 +64,11 @@ class VCardViewerAdapter( } item_contact_image.apply { val photo = item.vCard.photos.firstOrNull() - val placeholder = SimpleContactsHelper(context).getContactLetterIcon(name).toDrawable(resources) + val placeholder = if (name != null) { + SimpleContactsHelper(context).getContactLetterIcon(name).toDrawable(resources) + } else { + null + } val roundingRadius = resources.getDimensionPixelSize(R.dimen.big_margin) val transformation = RoundedCorners(roundingRadius) val options = RequestOptions()