diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index c53a4898f..7eec1a6fb 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -91,10 +91,14 @@ class MainActivity : VMBaseActivity(), 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(), } } - 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