Hide FAB on search suggestions
This commit is contained in:
@@ -42,8 +42,8 @@ import org.koitharu.kotatsu.history.ui.HistoryListFragment
|
||||
import org.koitharu.kotatsu.local.ui.LocalListFragment
|
||||
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
||||
import org.koitharu.kotatsu.remotelist.ui.RemoteListFragment
|
||||
import org.koitharu.kotatsu.search.ui.SearchActivity
|
||||
import org.koitharu.kotatsu.search.ui.MangaListActivity
|
||||
import org.koitharu.kotatsu.search.ui.SearchActivity
|
||||
import org.koitharu.kotatsu.search.ui.global.GlobalSearchActivity
|
||||
import org.koitharu.kotatsu.search.ui.suggestion.SearchSuggestionFragment
|
||||
import org.koitharu.kotatsu.search.ui.suggestion.SearchSuggestionListener
|
||||
@@ -358,17 +358,19 @@ class MainActivity : BaseActivity<ActivityMainBinding>(),
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.container, fragment, TAG_PRIMARY)
|
||||
.commit()
|
||||
if (fragment is HistoryListFragment) binding.fab.show() else binding.fab.hide()
|
||||
adjustFabVisibility(topFragment = fragment)
|
||||
}
|
||||
|
||||
private fun onSearchOpened() {
|
||||
binding.drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
||||
drawerToggle.isDrawerIndicatorEnabled = false
|
||||
adjustFabVisibility(isSearchOpened = true)
|
||||
}
|
||||
|
||||
private fun onSearchClosed() {
|
||||
binding.drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
|
||||
drawerToggle.isDrawerIndicatorEnabled = true
|
||||
adjustFabVisibility(isSearchOpened = false)
|
||||
}
|
||||
|
||||
private fun onFirstStart() {
|
||||
@@ -383,4 +385,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun adjustFabVisibility(
|
||||
topFragment: Fragment? = supportFragmentManager.findFragmentByTag(TAG_PRIMARY),
|
||||
isSearchOpened: Boolean = supportFragmentManager.findFragmentByTag(TAG_SEARCH)?.isVisible == true,
|
||||
) {
|
||||
if (!isSearchOpened && topFragment is HistoryListFragment) binding.fab.show() else binding.fab.hide()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user