From 5af53bba82cfbd4dba0dbd68b138c495d82a5a16 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 27 Aug 2022 16:54:36 +0200 Subject: [PATCH] recognise shorts --- .../extensions/SetFormattedDuration.kt | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/extensions/SetFormattedDuration.kt b/app/src/main/java/com/github/libretube/extensions/SetFormattedDuration.kt index 31008c669..502d71e73 100644 --- a/app/src/main/java/com/github/libretube/extensions/SetFormattedDuration.kt +++ b/app/src/main/java/com/github/libretube/extensions/SetFormattedDuration.kt @@ -3,15 +3,27 @@ package com.github.libretube.extensions import android.text.format.DateUtils import android.widget.TextView import com.github.libretube.R +import com.github.libretube.util.ThemeHelper -fun TextView?.setFormattedDuration(duration: Long) { +fun TextView.setFormattedDuration(duration: Long) { val text = if (duration < 0L) { - this!!.setBackgroundColor(R.attr.colorPrimaryDark) + this.setBackgroundColor( + ThemeHelper.getThemeColor( + context, + R.attr.colorPrimaryDark + ) + ) this.context.getString(R.string.live) - } else if (duration == 0L) { - this!!.context.getString(R.string.yt_shorts) + } else if (duration in 0L..60L) { + this.setBackgroundColor( + ThemeHelper.getThemeColor( + context, + R.attr.colorPrimaryDark + ) + ) + this.context.getString(R.string.yt_shorts) } else { DateUtils.formatElapsedTime(duration) } - this!!.text = text + this.text = text }