Added onPrepareOptionsMenu method to ViewController

This commit is contained in:
Ivan Vlasov 2019-03-22 00:13:45 +03:00
parent 8aa8432338
commit 953c998881
2 changed files with 17 additions and 0 deletions

View File

@ -171,6 +171,10 @@ open class ViewControllerFragment<TActivity : FragmentActivity, TState : Parcela
viewController?.onCreateOptionsMenu(menu, inflater)
}
override fun onPrepareOptionsMenu(menu: Menu?) {
viewController?.onPrepareOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean =
viewController?.onOptionsItemSelected(item) == true || super.onOptionsItemSelected(item)

View File

@ -160,6 +160,19 @@ open class ViewController<TActivity : FragmentActivity, TState : Parcelable>(
*/
open fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) = Unit
/**
* Prepare the standard options menu to be displayed. This is
* called right before the menu is shown, every time it is shown.
* You can use this method to efficiently enable/disable items or otherwise
* dynamically modify the contents.
*
* @param menu The options menu as last shown or first initialized by onCreateOptionsMenu().
*
* @see [Fragment.hasOptionsMenu]
* @see [onCreateOptionsMenu]
*/
open fun onPrepareOptionsMenu(menu: Menu?) = Unit
/**
* Calls right after construction of [ViewController].
* Happens at [ViewControllerFragment.onActivityCreated].