mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Fix format short when the count is null
This commit is contained in:
parent
e598b745f6
commit
75ffce292c
@ -3,15 +3,17 @@ package com.github.libretube.extensions
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
@Suppress("KotlinConstantConditions")
|
||||
fun Long?.formatShort(): String = when {
|
||||
this!! < 1000 -> {
|
||||
this == null -> (0).toString()
|
||||
this < 1000 -> {
|
||||
this.toString()
|
||||
}
|
||||
this in 1000..999999 -> {
|
||||
this in (1000..999999) -> {
|
||||
val decimal = BigDecimal(this / 1000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString() + "K"
|
||||
}
|
||||
this in 1000000..10000000 -> {
|
||||
this in (1000000..10000000) -> {
|
||||
val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString() + "M"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user