private async void Button_AddToPlaylist_Click(object sender, RoutedEventArgs e) { if (!PlayingService.IsPlayingSong) { return; } if (PlayingService.PlaylistItems_Created == null && PlayingService.PlaylistItems_Subscribed == null) { PlayingService.PlaylistItems_Created = new ObservableCollection <PlaylistItem>(); PlayingService.PlaylistItems_Subscribed = new ObservableCollection <PlaylistItem>(); MyPlaylistRoot myPlaylistRoot = await Task.Run(() => PlaylistService.GetMyPlaylist()); foreach (var temp in myPlaylistRoot.playlist) { if (temp.subscribed == "true") { PlayingService.PlaylistItems_Subscribed.Add(temp); } else { PlayingService.PlaylistItems_Created.Add(temp); } } myPlaylistRoot = null; } ListBox_CreatedPlaylist.ItemsSource = PlayingService.PlaylistItems_Created; await ContentDialog_CreatedPlaylist.ShowAsync(); }
private async void MyMusicList_Loaded(object sender, RoutedEventArgs e) { if (playlistItems_created == null && playlistItems_subscribed == null) { playlistItems_created = new ObservableCollection <PlaylistItem>(); playlistItems_subscribed = new ObservableCollection <PlaylistItem>(); MyPlaylistRoot myPlaylistRoot = await Task.Run(() => PlaylistService.GetMyPlaylist()); if (myPlaylistRoot == null || myPlaylistRoot.playlist == null) { NotifyPopup notifyPopup = new NotifyPopup("获取失败"); notifyPopup.Show(); return; } foreach (var temp in myPlaylistRoot.playlist) { if (temp.subscribed == "true") { playlistItems_subscribed.Add(temp); } else { playlistItems_created.Add(temp); } } myPlaylistRoot = null; } AdaptiveGridView_createdByMe.ItemsSource = playlistItems_created; AdaptiveGridView_subscribed.ItemsSource = playlistItems_subscribed; }