public static Album ToAlbum(this FullAlbum fullAlbum)
        {
            var album = new Album
            {
                ProviderId = "spotify." + fullAlbum.Id,
                Name = fullAlbum.Name.Trim().Replace("  ", " "),
                ReleaseDate = GetDateTime(fullAlbum),
                Genre = fullAlbum.Genres != null ? fullAlbum.Genres.FirstOrDefault() : ""
            };

            return album;
        }
        public static Album ToAlbum(this LastAlbum lastAlbum)
        {
            var album = new Album
            {
                ProviderId =
                    !string.IsNullOrEmpty(lastAlbum.Mbid) ? ("mbid." + lastAlbum.Mbid) : ("lastid." + lastAlbum.Id),
                Name = lastAlbum.Name.Trim().Replace("  ", " "),
                ReleaseDate = lastAlbum.ReleaseDateUtc.HasValue ? lastAlbum.ReleaseDateUtc.Value.DateTime : DateTime.MinValue,
                Genre = lastAlbum.TopTags != null ? lastAlbum.TopTags.First().Name : ""
            };

            return album;
        }
Esempio n. 3
0
        public static async Task SaveAlbumImageAsync(Album album, string url)
        {
            var filePath = string.Format(AppConstant.ArtworkPath, album.Id);
            if (await SaveImageAsync(filePath, url).ConfigureAwait(false))
            {
                album.HasArtwork = true;
                await App.Locator.SqlService.UpdateItemAsync(album).ConfigureAwait(false);

                await DispatcherHelper.RunAsync(
                    () =>
                    {
                        album.Artwork = new PclBitmapImage(new Uri(AppConstant.LocalStorageAppPath + filePath));
                        album.Artwork.SetDecodedPixel(App.Locator.CollectionService.ScaledImageSize);

                        album.MediumArtwork = new PclBitmapImage(new Uri(AppConstant.LocalStorageAppPath + filePath));
                        album.MediumArtwork.SetDecodedPixel(App.Locator.CollectionService.ScaledImageSize/2);

                        album.SmallArtwork = new PclBitmapImage(new Uri(AppConstant.LocalStorageAppPath + filePath));
                        album.SmallArtwork.SetDecodedPixel(50);
                    });
            }
        }
Esempio n. 4
0
        public static async Task<bool> PinToggleAsync(Album album)
        {
            bool created;
            var id = "album." + album.Id;

            if (!SecondaryTile.Exists(id))
            {
                Insights.Track(
                    "Pin To Start",
                    new Dictionary<string, string>
                    {
                        {"DisplayName", album.Name},
                        {"ProviderId", album.ProviderId},
                        {"Type", "Album"}
                    });
                created =
                    await
                        CreatePin(
                            id,
                            album.Name,
                            "albums/" + album.Id,
                            string.Format(AppConstant.ArtworkPath, album.Id));
            }
            else
            {
                var secondaryTile = new SecondaryTile(id);
                created = !await secondaryTile.RequestDeleteAsync();
            }

            return created;
        }
Esempio n. 5
0
        private static void ExitIfAlbumEmpty(Album album)
        {
            if (App.Navigator.CurrentPage is CollectionAlbumPage && album.Songs.Count == 0)
            {
                App.Navigator.GoBack();
            }

            ExitIfArtistEmpty(album.PrimaryArtist);
        }
Esempio n. 6
0
 private void BindAlbumBitmap(ImageView image, Album album)
 {
     ((PclBitmapImage) album.Artwork).PropertyChanged +=
         (sender, args) => { image.SetImageBitmap(album.Artwork.Image as Bitmap); };
     image.SetImageBitmap(album.Artwork.Image as Bitmap);
 }