mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
changes to gracefully handle a failure to get contact attachment data from provider
This commit is contained in:
@@ -74,11 +74,19 @@ class AttachmentAdapter @Inject constructor(
|
||||
val attachment = getItem(position)
|
||||
|
||||
if (attachment.isVCard(context)) {
|
||||
val displayName = Ezvcard.parse(
|
||||
String(attachment.getResourceBytes(context))
|
||||
).first().getDisplayName() ?: ""
|
||||
holder.name.text = displayName
|
||||
holder.name.isVisible = displayName.isNotEmpty()
|
||||
try {
|
||||
val displayName = Ezvcard.parse(
|
||||
String(attachment.getResourceBytes(context))
|
||||
).first().getDisplayName() ?: ""
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user