/// <summary> /// Populates the Atlas with all followed artists. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnFollowedArtists(object sender, RoutedEventArgs e) { //Clear the Atlas, clear the playlist selection too. //Show all artists you're following. _atlasViewMode = AtlasViewMode.FollowedArtistView; //Clear the playlist selection. NavigationControl navigationControl = (NavigationControl)sender; navigationControl.SelectPlaylist(null); OnPlaylistSelectionChanged(navigationControl, e); //Add all followed artists to the hierarchy. FollowedArtistList followedArtists = SpotifyCacheService.GetFollowedArtists(); AtlasViewOptions viewOptions = new AtlasViewOptions(0); this.AtlasView.ViewModel.CreateFollowedArtistHierarchy(followedArtists.ArtistItems.Items.AsReadOnly(), viewOptions); this.AtlasView.UpdateNetwork(); }
private void OnNewReleases(object sender, RoutedEventArgs e) { _atlasViewMode = AtlasViewMode.NewReleasesView; //Clear the playlist selection. NavigationControl navigationControl = (NavigationControl)sender; navigationControl.SelectPlaylist(null); OnPlaylistSelectionChanged(navigationControl, e); List <NewReleaseItem> newsItems = new List <NewReleaseItem>(); //Add artists that have new releases. //System.Threading.Tasks.Task.Run(() => { AlbumType filter = AlbumType.Album | AlbumType.Single; DateTime cutoff = DateTime.Now.AddMonths(-3); //TODO: Data-drive this setting. int maxSuggestions = 1; //TODO: Data-drive this setting. FollowedArtistList followedArtists = SpotifyCacheService.GetFollowedArtists(); foreach (Artist followedArtist in followedArtists.ArtistItems.Items) { //Find if there's any new content available from this artist. AlbumInfoList albums = SpotifyClientService.Client.GetArtistAlbums(followedArtist, filter); foreach (AlbumInfo album in albums.Items) { //if (_userCache.SeenNewsItem(album.ID)) continue; Album albumInfo = SpotifyClientService.Client.GetAlbum(album); if (albumInfo.ReleaseDate > cutoff) { newsItems.Add(new NewReleaseItem(followedArtist, albumInfo)); if (newsItems.Count >= maxSuggestions) { break; } } else { //Assume that albums are returned by Spotify by release date, descending. //If we miss the cutoff, skip out. break; } } } if (newsItems.Any()) { Dispatcher.Invoke(() => { //Display a popup. //this.NewsFeedPopup.DataContext = new NewsFeedViewModel(newsItems, userCache); //this.NewsFeedPopup.Width = this.RenderSize.Width * 0.8; //this.NewsFeedPopup.Height = this.RenderSize.Height * 0.8; //this.NewsFeedPopup.IsOpen = true; }); } } //); AtlasViewOptions viewOptions = new AtlasViewOptions(0); this.AtlasView.ViewModel.CreateNewReleaseHierarchy(newsItems.ToList().AsReadOnly(), viewOptions); this.AtlasView.UpdateNetwork(); }