pull/1732/head
kunfei 3 years ago
parent 7e20ed731d
commit dec5d386bc
  1. 18
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -91,10 +91,14 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run {
when (item.itemId) {
R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false)
R.id.menu_discovery -> openPage(idExplore)
R.id.menu_rss -> openPage(idRss)
R.id.menu_my_config -> openPage(idMy)
R.id.menu_bookshelf ->
viewPagerMain.setCurrentItem(0, false)
R.id.menu_discovery ->
viewPagerMain.setCurrentItem(realPositions.indexOf(idExplore), false)
R.id.menu_rss ->
viewPagerMain.setCurrentItem(realPositions.indexOf(idRss), false)
R.id.menu_my_config ->
viewPagerMain.setCurrentItem(realPositions.indexOf(idMy), false)
}
return false
}
@ -118,12 +122,6 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
}
}
private fun openPage(id: Int) {
realPositions.indexOf(id).let { index ->
binding.viewPagerMain.setCurrentItem(index, false)
}
}
private fun upVersion() {
if (LocalConfig.versionCode != appInfo.versionCode) {
LocalConfig.versionCode = appInfo.versionCode

Loading…
Cancel
Save