mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
commit
2b30c41bcb
@ -3,15 +3,27 @@ package com.github.libretube.extensions
|
|||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.github.libretube.R
|
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) {
|
val text = if (duration < 0L) {
|
||||||
this!!.setBackgroundColor(R.attr.colorPrimaryDark)
|
this.setBackgroundColor(
|
||||||
|
ThemeHelper.getThemeColor(
|
||||||
|
context,
|
||||||
|
R.attr.colorPrimaryDark
|
||||||
|
)
|
||||||
|
)
|
||||||
this.context.getString(R.string.live)
|
this.context.getString(R.string.live)
|
||||||
} else if (duration == 0L) {
|
} else if (duration in 0L..60L) {
|
||||||
this!!.context.getString(R.string.yt_shorts)
|
this.setBackgroundColor(
|
||||||
|
ThemeHelper.getThemeColor(
|
||||||
|
context,
|
||||||
|
R.attr.colorPrimaryDark
|
||||||
|
)
|
||||||
|
)
|
||||||
|
this.context.getString(R.string.yt_shorts)
|
||||||
} else {
|
} else {
|
||||||
DateUtils.formatElapsedTime(duration)
|
DateUtils.formatElapsedTime(duration)
|
||||||
}
|
}
|
||||||
this!!.text = text
|
this.text = text
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user