mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-03-04 19:47:44 +01:00
show the sorting menu button only at the Alarms tab
This commit is contained in:
parent
f5aef41a6e
commit
b7fdedb939
@ -81,11 +81,17 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu, menu)
|
||||
menu.apply {
|
||||
findItem(R.id.sort).isVisible = view_pager.currentItem == TAB_ALARM
|
||||
updateMenuItemColors(this)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.sort -> getViewPagerAdapter()?.showAlarmSortDialog()
|
||||
R.id.settings -> launchSettings()
|
||||
R.id.about -> launchAbout()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
@ -133,6 +139,7 @@ class MainActivity : SimpleActivity() {
|
||||
view_pager.adapter = ViewPagerAdapter(supportFragmentManager)
|
||||
view_pager.onPageChangeListener {
|
||||
main_tabs_holder.getTabAt(it)?.select()
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
val tabToOpen = intent.getIntExtra(OPEN_TAB, config.lastUsedViewPagerPage)
|
||||
|
@ -38,6 +38,10 @@ class ViewPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
|
||||
else -> throw RuntimeException("Trying to fetch unknown fragment id $position")
|
||||
}
|
||||
|
||||
fun showAlarmSortDialog() {
|
||||
(fragments[TAB_ALARM] as? AlarmFragment)?.showSortingDialog()
|
||||
}
|
||||
|
||||
fun updateClockTabAlarm() {
|
||||
(fragments[TAB_CLOCK] as? ClockFragment)?.updateAlarm()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user