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 8efbf914b..39aac0747 100644 --- a/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceVerificationHelp.kt @@ -12,6 +12,7 @@ import splitties.init.appCtx object SourceVerificationHelp { + private var key: String = "" /** * 获取书源验证结果 * 图片验证码 防爬 滑动验证码 点击字符 等等 @@ -19,7 +20,7 @@ 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" + key = "${source.getKey()}_verificationResult" CacheManager.delete(key) if (!useBrowser) { @@ -52,6 +53,7 @@ object SourceVerificationHelp { */ fun startBrowser(source: BaseSource?, url: String, title: String, saveResult: Boolean? = false) { source ?: throw NoStackTraceException("startBrowser parameter source cannot be null") + key = "${source.getKey()}_verificationResult" appCtx.startActivity { putExtra("title", title) putExtra("url", url) @@ -61,7 +63,7 @@ object SourceVerificationHelp { } } - private fun checkActivityStatus(): Boolean { - return true + fun checkResult() { + CacheManager.get(key) ?: CacheManager.putMemory(key, "") } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt b/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt index 57460eb09..a3b7dd656 100644 --- a/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/VerificationCodeDialog.kt @@ -12,6 +12,7 @@ import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.databinding.DialogVerificationCodeViewBinding import io.legado.app.help.CacheManager +import io.legado.app.help.SourceVerificationHelp import io.legado.app.help.glide.ImageLoader import io.legado.app.help.glide.OkHttpModelLoader import io.legado.app.lib.theme.primaryColor @@ -91,9 +92,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification } override fun onDestroy() { - val sourceOrigin = arguments?.getString("sourceOrigin") - val key = "${sourceOrigin}_verificationResult" - CacheManager.get(key) ?: CacheManager.putMemory(key, "") + SourceVerificationHelp.checkResult() super.onDestroy() activity?.finish() } diff --git a/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt b/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt index 055d3509c..2f5de2a23 100644 --- a/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt +++ b/app/src/main/java/io/legado/app/ui/browser/WebViewActivity.kt @@ -17,6 +17,7 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst import io.legado.app.databinding.ActivityWebViewBinding +import io.legado.app.help.SourceVerificationHelp import io.legado.app.help.config.AppConfig import io.legado.app.help.http.CookieStore import io.legado.app.lib.dialogs.SelectItem @@ -182,6 +183,7 @@ class WebViewActivity : VMBaseActivity() { } override fun onDestroy() { + SourceVerificationHelp.checkResult() super.onDestroy() binding.webView.destroy() }