Merge pull request #540 from cvanloo/fix-fetch-full-size-artist-image
feat: fetch full size artist cover on tapped
This commit is contained in:
+48
-23
@@ -247,7 +247,7 @@ func (a *ArtistPage) load() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
a.artistInfo = artist
|
a.artistInfo = artist
|
||||||
a.header.Update(artist)
|
a.header.Update(artist, a.im)
|
||||||
if a.activeView == 0 {
|
if a.activeView == 0 {
|
||||||
a.showAlbumGrid(false /*reSort*/)
|
a.showAlbumGrid(false /*reSort*/)
|
||||||
} else {
|
} else {
|
||||||
@@ -361,17 +361,19 @@ const artistBioNotAvailableKey = "Artist biography not available."
|
|||||||
type ArtistPageHeader struct {
|
type ArtistPageHeader struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
artistID string
|
artistID string
|
||||||
artistPage *ArtistPage
|
artistPage *ArtistPage
|
||||||
artistImage *widgets.ImagePlaceholder
|
artistImage *widgets.ImagePlaceholder
|
||||||
titleDisp *widget.RichText
|
artistImageID string
|
||||||
biographyDisp *widgets.MaxRowsLabel
|
titleDisp *widget.RichText
|
||||||
similarArtists *fyne.Container
|
biographyDisp *widgets.MaxRowsLabel
|
||||||
favoriteBtn *widgets.FavoriteButton
|
similarArtists *fyne.Container
|
||||||
playBtn *widget.Button
|
favoriteBtn *widgets.FavoriteButton
|
||||||
playRadioBtn *widget.Button
|
playBtn *widget.Button
|
||||||
menuBtn *widget.Button
|
playRadioBtn *widget.Button
|
||||||
container *fyne.Container
|
menuBtn *widget.Button
|
||||||
|
container *fyne.Container
|
||||||
|
fullSizeCoverFetching bool
|
||||||
//shareMenuItem *fyne.MenuItem
|
//shareMenuItem *fyne.MenuItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,11 +390,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader {
|
|||||||
SizeName: theme.SizeNameHeadingText,
|
SizeName: theme.SizeNameHeadingText,
|
||||||
}
|
}
|
||||||
a.artistImage = widgets.NewImagePlaceholder(myTheme.ArtistIcon, 225)
|
a.artistImage = widgets.NewImagePlaceholder(myTheme.ArtistIcon, 225)
|
||||||
a.artistImage.OnTapped = func(*fyne.PointEvent) {
|
a.artistImage.OnTapped = func(*fyne.PointEvent) { go a.showPopUpCover() }
|
||||||
if im := a.artistImage.Image(); im != nil {
|
|
||||||
a.artistPage.contr.ShowPopUpImage(im)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() })
|
a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() })
|
||||||
a.playBtn = widget.NewButtonWithIcon(lang.L("Play Discography"), theme.MediaPlayIcon(), func() {
|
a.playBtn = widget.NewButtonWithIcon(lang.L("Play Discography"), theme.MediaPlayIcon(), func() {
|
||||||
go a.artistPage.pm.PlayArtistDiscography(a.artistID, false /*shuffle*/)
|
go a.artistPage.pm.PlayArtistDiscography(a.artistID, false /*shuffle*/)
|
||||||
@@ -443,6 +441,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader {
|
|||||||
|
|
||||||
func (a *ArtistPageHeader) Clear() {
|
func (a *ArtistPageHeader) Clear() {
|
||||||
a.artistID = ""
|
a.artistID = ""
|
||||||
|
a.artistImageID = ""
|
||||||
a.favoriteBtn.IsFavorited = false
|
a.favoriteBtn.IsFavorited = false
|
||||||
a.titleDisp.Segments[0].(*widget.TextSegment).Text = ""
|
a.titleDisp.Segments[0].(*widget.TextSegment).Text = ""
|
||||||
a.biographyDisp.Text = lang.L(artistBioNotAvailableKey)
|
a.biographyDisp.Text = lang.L(artistBioNotAvailableKey)
|
||||||
@@ -450,9 +449,10 @@ func (a *ArtistPageHeader) Clear() {
|
|||||||
obj.Hide()
|
obj.Hide()
|
||||||
}
|
}
|
||||||
a.artistImage.SetImage(nil, false)
|
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 {
|
if artist == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -464,11 +464,14 @@ func (a *ArtistPageHeader) Update(artist *mediaprovider.ArtistWithAlbums) {
|
|||||||
if artist.CoverArtID == "" {
|
if artist.CoverArtID == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if im, err := a.artistPage.im.GetCoverThumbnail(artist.CoverArtID); err != nil {
|
a.artistImageID = artist.CoverArtID
|
||||||
log.Printf("failed to load artist image: %v", err)
|
go func() {
|
||||||
} else {
|
if cover, err := im.GetCoverThumbnail(artist.CoverArtID); err == nil {
|
||||||
a.artistImage.SetImage(im, true /*tappable*/)
|
a.artistImage.SetImage(cover, true)
|
||||||
}
|
} else {
|
||||||
|
log.Printf("error fetching cover: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtistPageHeader) UpdateInfo(info *mediaprovider.ArtistInfo) {
|
func (a *ArtistPageHeader) UpdateInfo(info *mediaprovider.ArtistInfo) {
|
||||||
@@ -517,6 +520,28 @@ func (a *ArtistPageHeader) UpdateInfo(info *mediaprovider.ArtistInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *ArtistPageHeader) showPopUpCover() {
|
||||||
|
if a.artistImageID == "" {
|
||||||
|
if im := a.artistImage.Image(); im != nil {
|
||||||
|
a.artistPage.contr.ShowPopUpImage(im)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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() {
|
func (a *ArtistPageHeader) toggleFavorited() {
|
||||||
params := mediaprovider.RatingFavoriteParameters{ArtistIDs: []string{a.artistID}}
|
params := mediaprovider.RatingFavoriteParameters{ArtistIDs: []string{a.artistID}}
|
||||||
a.artistPage.mp.SetFavorite(params, a.favoriteBtn.IsFavorited)
|
a.artistPage.mp.SetFavorite(params, a.favoriteBtn.IsFavorited)
|
||||||
|
|||||||
Reference in New Issue
Block a user