Ejemplo n.º 1
0
        private async void FavoriteSureButton_Click(object sender, RoutedEventArgs e)
        {
            var removedList   = new List <string>();
            var addList       = new List <string>();
            var selectedItems = FavoriteListView.SelectedItems;

            foreach (var item in selectedItems)
            {
                var fav = item as FavoriteItem;
                if (fav.fav_state == 0)
                {
                    addList.Add(fav.id.ToString());
                }
            }
            foreach (var item in _tempFavorites)
            {
                if (item.fav_state == 1 && !selectedItems.Any(p => (p as FavoriteItem).id == item.id))
                {
                    removedList.Add(item.id.ToString());
                }
            }
            if (addList.Count > 0 || removedList.Count > 0)
            {
                FavoriteSureButton.IsLoading = true;
                bool result = await _videoService.AddVideoToFavoriteAsync(_detail.aid, addList, removedList);

                FavoriteSureButton.IsLoading = false;
                if (result)
                {
                    FavoriteFlyout.Hide();
                    FavoriteButton.IsCheck = selectedItems.Count > 0;
                    new TipPopup("已更改收藏夹").ShowMessage();
                    UpdateVideoInfo();
                }
                else
                {
                    new TipPopup("收藏失败").ShowError();
                }
            }
            CheckLikeHoldState();
        }