From f0c5c9fdb34f3b6080c57e81305ddeedc9d8f3f4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 22 Nov 2020 21:37:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/JsExtensions.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index b282fbcc2..5e99f88e1 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -241,29 +241,27 @@ interface JsExtensions { return null } - fun queryTTF(path: String): QueryTTF? { - val key = md5Encode16(path) + fun queryTTF(str: String?): QueryTTF? { + str ?: return null + val key = md5Encode16(str) var qTTF = CacheManager.getQueryTTF(key) if (qTTF != null) { return qTTF } val font: ByteArray? = when { - path.isAbsUrl() -> runBlocking { + str.isAbsUrl() -> runBlocking { var x = CacheManager.getByteArray(key) if (x == null) { - x = HttpHelper.simpleGetBytesAsync(path) + x = HttpHelper.simpleGetBytesAsync(str) x?.let { CacheManager.put(key, it) } } return@runBlocking x } - path.isContentScheme() -> { - Uri.parse(path).readBytes(App.INSTANCE) - } - else -> { - File(path).readBytes() - } + str.isContentScheme() -> Uri.parse(str).readBytes(App.INSTANCE) + str.startsWith("/storage") -> File(str).readBytes() + else -> base64DecodeToByteArray(str) } font ?: return null qTTF = QueryTTF(font)