|
|
|
@ -170,28 +170,32 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), |
|
|
|
|
private inner class TabFragmentPageAdapter(fm: FragmentManager) : |
|
|
|
|
FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { |
|
|
|
|
|
|
|
|
|
private fun getBookshelfFragment(): Fragment { |
|
|
|
|
val bookshelfFragment: Fragment |
|
|
|
|
get() { |
|
|
|
|
if (!fragmentMap.containsKey(0)) { |
|
|
|
|
fragmentMap[0] = BookshelfFragment() |
|
|
|
|
} |
|
|
|
|
return fragmentMap.getValue(0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun getExploreFragment(): Fragment { |
|
|
|
|
val exploreFragment: Fragment |
|
|
|
|
get() { |
|
|
|
|
if (!fragmentMap.containsKey(1)) { |
|
|
|
|
fragmentMap[1] = ExploreFragment() |
|
|
|
|
} |
|
|
|
|
return fragmentMap.getValue(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun getRssFragment(): Fragment { |
|
|
|
|
val rssFragment: Fragment |
|
|
|
|
get() { |
|
|
|
|
if (!fragmentMap.containsKey(2)) { |
|
|
|
|
fragmentMap[2] = RssFragment() |
|
|
|
|
} |
|
|
|
|
return fragmentMap.getValue(2) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun getMyFragment(): Fragment { |
|
|
|
|
val myFragment: Fragment |
|
|
|
|
get() { |
|
|
|
|
if (!fragmentMap.containsKey(3)) { |
|
|
|
|
fragmentMap[3] = MyFragment() |
|
|
|
|
} |
|
|
|
@ -204,14 +208,10 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), |
|
|
|
|
|
|
|
|
|
override fun getItem(position: Int): Fragment { |
|
|
|
|
return when (position) { |
|
|
|
|
0 -> getBookshelfFragment() |
|
|
|
|
1 -> getExploreFragment() |
|
|
|
|
2 -> if (AppConfig.isShowRSS) { |
|
|
|
|
getRssFragment() |
|
|
|
|
} else { |
|
|
|
|
getMyFragment() |
|
|
|
|
} |
|
|
|
|
else -> getMyFragment() |
|
|
|
|
0 -> bookshelfFragment |
|
|
|
|
1 -> exploreFragment |
|
|
|
|
2 -> if (AppConfig.isShowRSS) rssFragment else myFragment |
|
|
|
|
else -> myFragment |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|