/// <summary>
        /// Called when a library has been selected.
        /// </summary>
        /// <param name="selectedLibrary"></param>
        private void NameEntered(string playlistName, NewPlaylistNameDialogFragment playlistNameFragment, bool _)
        {
            string alertText = "";

            if (playlistName.Length == 0)
            {
                alertText = "An empty name is not valid.";
            }
            else if (playlistName == selectedObjects.Playlists[0].Name)
            {
                alertText = "Name not changed.";
            }
            else if (PlaylistsViewModel.PlaylistNames.Contains(playlistName) == true)
            {
                alertText = "A playlist with that name already exists.";
            }
            else
            {
                PlaylistsController.RenamePlaylist(selectedObjects.Playlists[0], playlistName);
                playlistNameFragment.Dismiss();
                commandCallback.PerformAction();
            }

            // Display an error message if the playlist name is not valid. Do not dismiss the dialog
            if (alertText.Length > 0)
            {
                NotificationDialogFragment.ShowFragment(CommandRouter.Manager, alertText);
            }
        }
        /// <summary>
        /// Show an alert dialogue with the specified Title and a single OK button
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="title"></param>
        public static void ShowFragment(FragmentManager manager, string title)
        {
            NotificationDialogFragment dialog = new NotificationDialogFragment {
                Arguments = new Bundle()
            };

            dialog.Arguments.PutString("title", title);
            dialog.Show(manager, "fragment_notification_tag");
        }
Пример #3
0
        /// <summary>
        /// Called when a playlist name has been entered has been selected.
        /// </summary>
        /// <param name="selectedLibrary"></param>
        private async void NameEntered(string playlistName, NewPlaylistNameDialogFragment playlistNameFragment, bool isAlbum)
        {
            string alertText = "";

            // An empty playlist name is not allowed
            if (playlistName.Length == 0)
            {
                alertText = EmptyNameError;
            }
            else
            {
                // Check for a duplicate
                if (PlaylistsViewModel.PlaylistNames.Contains(playlistName) == true)
                {
                    alertText = DuplicatePlaylistError;
                }
                else
                {
                    // Create a SongPlaylist or AlbumPlaylist as appropriate and add the Songs/Albums to it
                    if (isAlbum == false)
                    {
                        // Create the playlist and add the songs to it
                        // Need to wait for the playlist to be stored as we are going to access it's Id straight away
                        SongPlaylist newPlaylist = await PlaylistsController.AddSongPlaylistAsync(playlistName);

                        PlaylistsController.AddSongsToPlaylist(selectedObjects.Songs, newPlaylist);
                    }
                    else
                    {
                        AlbumPlaylist newPlaylist = await PlaylistsController.AddAlbumPlaylistAsync(playlistName);

                        PlaylistsController.AddAlbumsToPlaylist(selectedObjects.Albums, newPlaylist);
                    }
                }
            }

            // Display an error message if the playlist name is not valid.
            if (alertText.Length > 0)
            {
                NotificationDialogFragment.ShowFragment(CommandRouter.Manager, alertText);
            }
            else
            {
                // Dismiss the playlist name dialogue and finally perform the command callback (exit action mode)
                playlistNameFragment.Dismiss();
                commandCallback.PerformAction();
            }
        }