From d4e1af532f47b11af27669155c03e74ba0a25f95 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 5 May 2022 17:16:58 +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 --- .../legado/app/help/SourceVerificationHelp.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt b/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt index 3f3a302dc..8efbf914b 100644 --- a/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt @@ -1,13 +1,13 @@ package io.legado.app.help -import io.legado.app.utils.startActivity import io.legado.app.constant.AppLog -import io.legado.app.exception.NoStackTraceException import io.legado.app.data.entities.BaseSource -import io.legado.app.ui.browser.WebViewActivity +import io.legado.app.exception.NoStackTraceException import io.legado.app.ui.association.VerificationCodeActivity -import splitties.init.appCtx +import io.legado.app.ui.browser.WebViewActivity +import io.legado.app.utils.startActivity import kotlinx.coroutines.runBlocking +import splitties.init.appCtx object SourceVerificationHelp { @@ -19,13 +19,13 @@ object SourceVerificationHelp { fun getVerificationResult(source: BaseSource?, url: String, title: String, useBrowser: Boolean): String { source ?: throw NoStackTraceException("getVerificationResult parameter source cannot be null") return runBlocking { - val key = "${source?.getKey() ?: ""}_verificationResult" + val key = "${source.getKey()}_verificationResult" CacheManager.delete(key) if (!useBrowser) { appCtx.startActivity { putExtra("imageUrl", url) - putExtra("sourceOrigin", source?.getKey()) + putExtra("sourceOrigin", source.getKey()) } } else { startBrowser(source, url, title, true) @@ -39,10 +39,8 @@ object SourceVerificationHelp { } } CacheManager.get(key)!!.let { - if (it.isBlank()) { + it.ifBlank { throw NoStackTraceException("验证结果为空") - } else { - it } } } @@ -57,9 +55,9 @@ object SourceVerificationHelp { appCtx.startActivity { putExtra("title", title) putExtra("url", url) - putExtra("sourceOrigin", source?.getKey()) + putExtra("sourceOrigin", source.getKey()) putExtra("sourceVerificationEnable", saveResult) - IntentData.put(url, source?.getHeaderMap(true)) + IntentData.put(url, source.getHeaderMap(true)) } }