/// <summary> /// Called when a menu item has been selected /// </summary> /// <param name="item"></param> /// <returns></returns> public override bool OnOptionsItemSelected(IMenuItem item) { bool handled = false; int id = item.ItemId; // Let the main command router have a look first if (CommandRouter.HandleCommand(id) == true) { handled = true; } // Pass on a collapse request to the adapter else if (id == Resource.Id.action_collapse) { Adapter.OnCollapseRequest(); handled = true; } else if (id == Resource.Id.filter) { FilterSelector?.SelectFilter(); } if (handled == false) { handled = base.OnOptionsItemSelected(item); } return(handled); }
/// <summary> /// Bind to the specified view. /// </summary> /// <param name="menu"></param> public override void BindToView(View view, Context context) { if (view != null) { // Find the textview to display the library name and install a click handler titleTextView = view.FindViewById <TextView>(Resource.Id.toolbar_title); // Find the playback_info menu item if it exists if (titleTextView != null) { // Create a Popup for this text view and route it's selections to the CommandRouter titlePopup = new PopupMenu(context, titleTextView); titlePopup.Inflate(Resource.Menu.menu_library); titlePopup.MenuItemClick += (sender, args) => { CommandRouter.HandleCommand(args.Item.ItemId); }; // Show the popup when the textview is selected titleTextView.Click += (sender, args) => { titlePopup.Show(); }; LibraryNameDisplayController.DataReporter = this; } } else { titleTextView = null; titlePopup = null; } }
/// <summary> /// Called to handle the command. /// </summary> /// <param name="commandIdentity"></param> public override void HandleCommand(int commandIdentity) { // Create a Popup menu containing the Autoplay options PopupMenu autoplayMenu = new PopupMenu(commandButton.Context, commandButton); autoplayMenu.Inflate(Resource.Menu.menu_autoplay); autoplayMenu.MenuItemClick += (sender, args) => { CommandRouter.HandleCommand(args.Item.ItemId, selectedObjects.SelectedObjects, commandCallback, commandButton); }; autoplayMenu.Show(); }
/// <summary> /// Called when one of the main toolbar menu items has been selected /// </summary> /// <param name="item"></param> /// <returns></returns> public override bool OnOptionsItemSelected(IMenuItem item) { bool handled = false; int id = item.ItemId; // Let the CommandRouter have first go if (CommandRouter.HandleCommand(id) == true) { handled = true; } // If the selection has not been handled pass it on to the base class if (handled == false) { handled = base.OnOptionsItemSelected(item); } return(handled); }
/// <summary> /// Bind to the specified menu item. /// Replace the standard view associated with the menu item with our own reduced margin version /// Store the AppCompatImageButton from the view so that the icon can be changed. /// Add an event handler for the button. /// </summary> /// <param name="menu"></param> public override void BindToMenu(IMenu menu, Context context, View activityContent) { if (menu != null) { // Find the playback_info menu item if it exists IMenuItem boundMenuItem = menu.FindItem(Resource.Id.playback_mode); if (boundMenuItem != null) { boundMenuItem.SetActionView(Resource.Layout.toolbarButton); imageButton = boundMenuItem.ActionView.FindViewById <AppCompatImageButton>(Resource.Id.toolbarSpecialButton); // Create a Popup for this button and route it's selections to the CommandRouter titlePopup = new PopupMenu(context, imageButton); titlePopup.Inflate(Resource.Menu.menu_playback); titlePopup.MenuItemClick += (sender, args) => { CommandRouter.HandleCommand(args.Item.ItemId); }; // Show the popup when the button is selected imageButton.Click += (sender, args) => { // Set the submenu item text according to the current state of the individual playback attributes titlePopup.Menu.FindItem(Resource.Id.repeat_on_off).SetTitle(PlaybackModeModel.RepeatOn ? "Repeat off" : "Repeat on"); titlePopup.Menu.FindItem(Resource.Id.shuffle_on_off).SetTitle(PlaybackModeModel.ShuffleOn ? "Shuffle off" : "Shuffle on"); titlePopup.Menu.FindItem(Resource.Id.auto_on_off).SetTitle(PlaybackModeModel.AutoOn ? "Auto off" : "Auto on"); titlePopup.Show(); }; DisplayPlaybackIcon(); } PlaybackModeController.DataReporter = this; } else { imageButton = null; titlePopup = null; } }