This commit is contained in:
Horis
2023-09-15 15:17:49 +08:00
parent 4dd04fe0d7
commit 5f42c6db26
14 changed files with 33 additions and 4 deletions
@@ -137,6 +137,7 @@ object PreferKey {
const val batchChangeSourceDelay = "batchChangeSourceDelay"
const val openBookInfoByClickTitle = "openBookInfoByClickTitle"
const val defaultHomePage = "defaultHomePage"
const val showBookshelfFastScroller = "showBookshelfFastScroller"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"
@@ -403,6 +403,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefBoolean(PreferKey.openBookInfoByClickTitle, value)
}
var showBookshelfFastScroller: Boolean
get() = appCtx.getPrefBoolean(PreferKey.showBookshelfFastScroller, false)
set(value) {
appCtx.putPrefBoolean(PreferKey.showBookshelfFastScroller, value)
}
var contentSelectSpeakMod: Int
get() = appCtx.getPrefInt(PreferKey.contentSelectSpeakMod)
set(value) {
@@ -168,6 +168,10 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
AppConfig.showWaitUpCount = swShowWaitUpBooks.isChecked
activityViewModel.postUpBooksLiveData(true)
}
if (AppConfig.showBookshelfFastScroller != swShowBookshelfFastScroller.isChecked) {
AppConfig.showBookshelfFastScroller = swShowBookshelfFastScroller.isChecked
postEvent(EventBus.BOOKSHELF_REFRESH, "")
}
if (bookshelfSort != rgSort.getCheckedIndex()) {
AppConfig.bookshelfSort = rgSort.getCheckedIndex()
upSort()
@@ -86,6 +86,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
private fun initRecyclerView() {
binding.rvBookshelf.setEdgeEffectColor(primaryColor)
binding.rvBookshelf.setFastScrollEnabled(AppConfig.showBookshelfFastScroller)
binding.refreshLayout.setColorSchemeColors(accentColor)
binding.refreshLayout.setOnRefreshListener {
binding.refreshLayout.isRefreshing = false
@@ -275,6 +276,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
observeEvent<String>(EventBus.BOOKSHELF_REFRESH) {
booksAdapter.notifyDataSetChanged()
startLastUpdateTimeJob()
binding.rvBookshelf.setFastScrollEnabled(AppConfig.showBookshelfFastScroller)
}
}
}
}