diff --git a/app/src/main/java/io/legado/app/help/CacheManager.kt b/app/src/main/java/io/legado/app/help/CacheManager.kt index a79bb2720..e9e597648 100644 --- a/app/src/main/java/io/legado/app/help/CacheManager.kt +++ b/app/src/main/java/io/legado/app/help/CacheManager.kt @@ -35,6 +35,11 @@ object CacheManager { } } + fun putMemory(key: String, value: Any) { + val cache = Cache(key, value.toString(), 0) + memoryLruCache.put(key, cache) + } + fun get(key: String): String? { getFromMemory(key)?.let { return it 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 a1c6bb928..a38f17cfc 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 @@ -19,7 +19,7 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding /** * 图片验证码对话框 - * 结果保存在数据库中 + * 结果保存在内存中 * val key = "${sourceOrigin ?: ""}_verificationResult" * CacheManager.get(key) */ @@ -64,7 +64,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification tvOk.setOnClickListener { val verificationCode = binding.verificationCode.text.toString() verificationCode.let { - CacheManager.put(key, it) + CacheManager.putMemory(key, it) dismiss() } } @@ -77,7 +77,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification override fun onDestroy() { val sourceOrigin = arguments?.getString("sourceOrigin") val key = "${sourceOrigin}_verificationResult" - CacheManager.get(key) ?: CacheManager.put(key, "") + CacheManager.get(key) ?: CacheManager.putMemory(key, "") super.onDestroy() activity?.finish() } diff --git a/app/src/main/java/io/legado/app/ui/browser/WebViewModel.kt b/app/src/main/java/io/legado/app/ui/browser/WebViewModel.kt index 7471db654..f3fb99798 100644 --- a/app/src/main/java/io/legado/app/ui/browser/WebViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/browser/WebViewModel.kt @@ -87,7 +87,7 @@ class WebViewModel(application: Application) : BaseViewModel(application) { if (sourceVerificationEnable) { val key = "${sourceOrigin}_verificationResult" html = AnalyzeUrl(baseUrl, headerMapF = headerMap).getStrResponse(useWebView = false).body - CacheManager.put(key, html ?: "") + CacheManager.putMemory(key, html ?: "") } }