diff --git a/app/src/main/java/app/pachli/adapter/StatusBaseViewHolder.kt b/app/src/main/java/app/pachli/adapter/StatusBaseViewHolder.kt index a3765e58d..0fb660ad1 100644 --- a/app/src/main/java/app/pachli/adapter/StatusBaseViewHolder.kt +++ b/app/src/main/java/app/pachli/adapter/StatusBaseViewHolder.kt @@ -517,9 +517,8 @@ abstract class StatusBaseViewHolder protected constructor(i if (useBlurhash) attachment.blurhash else null, ) val type = attachment.type - if (showingContent && (type === Attachment.Type.VIDEO || type === Attachment.Type.GIFV)) { - imageView.foreground = - ContextCompat.getDrawable(context, R.drawable.play_indicator_overlay) + if (showingContent && type.isPlayable()) { + imageView.foreground = ContextCompat.getDrawable(context, R.drawable.play_indicator_overlay) } else { imageView.foreground = null } @@ -900,10 +899,8 @@ abstract class StatusBaseViewHolder protected constructor(i companion object { @JvmStatic protected fun hasPreviewableAttachment(attachments: List): Boolean { - for ((_, _, _, _, type) in attachments) { - if (type === Attachment.Type.AUDIO || type === Attachment.Type.UNKNOWN) { - return false - } + for (attachment in attachments) { + if (attachment.type == Attachment.Type.UNKNOWN) return false } return true } @@ -940,3 +937,12 @@ abstract class StatusBaseViewHolder protected constructor(i } } } + +/** + * @return True if this attachment type is playable and should show the playable indicator, + * otherwise false. + */ +fun Attachment.Type.isPlayable() = when (this) { + Attachment.Type.AUDIO, Attachment.Type.GIFV, Attachment.Type.VIDEO -> true + Attachment.Type.IMAGE, Attachment.Type.UNKNOWN -> false +}