From 1adce9267b5b0b27daa445a4d8b413c83bbc9d6e Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 27 Dec 2020 20:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/StringUtils.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/StringUtils.kt b/app/src/main/java/io/legado/app/utils/StringUtils.kt index a2e2c4388..89d561cbf 100644 --- a/app/src/main/java/io/legado/app/utils/StringUtils.kt +++ b/app/src/main/java/io/legado/app/utils/StringUtils.kt @@ -106,11 +106,9 @@ object StringUtils { if (length <= 0) return "0" val units = arrayOf("b", "kb", "M", "G", "T") //计算单位的,原理是利用lg,公式是 lg(1024^n) = nlg(1024),最后 nlg(1024)/lg(1024) = n。 - //计算单位的,原理是利用lg,公式是 lg(1024^n) = nlg(1024),最后 nlg(1024)/lg(1024) = n。 val digitGroups = (log10(length.toDouble()) / log10(1024.0)).toInt() //计算原理是,size/单位值。单位值指的是:比如说b = 1024,KB = 1024^2 - //计算原理是,size/单位值。单位值指的是:比如说b = 1024,KB = 1024^2 return DecimalFormat("#,##0.##") .format(length / 1024.0.pow(digitGroups.toDouble())) + " " + units[digitGroups] } @@ -306,7 +304,7 @@ object StringUtils { return sb.toString() } - fun hexStringToByte(hexString: String): ByteArray? { + fun hexStringToByte(hexString: String): ByteArray { val hexStr = hexString.replace(" ", "") val len = hexStr.length val bytes = ByteArray(len / 2)