From d485f3afe0b24c55358955bf086db9db40f18a81 Mon Sep 17 00:00:00 2001 From: celetor <86599970+celetor@users.noreply.github.com> Date: Tue, 20 Jul 2021 11:14:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=BD=91=E7=BB=9Czip?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=87=8C=E9=9D=A2=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?-=E5=A2=9E=E5=8A=A0=E4=BB=8E=E5=8D=81=E5=85=AD=E8=BF=9B?= =?UTF-8?q?=E5=88=B6=E5=AD=97=E7=AC=A6=E4=B8=B2=E4=B8=AD=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/JsExtensions.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 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 56326e382..db9f3cbfa 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -312,13 +312,17 @@ interface JsExtensions { /** * 获取网络zip文件里面的数据 - * @param url zip文件的链接 + * @param url zip文件的链接或十六进制字符串 * @param path 所需获取文件在zip内的路径 * @return zip指定文件的数据 */ fun getZipStringContent(url: String, path: String): String { - val bytes = runBlocking { - return@runBlocking okHttpClient.newCall { url(url) }.bytes() + val bytes = if (url.startsWith("http://") || url.startsWith("https://")) { + runBlocking { + return@runBlocking okHttpClient.newCall { url(url) }.bytes() + } + } else { + StringUtils.hexStringToByte(url) } val bos = ByteArrayOutputStream() val zis = ZipInputStream(ByteArrayInputStream(bytes)) @@ -339,13 +343,17 @@ interface JsExtensions { /** * 获取网络zip文件里面的数据 - * @param url zip文件的链接 + * @param url zip文件的链接或十六进制字符串 * @param path 所需获取文件在zip内的路径 * @return zip指定文件的数据 */ fun getZipByteArrayContent(url: String, path: String): ByteArray? { - val bytes = runBlocking { - return@runBlocking okHttpClient.newCall { url(url) }.bytes() + val bytes = if (url.startsWith("http://") || url.startsWith("https://")) { + runBlocking { + return@runBlocking okHttpClient.newCall { url(url) }.bytes() + } + } else { + StringUtils.hexStringToByte(url) } val bos = ByteArrayOutputStream() val zis = ZipInputStream(ByteArrayInputStream(bytes))