diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index e2403a1..aac8969 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -247,7 +247,7 @@ func (a *ArtistPage) load() { return } a.artistInfo = artist - a.header.Update(artist) + a.header.Update(artist, a.im) if a.activeView == 0 { a.showAlbumGrid(false /*reSort*/) } else { @@ -364,6 +364,7 @@ type ArtistPageHeader struct { artistID string artistPage *ArtistPage artistImage *widgets.ImagePlaceholder + artistImageID string titleDisp *widget.RichText biographyDisp *widgets.MaxRowsLabel similarArtists *fyne.Container @@ -372,6 +373,7 @@ type ArtistPageHeader struct { playRadioBtn *widget.Button menuBtn *widget.Button container *fyne.Container + fullSizeCoverFetching bool //shareMenuItem *fyne.MenuItem } @@ -388,11 +390,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader { SizeName: theme.SizeNameHeadingText, } a.artistImage = widgets.NewImagePlaceholder(myTheme.ArtistIcon, 225) - a.artistImage.OnTapped = func(*fyne.PointEvent) { - if im := a.artistImage.Image(); im != nil { - a.artistPage.contr.ShowPopUpImage(im) - } - } + a.artistImage.OnTapped = func(*fyne.PointEvent) { go a.showPopUpCover() } a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() }) a.playBtn = widget.NewButtonWithIcon(lang.L("Play Discography"), theme.MediaPlayIcon(), func() { go a.artistPage.pm.PlayArtistDiscography(a.artistID, false /*shuffle*/) @@ -443,6 +441,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader { func (a *ArtistPageHeader) Clear() { a.artistID = "" + a.artistImageID = "" a.favoriteBtn.IsFavorited = false a.titleDisp.Segments[0].(*widget.TextSegment).Text = "" a.biographyDisp.Text = lang.L(artistBioNotAvailableKey) @@ -450,25 +449,28 @@ func (a *ArtistPageHeader) Clear() { obj.Hide() } a.artistImage.SetImage(nil, false) + a.fullSizeCoverFetching = false } -func (a *ArtistPageHeader) Update(artist *mediaprovider.ArtistWithAlbums) { +func (a *ArtistPageHeader) Update(artist *mediaprovider.ArtistWithAlbums, im *backend.ImageManager) { if artist == nil { return } a.favoriteBtn.IsFavorited = artist.Favorite a.favoriteBtn.Refresh() a.artistID = artist.ID + a.artistImageID = artist.CoverArtID a.titleDisp.Segments[0].(*widget.TextSegment).Text = artist.Name a.titleDisp.Refresh() - if artist.CoverArtID == "" { - return - } - if im, err := a.artistPage.im.GetCoverThumbnail(artist.CoverArtID); err != nil { - log.Printf("failed to load artist image: %v", err) - } else { - a.artistImage.SetImage(im, true /*tappable*/) - } + + go func() { + if cover, err := im.GetCoverThumbnail(artist.CoverArtID); err == nil { + a.artistImage.SetImage(cover, true) + a.artistImage.Refresh() + } else { + log.Printf("error fetching cover: %v", err) + } + }() } func (a *ArtistPageHeader) UpdateInfo(info *mediaprovider.ArtistInfo) { @@ -517,6 +519,22 @@ func (a *ArtistPageHeader) UpdateInfo(info *mediaprovider.ArtistInfo) { } } +func (a *ArtistPageHeader) showPopUpCover() { + if a.fullSizeCoverFetching { + return + } + a.fullSizeCoverFetching = true + defer func() { a.fullSizeCoverFetching = false }() + cover, err := a.artistPage.im.GetFullSizeCoverArt(a.artistImageID) + if err != nil { + log.Printf("error getting full size album cover: %s", err.Error()) + return + } + if a.artistPage != nil { + a.artistPage.contr.ShowPopUpImage(cover) + } +} + func (a *ArtistPageHeader) toggleFavorited() { params := mediaprovider.RatingFavoriteParameters{ArtistIDs: []string{a.artistID}} a.artistPage.mp.SetFavorite(params, a.favoriteBtn.IsFavorited)