forked from upstream-mirrors/quik
Merge pull request #265 from gavine99/gracefully-handle-failure-to-get-contact-attachment-data
gracefully handle a failure to get contact attachment data
This commit is contained in:
@@ -74,11 +74,19 @@ class AttachmentAdapter @Inject constructor(
|
|||||||
val attachment = getItem(position)
|
val attachment = getItem(position)
|
||||||
|
|
||||||
if (attachment.isVCard(context)) {
|
if (attachment.isVCard(context)) {
|
||||||
val displayName = Ezvcard.parse(
|
try {
|
||||||
String(attachment.getResourceBytes(context))
|
val displayName = Ezvcard.parse(
|
||||||
).first().getDisplayName() ?: ""
|
String(attachment.getResourceBytes(context))
|
||||||
holder.name.text = displayName
|
).first().getDisplayName() ?: ""
|
||||||
holder.name.isVisible = displayName.isNotEmpty()
|
holder.name.text = displayName
|
||||||
|
holder.name.isVisible = displayName.isNotEmpty()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// npe from Ezvcard first() call above can be thrown if resource bytes cannot
|
||||||
|
// be retrieved from contact resource provider
|
||||||
|
holder.vCardAvatar.setImageResource(android.R.drawable.ic_delete)
|
||||||
|
holder.name.text = context.getString(R.string.attachment_missing)
|
||||||
|
holder.name.isVisible = true
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user