mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 04:06:14 +00:00
Handle thumbnail generation failing more gracefully.
This commit is contained in:
@@ -253,16 +253,21 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
}
|
||||
|
||||
private fun generateThumbnailIfPossible(attachment: DatabaseAttachment): ImageCompressionUtil.Result? {
|
||||
val uri: DecryptableUri = attachment.uri?.let { DecryptableUri(it) } ?: return null
|
||||
try {
|
||||
val uri: DecryptableUri = attachment.uri?.let { DecryptableUri(it) } ?: return null
|
||||
|
||||
return if (MediaUtil.isImageType(attachment.contentType)) {
|
||||
compress(uri, attachment.contentType ?: "")
|
||||
} else if (Build.VERSION.SDK_INT >= 23 && MediaUtil.isVideoType(attachment.contentType)) {
|
||||
MediaUtil.getVideoThumbnail(context, attachment.uri)?.let {
|
||||
return if (MediaUtil.isImageType(attachment.contentType)) {
|
||||
compress(uri, attachment.contentType ?: "")
|
||||
} else if (Build.VERSION.SDK_INT >= 23 && MediaUtil.isVideoType(attachment.contentType)) {
|
||||
MediaUtil.getVideoThumbnail(context, attachment.uri)?.let {
|
||||
compress(uri, attachment.contentType ?: "")
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to generate thumbnail for $attachmentId", e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user