예제 #1
0
        public override void FollowArtist()
        {
            IsHighlighted = true;

            if (!SpotifyCacheService.IsArtistFollowed(_newReleaseItem.Artist))
            {
                SpotifyCacheService.FollowArtist(_newReleaseItem.Artist);
            }
        }
예제 #2
0
        public override void UnfollowArtist()
        {
            IsHighlighted = false;

            if (SpotifyCacheService.IsArtistFollowed(_newReleaseItem.Artist))
            {
                SpotifyCacheService.UnfollowArtist(_newReleaseItem.Artist);
            }
        }
예제 #3
0
        public override void FollowArtist()
        {
            IsHighlighted = true;

            if (!SpotifyCacheService.IsArtistFollowed(ArtistViewModel.Artist))
            {
                SpotifyCacheService.FollowArtist(ArtistViewModel.Artist);
            }
        }
예제 #4
0
        public override void UnfollowArtist()
        {
            IsHighlighted = false;

            if (SpotifyCacheService.IsArtistFollowed(ArtistViewModel.Artist))
            {
                SpotifyCacheService.UnfollowArtist(ArtistViewModel.Artist);
            }
        }
예제 #5
0
        public ArtistNetworkNodeViewModel(
            ArtistViewModel viewModel,
            AtlasHierarchy hierarchy,
            IHierarchyNode hierarchyNode,
            IPlaylistView playlist)
            : base(viewModel.Name)
        {
            ArtistViewModel = viewModel;

            Debug.Assert(hierarchyNode is ArtistHierarchyNode);
            _hierarchyNode = (ArtistHierarchyNode)hierarchyNode;
            _hierarchy     = hierarchy;
            _playlist      = playlist;

            _numTracks = GetArtistTrackCount();

            IsHighlighted = SpotifyCacheService.IsArtistFollowed(ArtistViewModel.Artist);
        }
예제 #6
0
        /// <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();
        }
예제 #7
0
        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();
        }