mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
Format file.
This commit is contained in:
parent
24e31c4efb
commit
87c52f7e58
@ -4,19 +4,19 @@ import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
fun Long?.formatShort(): 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"
|
||||
}
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user