TraktPlugin.TraktLists.GetListDetailsFromUser C# (CSharp) Méthode

GetListDetailsFromUser() public static méthode

Get all details needed to create a new list or edit existing list
public static GetListDetailsFromUser ( TraktListDetail &list ) : bool
list TraktPlugin.TraktAPI.DataStructures.TraktListDetail returns list details
Résultat bool
        public static bool GetListDetailsFromUser(ref TraktListDetail list)
        {
            // the list will have ids if it exists online
            bool editing = list.Ids != null;

            // Show Keyboard for Name of list
            string name = editing ? list.Name : string.Empty;
            if (!GUIUtils.GetStringFromKeyboard(ref name)) return false;
            if ((list.Name = name) == string.Empty) return false;

            // Skip Description and get Privacy...this requires a custom dialog as
            // virtual keyboard does not allow very much text for longer descriptions.
            // We may create a custom dialog for this in future
            var items = new List<GUIListItem>();
            var item = new GUIListItem();
            int selectedItem = 0;

            // Public
            item = new GUIListItem { Label = Translation.PrivacyPublic, Label2 = Translation.Public };
            if (list.Privacy == "public") { selectedItem = 0; item.Selected = true; }
            items.Add(item);
            // Private
            item = new GUIListItem { Label = Translation.PrivacyPrivate, Label2 = Translation.Private };
            if (list.Privacy == "private") { selectedItem = 1; item.Selected = true; }
            items.Add(item);
            // Friends
            item = new GUIListItem { Label = Translation.PrivacyFriends, Label2 = Translation.Friends };
            if (list.Privacy == "friends") { selectedItem = 2; item.Selected = true; }
            items.Add(item);

            selectedItem = GUIUtils.ShowMenuDialog(Translation.Privacy, items, selectedItem);
            if (selectedItem == -1) return false;

            list.Privacy = GetPrivacyLevelFromTranslation(items[selectedItem].Label2);

            // Skip 'Show Shouts' and 'Use Numbering' until we have Custom Dialog for List edits

            return true;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Get the slugs for each list selected by a user in the Multi-Select dialog
        /// </summary>
        /// <param name="username">username of user</param>
        /// <param name="lists">List of lists created by user</param>
        public static List <string> GetUserListSelections(List <TraktUserList> lists)
        {
            if (lists.Count == 0)
            {
                if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.NoListsFound, true))
                {
                    // nothing to do, return
                    return(null);
                }
                TraktList list = new TraktList();
                if (TraktLists.GetListDetailsFromUser(ref list))
                {
                    TraktLogger.Info("Creating new '{0}' list '{1}'", list.Privacy, list.Name);
                    TraktAddListResponse response = TraktAPI.TraktAPI.ListAdd(list);
                    TraktAPI.TraktAPI.LogTraktResponse <TraktResponse>(response);
                    if (response.Status == "success")
                    {
                        ClearCache(TraktSettings.Username);
                        return(new List <string> {
                            response.Slug
                        });
                    }
                }
                return(null);
            }

            List <MultiSelectionItem> selectedItems = GUIUtils.ShowMultiSelectionDialog(Translation.SelectLists, GetMultiSelectItems(lists));

            if (selectedItems == null)
            {
                return(null);
            }

            List <string> slugs = new List <string>();

            foreach (var item in selectedItems.Where(l => l.Selected == true))
            {
                slugs.Add(item.ItemID);
            }
            return(slugs);
        }
All Usage Examples Of TraktPlugin.TraktLists::GetListDetailsFromUser