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

@ -92,7 +92,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run { override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run {
when (item.itemId) { when (item.itemId) {
R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false) R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false)
R.id.menu_discovery -> viewPagerMain.setCurrentItem(1, false) R.id.menu_discovery -> openPage(idExplore)
R.id.menu_rss -> openPage(idRss) R.id.menu_rss -> openPage(idRss)
R.id.menu_my_config -> openPage(idMy) R.id.menu_my_config -> openPage(idMy)
} }
@ -119,9 +119,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
} }
private fun openPage(id: Int) { private fun openPage(id: Int) {
realPositions.firstOrNull { realPositions.indexOf(id).let { index ->
it == id
}?.let { index ->
binding.viewPagerMain.setCurrentItem(index, false) binding.viewPagerMain.setCurrentItem(index, false)
} }
} }

Loading…
Cancel
Save