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

ClearItemsInList() public static méthode

Temporarily clears all items in a list Next time list contents will be refereshed online
public static ClearItemsInList ( string username, int id ) : void
username string
id int
Résultat void
        public static void ClearItemsInList(string username, int id)
        {
            // if we are adding to the current active list, then this is invalid and we dont care
            // if we are removing from the current list, we already take care of this ourselves
            // in all other cases we should clear
            if (GUIListItems.CurrentList != null && GUIListItems.CurrentList.Ids.Trakt == id && GUIListItems.CurrentUser == username)
                return;

            var listItems = GetListItemsForUser(username, id);
            if (listItems == null) return;

            // remove items
            UserListItems.Remove(username + ":" + id);
        }

Usage Example

Exemple #1
0
        internal static void AddRemoveItemInList(List <string> slugs, List <TraktListItem> items, bool remove)
        {
            Thread listThread = new Thread(delegate(object obj)
            {
                foreach (var slug in slugs)
                {
                    TraktList list = new TraktList
                    {
                        UserName = TraktSettings.Username,
                        Password = TraktSettings.Password,
                        Slug     = slug,
                        Items    = items
                    };
                    TraktSyncResponse response = null;
                    if (!remove)
                    {
                        response = TraktAPI.TraktAPI.ListAddItems(list);
                    }
                    else
                    {
                        response = TraktAPI.TraktAPI.ListDeleteItems(list);
                    }

                    TraktAPI.TraktAPI.LogTraktResponse <TraktSyncResponse>(response);
                    if (response.Status == "success")
                    {
                        // clear current items in any lists
                        // list items will be refreshed online if we try to request them
                        TraktLists.ClearItemsInList(TraktSettings.Username, slug);
                    }
                }
            })
            {
                Name         = remove ? "RemoveList" : "AddList",
                IsBackground = true
            };

            listThread.Start();
        }