This commit is contained in:
kunfei 2020-02-09 13:02:02 +08:00
parent c2a8b9bd8b
commit b9e369ac0e
4 changed files with 14 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package io.legado.app.help
import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.utils.*
@ -44,6 +45,9 @@ object AppConfig {
App.INSTANCE.putPrefBoolean(PreferKey.showRss, value)
}
val autoRefreshBook: Boolean
get() = App.INSTANCE.getPrefBoolean(App.INSTANCE.getString(R.string.pk_auto_refresh))
var threadCount: Int
get() = App.INSTANCE.getPrefInt(PreferKey.threadCount, 16)
set(value) {

View File

@ -15,7 +15,7 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.delay
class MainViewModel(application: Application) : BaseViewModel(application) {
val updateList = arrayListOf<String>()
val updateList = hashSetOf<String>()
fun upChapterList() {
execute {

View File

@ -17,6 +17,7 @@ import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookGroup
import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.*
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
@ -26,7 +27,9 @@ import io.legado.app.ui.book.group.GroupManageDialog
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.download.DownloadActivity
import io.legado.app.ui.importbook.ImportBookActivity
import io.legado.app.ui.main.MainViewModel
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_change_source.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.fragment_bookshelf.*
import kotlinx.android.synthetic.main.view_tab_layout.*
@ -51,6 +54,11 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
setSupportToolbar(toolbar)
initRecyclerView()
initBookGroupData()
if (AppConfig.autoRefreshBook) {
recycler_view.postDelayed({
getViewModelOfActivity(MainViewModel::class.java).updateList
}, 1000)
}
}
override fun onCompatCreateOptionsMenu(menu: Menu) {

View File

@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<io.legado.app.lib.theme.prefs.ATESwitchPreference
android:defaultValue="true"
android:defaultValue="false"
android:key="@string/pk_auto_refresh"
android:summary="@string/ps_auto_refresh"
android:title="@string/pt_auto_refresh"