From e65e2259f9ef69856014d1465a317ea33bf56966 Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Wed, 29 Jun 2022 08:26:50 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/main/MainActivity.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index ee7d85737..26d0bcd8c 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -88,7 +88,8 @@ class MainActivity : VMBaseActivity(), upVersion() privacyPolicy() //自动更新书籍 - if (AppConfig.autoRefreshBook) { + val isAutoRefreshedBook = savedInstanceState?.getBoolean("isAutoRefreshedBook") ?: false + if (AppConfig.autoRefreshBook && !isAutoRefreshedBook) { binding.viewPagerMain.postDelayed(1000) { viewModel.upAllBookToc() } @@ -210,6 +211,13 @@ class MainActivity : VMBaseActivity(), return super.onKeyUp(keyCode, event) } + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + if (AppConfig.autoRefreshBook) { + outState.putBoolean("isAutoRefreshedBook", true) + } + } + override fun onDestroy() { super.onDestroy() Coroutine.async {