mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Merge pull request #4373 from kiwix/Fixes#4368
Fixed: File size unit / calculation differs from Kiwix-Server.
This commit is contained in:
commit
bd7228354f
@ -20,7 +20,7 @@
|
||||
<ID>MagicNumber:DownloaderModule.kt$DownloaderModule$5</ID>
|
||||
<ID>MagicNumber:FileUtils.kt$FileUtils$3</ID>
|
||||
<ID>MagicNumber:JNIInitialiser.kt$JNIInitialiser$1024</ID>
|
||||
<ID>MagicNumber:Byte.kt$Byte$1024.0</ID>
|
||||
<ID>MagicNumber:Byte.kt$Byte$1000.0</ID>
|
||||
<ID>MagicNumber:MainMenu.kt$MainMenu$99</ID>
|
||||
<ID>MagicNumber:ReaderMenuState.kt$ReaderMenuState$99</ID>
|
||||
<ID>MagicNumber:OnSwipeTouchListener.kt$OnSwipeTouchListener.GestureListener$100</ID>
|
||||
|
@ -27,9 +27,9 @@ value class Byte(private val byteString: String?) {
|
||||
val humanReadable
|
||||
get() = byteString?.toLongOrNull()?.let {
|
||||
val units = arrayOf("B", "KB", "MB", "GB", "TB")
|
||||
val conversion = (log10(it.toDouble()) / log10(1024.0)).toInt()
|
||||
DecimalFormat("#,##0.#")
|
||||
.format(it / 1024.0.pow(conversion.toDouble())) +
|
||||
val conversion = (log10(it.toDouble()) / log10(1000.0)).toInt()
|
||||
DecimalFormat("#,##0.##")
|
||||
.format(it / 1000.0.pow(conversion.toDouble())) +
|
||||
" " +
|
||||
units[conversion]
|
||||
}.orEmpty()
|
||||
|
Loading…
x
Reference in New Issue
Block a user