Merge pull request #220 from esensar/fix/tab-color
Fix inactive tab onResume update when there are 3 tabs
This commit is contained in:
commit
673110e489
|
@ -70,11 +70,11 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupTabColors()
|
|
||||||
updateMenuColors()
|
updateMenuColors()
|
||||||
if (getPagerAdapter()?.showRecycleBin != config.useRecycleBin) {
|
if (getPagerAdapter()?.showRecycleBin != config.useRecycleBin) {
|
||||||
setupViewPager()
|
setupViewPager()
|
||||||
}
|
}
|
||||||
|
setupTabColors()
|
||||||
getPagerAdapter()?.onResume()
|
getPagerAdapter()?.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,9 +207,13 @@ class MainActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||||
val inactiveView = binding.mainTabsHolder.getTabAt(getInactiveTabIndex())?.customView
|
|
||||||
updateBottomTabItemColors(activeView, true)
|
updateBottomTabItemColors(activeView, true)
|
||||||
updateBottomTabItemColors(inactiveView, false)
|
for (i in 0 until binding.mainTabsHolder.tabCount) {
|
||||||
|
if (i != binding.viewPager.currentItem) {
|
||||||
|
val inactiveView = binding.mainTabsHolder.getTabAt(i)?.customView
|
||||||
|
updateBottomTabItemColors(inactiveView, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.select()
|
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.select()
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
|
@ -217,8 +221,6 @@ class MainActivity : SimpleActivity() {
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndex() = if (binding.viewPager.currentItem == 0) 1 else 0
|
|
||||||
|
|
||||||
private fun getPagerAdapter() = (binding.viewPager.adapter as? ViewPagerAdapter)
|
private fun getPagerAdapter() = (binding.viewPager.adapter as? ViewPagerAdapter)
|
||||||
|
|
||||||
private fun launchSettings() {
|
private fun launchSettings() {
|
||||||
|
|
Loading…
Reference in New Issue