优化
This commit is contained in:
@@ -135,6 +135,7 @@ object PreferKey {
|
||||
const val shrinkDatabase = "shrinkDatabase"
|
||||
const val batchChangeSourceDelay = "batchChangeSourceDelay"
|
||||
const val openBookInfoByClickTitle = "openBookInfoByClickTitle"
|
||||
const val defaultHomePage = "defaultHomePage"
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
|
||||
@@ -429,6 +429,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
val onlyLatestBackup get() = appCtx.getPrefBoolean(PreferKey.onlyLatestBackup, true)
|
||||
|
||||
val defaultHomePage get() = appCtx.getPrefString(PreferKey.defaultHomePage, "bookshelf")
|
||||
|
||||
val doublePageHorizontal: String?
|
||||
get() = appCtx.getPrefString(PreferKey.doublePageHorizontal)
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
bottomNavigationView.setOnNavigationItemSelectedListener(this@MainActivity)
|
||||
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity)
|
||||
}
|
||||
upHomePage()
|
||||
onBackPressedDispatcher.addCallback(this) {
|
||||
if (pagePosition != 0) {
|
||||
binding.viewPagerMain.currentItem = 0
|
||||
@@ -369,6 +370,21 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun upHomePage() {
|
||||
when (AppConfig.defaultHomePage) {
|
||||
"bookshelf" -> {}
|
||||
"explore" -> if (AppConfig.showDiscovery) {
|
||||
binding.viewPagerMain.setCurrentItem(realPositions.indexOf(idExplore), false)
|
||||
}
|
||||
|
||||
"rss" -> if (AppConfig.showRSS) {
|
||||
binding.viewPagerMain.setCurrentItem(realPositions.indexOf(idRss), false)
|
||||
}
|
||||
|
||||
"my" -> binding.viewPagerMain.setCurrentItem(realPositions.indexOf(idMy), false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFragmentId(position: Int): Int {
|
||||
val id = realPositions[position]
|
||||
if (id == idBookshelf) {
|
||||
|
||||
Reference in New Issue
Block a user