Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Base constructor which must be implemented if it is to successfully inherit from the Application
        /// class.
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="transfer"></param>
        public MainApp(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer)
        {
            instance = this;

            // Set up logging
            Logger.Reporter = this;

            // Initialise the storage
            InitialiseStorage();

            // Bind the command handlers to their command identities
            CommandRouter.BindHandlers();

            // Configure the controllers
            ConfigureControllers();

            // Initialise the network monitoring
            deviceDiscoverer = new DeviceDiscovery(Context);

            // Create a PlaybackRouter.
            playbackRouter = new PlaybackRouter(Context);

            // Start the MediaNotificationService
            mediaNotificationServiceInterface = new MediaNotificationServiceInterface(Context);

            // Start the ApplicationShutdownService
            applicationShutdownInterface = new ApplicationShutdownInterface(Context);
        }
Ejemplo n.º 3
0
        /// <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;
            }
        }
Ejemplo n.º 4
0
        /// <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();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Use the command handler associated with each button to determine if the button should be shown
 /// </summary>
 /// <param name="selectedObjects"></param>
 public void DetermineButtonsVisibility(GroupedSelection selectedObjects)
 {
     foreach (KeyValuePair <int, AppCompatImageButton> buttonPair in Buttons)
     {
         // Is there a command handler associated with this button
         CommandHandler handler = CommandRouter.GetHandlerForCommand(buttonPair.Key);
         if (handler != null)
         {
             buttonPair.Value.Visibility =
                 (handler.IsSelectionValidForCommand(selectedObjects, buttonPair.Key) == true) ? ViewStates.Visible : ViewStates.Gone;
         }
     }
 }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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;
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Bind this command to the router. An override is required here as this command can be launched using two identities
 /// </summary>
 public override void BindToRouter()
 {
     CommandRouter.BindHandler(CommandIdentity, this);
     CommandRouter.BindHandler(Resource.Id.auto_queue, this);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Bind this command to the router. An override is required here as this command can be launched using two identities
 /// </summary>
 public override void BindToRouter()
 {
     CommandRouter.BindHandler(CommandIdentity, this);
     CommandRouter.BindHandler(Resource.Id.play_now, this);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Bind this command to the router using its command identity
 /// </summary>
 public virtual void BindToRouter() => CommandRouter.BindHandler(CommandIdentity, this);