Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
 public ITracklistViewModel CreateTracklistViewModel(TracklistViewModelParams p)
 => new TracklistViewModel(ServiceRegistry.PlatformServices,
                           ServiceRegistry.GetService <ITracklistDataController>(),
                           ServiceRegistry.FavouritesService,
                           p);