mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-16 04:19:19 +00:00
Add: More info on top of the screen
Fix: Show real size of apk
This commit is contained in:
@ -13,12 +13,23 @@ private val sizeFormats = listOf("%.0f B", "%.0f kB", "%.1f MB", "%.2f GB")
|
||||
|
||||
fun Long.formatSize(): String {
|
||||
val (size, index) = generateSequence(Pair(this.toFloat(), 0)) { (size, index) ->
|
||||
if (size >= 1000f)
|
||||
Pair(size / 1000f, index + 1) else null
|
||||
if (size >= 1024f)
|
||||
Pair(size / 1024f, index + 1) else null
|
||||
}.take(sizeFormats.size).last()
|
||||
return sizeFormats[index].format(Locale.US, size)
|
||||
}
|
||||
|
||||
fun String?.trimAfter(char: Char, repeated: Int): String? {
|
||||
var count = 0
|
||||
this?.let {
|
||||
for (i in it.indices) {
|
||||
if (it[i] == char) count++
|
||||
if (repeated == count) return it.substring(0, i)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun Char.halfByte(): Int {
|
||||
return when (this) {
|
||||
in '0'..'9' -> this - '0'
|
||||
|
Reference in New Issue
Block a user