Skip to content

Commit

Permalink
iOS: More work on album art in Artist cells.
Browse files Browse the repository at this point in the history
Related to issue #405.
  • Loading branch information
ycastonguay committed Sep 19, 2013
1 parent 6bafd9e commit ccdcbf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Expand Up @@ -387,6 +387,7 @@ public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
cell.AlbumCountLabel.Hidden = item.AlbumTitles.Count >= 3 ? false : true;

int albumFetchCount = item.AlbumTitles.Count >= 3 ? 3 : item.AlbumTitles.Count;
//albumFetchCount = item.AlbumTitles.Count == 3 ? 3 : item.AlbumTitles.Count; // Do not load a third album art when the count is visible!
for (int a = 0; a < albumFetchCount; a++)
{
UIImageView imageAlbum = null;
Expand All @@ -398,14 +399,16 @@ public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
imageAlbum = cell.ImageAlbum3;

// Check if album art is cached
string key = _items[indexPath.Row].Query.ArtistName + "_" + _items[indexPath.Row].Query.AlbumTitle;
string key = _items[indexPath.Row].Query.ArtistName + "_" + _items[indexPath.Row].AlbumTitles[a];
KeyValuePair<string, UIImage> keyPair = _thumbnailImageCache.FirstOrDefault(x => x.Key == key);
if (keyPair.Equals(default(KeyValuePair<string, UIImage>)))
{
Console.WriteLine("MLBVC - GetCell - OnRequestAlbumArt - index: {0} key: {1}", indexPath.Row, key);
OnRequestAlbumArt(_items[indexPath.Row].Query.ArtistName, _items[indexPath.Row].AlbumTitles[a], imageAlbum);
}
else
{
Console.WriteLine("MLBVC - GetCell - Taking image from cache - index: {0} key: {1}", indexPath.Row, key);
imageAlbum.Image = keyPair.Value;
}

Expand Down Expand Up @@ -581,7 +584,7 @@ public void RefreshAlbumArtCell(string artistName, string albumTitle, byte[] alb
{
case MobileLibraryBrowserType.Artists:
// Remove older image from cache if exceeds cache size
if(_thumbnailImageCache.Count > 50)
if(_thumbnailImageCache.Count > 80)
_thumbnailImageCache.RemoveAt(0);
// Add image to cache
Expand All @@ -601,7 +604,11 @@ public void RefreshAlbumArtCell(string artistName, string albumTitle, byte[] alb
if(userData != null)
{
var imageView = (UIImageView)userData;
imageView.Alpha = 0;
imageView.Image = image;
UIView.Animate(0.2, () => {
imageView.Alpha = 1;
});
}
//if(cellArtistName.Image != image)
Expand Down
Expand Up @@ -137,7 +137,6 @@ public void SetImage(UIImage image)
UIView.Animate(0.2, () => {
_imageView.Alpha = 1;
});

}

public void SetHighlight(bool highlighted)
Expand Down

0 comments on commit ccdcbf7

Please sign in to comment.