switch to the Player tab on clicking Search

This commit is contained in:
tibbi 2023-01-14 22:24:33 +01:00
parent 43cd82cce6
commit 4f98921aab
3 changed files with 19 additions and 0 deletions

View File

@ -95,6 +95,14 @@ class MainActivity : SimpleActivity() {
main_menu.toggleHideOnScroll(false) main_menu.toggleHideOnScroll(false)
main_menu.setupMenu() main_menu.setupMenu()
main_menu.onSearchOpenListener = {
view_pager.currentItem = 1
}
main_menu.onSearchTextChangedListener = { text ->
getPagerAdapter()?.searchTextChanged(text)
}
main_menu.getToolbar().setOnMenuItemClickListener { menuItem -> main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) { when (menuItem.itemId) {
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent() R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
@ -142,6 +150,9 @@ class MainActivity : SimpleActivity() {
main_tabs_holder.onTabSelectionChanged( main_tabs_holder.onTabSelectionChanged(
tabUnselectedAction = { tabUnselectedAction = {
updateBottomTabItemColors(it.customView, false) updateBottomTabItemColors(it.customView, false)
if (it.position == 1) {
main_menu.closeSearch()
}
}, },
tabSelectedAction = { tabSelectedAction = {
view_pager.currentItem = it.position view_pager.currentItem = it.position

View File

@ -43,4 +43,8 @@ class ViewPagerAdapter(private val activity: SimpleActivity) : PagerAdapter() {
} }
fun finishActMode() = (mFragments[1] as? PlayerFragment)?.finishActMode() fun finishActMode() = (mFragments[1] as? PlayerFragment)?.finishActMode()
fun searchTextChanged(text: String) {
(mFragments[1] as? PlayerFragment)?.onSearchTextChanged(text)
}
} }

View File

@ -390,6 +390,10 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
player_progress_max.text = (recording?.duration ?: 0).getFormattedDuration() player_progress_max.text = (recording?.duration ?: 0).getFormattedDuration()
} }
fun onSearchTextChanged(text: String) {
}
private fun togglePlayPause() { private fun togglePlayPause() {
if (getIsPlaying()) { if (getIsPlaying()) {
pausePlayback() pausePlayback()