public WhatsNewViewModel(IPlatformServices platformServices)
            : base(platformServices)
        {
            this.whatsNewDataController  = ServiceRegistry.GetService <IWhatsNewDataController>();
            this.genreListDataController = ServiceRegistry.GetService <IGenreListDataController>();

            this.genreList = new MainThreadObservableCollectionAdapter <IGenreViewModel>(this.genreListDataController.TheList,
                                                                                         PlatformServices.MainThreadDispatcher);

            this.newReleases = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.whatsNewDataController.NewReleases,
                                                                                           PlatformServices.MainThreadDispatcher);

            this.deezerPicks = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.whatsNewDataController.DeezerPicks,
                                                                                           PlatformServices.MainThreadDispatcher);

            this.genreListDataController.OnFetchStateChanged += OnGenreListFetchStateChanged;

            this.whatsNewDataController.OnNewReleaseFetchStateChanged  += OnNewReleaseFetchStateChanged;
            this.whatsNewDataController.OnDeezerPicksFetchStateChanged += OnDeezerPicksFetchStateChanged;

            this.selectedGenreIndex = this.genreList.Count == 0 ? 0
                                                                : this.genreList.Select((x, i) => new { Genre = x, Index = i })
                                      .Where(x => x.Genre.Id == this.whatsNewDataController.CurrentGenreFilter)
                                      .Single()
                                      .Index;

            this.whatsNewDataController.BeginPopulateAsync();
            this.genreListDataController.RefreshGenreListAsync();
        }
        public UserOverviewViewModel(IPlatformServices platformServices,
                                     UserOverviewViewModelParams p)
            : base(platformServices)
        {
            this.dataController = ServiceRegistry.GetService <IUserOverviewDataController>();

            this.flow = new MainThreadObservableCollectionAdapter <ITrackViewModel>(dataController.Flow,
                                                                                    PlatformServices.MainThreadDispatcher);

            this.playlists = new MainThreadObservableCollectionAdapter <IPlaylistViewModel>(dataController.Playlists,
                                                                                            PlatformServices.MainThreadDispatcher);

            this.dataController.OnFlowFetchStateChanged            += OnFlowFetchStateChanged;
            this.dataController.OnPlaylistFetchStateChanged        += OnPlaylistFetchStateChanged;
            this.dataController.OnCompleteProfileFetchStateChanged += OnHeaderFetchStateChanged;

            this.dataController.FetchUserProfileAsync(p.UserId);
        }
        public ChartsViewModel(IPlatformServices platformServices)
            : base(platformServices)
        {
            this.chartsDataController    = ServiceRegistry.GetService <IChartsDataController>();
            this.genreListDataController = ServiceRegistry.GetService <IGenreListDataController>();


            this.genreList = new MainThreadObservableCollectionAdapter <IGenreViewModel>(this.genreListDataController.TheList,
                                                                                         PlatformServices.MainThreadDispatcher);



            this.albums = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.chartsDataController.AlbumChart,
                                                                                      PlatformServices.MainThreadDispatcher);

            this.artists = new MainThreadObservableCollectionAdapter <IArtistViewModel>(this.chartsDataController.ArtistChart,
                                                                                        PlatformServices.MainThreadDispatcher);

            this.tracks = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.chartsDataController.TrackChart,
                                                                                      PlatformServices.MainThreadDispatcher);

            this.playlists = new MainThreadObservableCollectionAdapter <IPlaylistViewModel>(this.chartsDataController.PlaylistChart,
                                                                                            PlatformServices.MainThreadDispatcher);


            this.genreListDataController.OnFetchStateChanged += OnGenreListFetchStateChanged;

            this.chartsDataController.OnAlbumChartFetchStateChanged    += OnAlbumChartFetchStatusChanged;
            this.chartsDataController.OnArtistChartFetchStateChanged   += OnArtistChartFetchStatusChanged;
            this.chartsDataController.OnTrackChartFetchStateChanged    += OnTrackChartFetchStatusChanged;
            this.chartsDataController.OnPlaylistChartFetchStateChanged += OnPlaylistChartFetchStatusChanged;


            //TODO: Need stop this 'Begin' call required before executing the below LINQ command stuff
            this.chartsDataController.BeginPopulateAsync();
            this.genreListDataController.RefreshGenreListAsync();

            this.selectedGenreIndex = this.genreList.Count == 0 ? 0
                                                                : this.genreList.Select((x, i) => new { Genre = x, Index = i })
                                      .Where(x => x.Genre.Id == this.chartsDataController.CurrentGenreFilter)
                                      .SingleOrDefault()
                                      .Index;
        }
        public ArtistOverviewViewModel(IPlatformServices platformServices,
                                       IArtistOverviewDataController dataController,
                                       IFavouritesService favouritesService,
                                       ArtistOverviewViewModelParams p)
            : base(platformServices)
        {
            this.dataController    = dataController;
            this.favouritesService = favouritesService;

            this.albums = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.dataController.Albums,
                                                                                      PlatformServices.MainThreadDispatcher);

            this.topTracks = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.dataController.TopTracks,
                                                                                         PlatformServices.MainThreadDispatcher);

            this.relatedArtists = new MainThreadObservableCollectionAdapter <IArtistViewModel>(this.dataController.RelatedArtists,
                                                                                               PlatformServices.MainThreadDispatcher);

            this.featuredPlaylists = new MainThreadObservableCollectionAdapter <IPlaylistViewModel>(this.dataController.Playlists,
                                                                                                    PlatformServices.MainThreadDispatcher);

            // TODO: Default artwork for artist...
            // NEEDS to be done before the fetch status changed is added, as event will fire before we've set fallback
            this.ArtistId = p.ArtistId;

            this.ArtistImage = "ms-appx:///Assets/StoreLogo.png";


            this.dataController.OnAlbumFetchStateChanged          += OnAlbumFetchStateChanged;
            this.dataController.OnTopTrackFetchStateChanged       += OnTopTrackFetchStateChanged;
            this.dataController.OnPlaylistFetchStateChanged       += OnPlaylistFetchStateChanged;
            this.dataController.OnRelatedArtistFetchStateChanged  += OnRelatedArtistFetchStateChanged;
            this.dataController.OnCompleteArtistFetchStateChanged += OnCompleteArtistFetchStateChanged;

            this.dataController.FetchOverviewAsync(this.ArtistId);

            UpdateFavouriteState();
            this.favouritesService.OnFavouritesChanged += OnFavouritesChanged;
        }
