mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-16 07:10:29 +05:30
23 lines
1.2 KiB
Kotlin
23 lines
1.2 KiB
Kotlin
|
package xyz.btcland.libretube
|
||
|
|
||
|
import java.math.BigDecimal
|
||
|
import java.math.RoundingMode
|
||
|
|
||
|
fun Long?.videoViews(): String = when {
|
||
|
this!!<1000 -> {
|
||
|
this.toString()
|
||
|
}
|
||
|
this in 1000..999999 -> {
|
||
|
val decimal = BigDecimal(this/1000).setScale(0, RoundingMode.HALF_EVEN)
|
||
|
decimal.toString()+"K"
|
||
|
}
|
||
|
this in 1000000..10000000 -> {
|
||
|
val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||
|
decimal.toString()+"M"
|
||
|
}
|
||
|
else -> {
|
||
|
val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||
|
decimal.toString()+"M"
|
||
|
}
|
||
|
}
|