From 8bfa1d31299176cdff69a2f20b61817cbdeb33aa Mon Sep 17 00:00:00 2001 From: Nihility Date: Sun, 8 Sep 2024 17:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=9A=84=20key=20=E4=B8=BA=20verificationRes?= =?UTF-8?q?ultKey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/help/source/SourceVerificationHelp.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/source/SourceVerificationHelp.kt b/app/src/main/java/io/legado/app/help/source/SourceVerificationHelp.kt index c4f53dc9a..2bc123253 100644 --- a/app/src/main/java/io/legado/app/help/source/SourceVerificationHelp.kt +++ b/app/src/main/java/io/legado/app/help/source/SourceVerificationHelp.kt @@ -19,8 +19,8 @@ object SourceVerificationHelp { private val waitTime = 1.minutes.inWholeNanoseconds - private fun getKey(source: BaseSource) = getKey(source.getKey()) - private fun getKey(sourceKey: String) = "${sourceKey}_verificationResult" + private fun getVerificationResultKey(source: BaseSource) = getVerificationResultKey(source.getKey()) + private fun getVerificationResultKey(sourceKey: String) = "${sourceKey}_verificationResult" /** * 获取书源验证结果 @@ -42,7 +42,7 @@ object SourceVerificationHelp { putExtra("imageUrl", url) putExtra("sourceOrigin", source.getKey()) putExtra("sourceName", source.getTag()) - IntentData.put(getKey(source), Thread.currentThread()) + IntentData.put(getVerificationResultKey(source), Thread.currentThread()) } } else { startBrowser(source, url, title, true) @@ -75,7 +75,6 @@ object SourceVerificationHelp { saveResult: Boolean? = false ) { source ?: throw NoStackTraceException("startBrowser parameter source cannot be null") - val key = getKey(source) appCtx.startActivity { putExtra("title", title) putExtra("url", url) @@ -83,26 +82,26 @@ object SourceVerificationHelp { putExtra("sourceName", source.getTag()) putExtra("sourceVerificationEnable", saveResult) IntentData.put(url, source.getHeaderMap(true)) - IntentData.put(key, Thread.currentThread()) + IntentData.put(getVerificationResultKey(source), Thread.currentThread()) } } fun checkResult(sourceKey: String) { getResult(sourceKey) ?: setResult(sourceKey, "") - val thread = IntentData.get(getKey(sourceKey)) + val thread = IntentData.get(getVerificationResultKey(sourceKey)) LockSupport.unpark(thread) } fun setResult(sourceKey: String, result: String?) { - CacheManager.putMemory(getKey(sourceKey), result ?: "") + CacheManager.putMemory(getVerificationResultKey(sourceKey), result ?: "") } fun getResult(sourceKey: String): String? { - return CacheManager.get(getKey(sourceKey)) + return CacheManager.get(getVerificationResultKey(sourceKey)) } fun clearResult(sourceKey: String) { - CacheManager.delete(getKey(sourceKey)) + CacheManager.delete(getVerificationResultKey(sourceKey)) } }