Пример #5
0
        public TracklistViewModel(IPlatformServices platformServices,
                                  ITracklistDataController dataController,
                                  IFavouritesService favouritesService,
                                  TracklistViewModelParams p)
            : base(platformServices)
        {
            this.dataController    = dataController;
            this.favouritesService = favouritesService;

            this.tracklist = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.dataController.Tracklist,
                                                                                         PlatformServices.MainThreadDispatcher);

            this.ItemId = p.ItemId;
            this.Type   = p.Type;

            this.Title       = string.Empty;
            this.Subtitle    = string.Empty;
            this.ArtworkUri  = "ms-appx://Assets/StoreLogo.png";
            this.WebsiteLink = null;

            switch (this.Type)
            {
            case ETracklistViewModelType.Album:
                this.dataController.FetchTracklistAsync(ETracklistType.Album, this.ItemId);
                break;

            case ETracklistViewModelType.Playlist:
                this.dataController.FetchTracklistAsync(ETracklistType.Playlist, this.ItemId);
                break;
            }

            this.dataController.OnTracklistFetchStateChanged    += OnFetchStateChanged;
            this.dataController.OnCompleteItemFetchStateChanged += OnHeaderFetchStateChanged;

            this.favouritesService.OnFavouritesChanged += OnFavouritesChanged;

            UpdateFavouriteState();
        }
        public SearchViewModel(IPlatformServices platformServices)
            : base(platformServices)
        {
            this.dataController = ServiceRegistry.GetService <ISearchDataController>();

            this.albums = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.dataController.AlbumResults,
                                                                                      PlatformServices.MainThreadDispatcher);

            this.tracks = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.dataController.TrackResults,
                                                                                      PlatformServices.MainThreadDispatcher);

            this.artists = new MainThreadObservableCollectionAdapter <IArtistViewModel>(this.dataController.ArtistResults,
                                                                                        PlatformServices.MainThreadDispatcher);

            this.playlists = new MainThreadObservableCollectionAdapter <IPlaylistViewModel>(this.dataController.PlaylistResults,
                                                                                            PlatformServices.MainThreadDispatcher);


            this.dataController.OnAlbumResultsFetchStateChanged    += OnAlbumFetchStateChanged;
            this.dataController.OnTrackResultsFetchStateChanged    += OnTrackFetchStateChanged;
            this.dataController.OnArtistResultsFetchStateChanged   += OnArtistFetchStateChanged;
            this.dataController.OnPlaylistResultsFetchStateChanged += OnPlaylistFetchStateChanged;
        }
Пример #7
0
        public MyDeezerViewModel(IAuthenticationService authService,
                                 IMyDeezerDataController dataController,
                                 IPlatformServices platformServices)
            : base(platformServices)
        {
            this.authService    = authService;
            this.dataController = dataController;

            this.authService.OnAuthenticationStatusChanged += OnAuthenticationStatusChanged;

            this.favouriteTracks = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.dataController.FavouriteTracks,
                                                                                               PlatformServices.MainThreadDispatcher);

            this.favouriteAlbums = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.dataController.FavouriteAlbums,
                                                                                               PlatformServices.MainThreadDispatcher);

            this.favouriteArtists = new MainThreadObservableCollectionAdapter <IArtistViewModel>(this.dataController.FavouriteArtists,
                                                                                                 PlatformServices.MainThreadDispatcher);

            this.dataController.OnFavouriteAlbumFetchStateChanged   += OnFavouriteAlbumsFetchStateChanged;
            this.dataController.OnFavouriteTracksFetchStateChanged  += OnFavouriteTracksFetchStateChanged;
            this.dataController.OnFavouriteArtistsFetchStateChanged += OnFavouriteArtistFetchStateChanged;
        }