Ver Fonte

Fix: fix traffic format

kr328 há 3 anos atrás
pai
commit
5bc3975591

+ 3 - 3
core/src/main/java/com/github/kr328/clash/core/util/Traffic.kt

@@ -22,17 +22,17 @@ private fun trafficString(scaled: Long): String {
         scaled > 1024 * 1024 * 1024 * 100L -> {
         scaled > 1024 * 1024 * 1024 * 100L -> {
             val data = scaled / 1024 / 1024 / 1024
             val data = scaled / 1024 / 1024 / 1024
 
 
-            "${data / 100}.${data % 100} GiB"
+            String.format("%.2f GiB", data.toFloat() / 100)
         }
         }
         scaled > 1024 * 1024 * 100L -> {
         scaled > 1024 * 1024 * 100L -> {
             val data = scaled / 1024 / 1024
             val data = scaled / 1024 / 1024
 
 
-            "${data / 100}.${data % 100} MiB"
+            String.format("%.2f MiB", data.toFloat() / 100)
         }
         }
         scaled > 1024 * 100L -> {
         scaled > 1024 * 100L -> {
             val data = scaled / 1024
             val data = scaled / 1024
 
 
-            "${data / 100}.${data % 100} KiB"
+            String.format("%.2f KiB", data.toFloat() / 100)
         }
         }
         else -> {
         else -> {
             "$scaled Bytes"
             "$scaled Bytes"