Merge pull request #2002 from 821938089/master

fix 自动刷新
pull/2005/head
kunfei 2 years ago committed by GitHub
commit 0f04eaee3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -88,7 +88,8 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
upVersion() upVersion()
privacyPolicy() privacyPolicy()
//自动更新书籍 //自动更新书籍
if (AppConfig.autoRefreshBook) { val isAutoRefreshedBook = savedInstanceState?.getBoolean("isAutoRefreshedBook") ?: false
if (AppConfig.autoRefreshBook && !isAutoRefreshedBook) {
binding.viewPagerMain.postDelayed(1000) { binding.viewPagerMain.postDelayed(1000) {
viewModel.upAllBookToc() viewModel.upAllBookToc()
} }
@ -210,6 +211,13 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
return super.onKeyUp(keyCode, event) return super.onKeyUp(keyCode, event)
} }
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
if (AppConfig.autoRefreshBook) {
outState.putBoolean("isAutoRefreshedBook", true)
}
}
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
Coroutine.async { Coroutine.async {

Loading…
Cancel
Save