Skip to content

Commit

Permalink
CarPlay: improve Genre presentation
Browse files Browse the repository at this point in the history
This uses a more compact, more informative layout.
  • Loading branch information
fkuehne committed May 12, 2023
1 parent 33d7655 commit d95f29d
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions Sources/CarPlay/CPListTemplate+Genres.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ + (NSArray *)listOfGenres
NSMutableArray *itemList = [[NSMutableArray alloc] initWithCapacity:count];

for (NSUInteger x = 0; x < count; x++) {
CPListImageRowItem *listItem;
CPListItem *listItem;

VLCMLGenre *iter = genres[x];
NSArray *artists = iter.artists;
NSMutableArray *artistImages = [NSMutableArray array];

UIImage *genreImage;
for (VLCMLArtist *artist in artists) {
UIImage *artworkImage = [VLCThumbnailsCache thumbnailForURL:artist.artworkMRL];
if (!artworkImage) {
artworkImage = [UIImage imageNamed:@"cp-Artist"];
}
[artistImages addObject:artworkImage];
genreImage = [VLCThumbnailsCache thumbnailForURL:artist.artworkMRL];
if (genreImage)
break;
}
if (!genreImage) {
genreImage = [UIImage imageNamed:@"cp-Genre"];
}

listItem = [[CPListImageRowItem alloc] initWithText:iter.name images:artistImages];
listItem = [[CPListItem alloc] initWithText:iter.name detailText:iter.numberOfTracksString image:genreImage];

listItem.userInfo = iter;
listItem.handler = ^(id <CPSelectableListItem> item,
Expand All @@ -61,16 +62,6 @@ + (NSArray *)listOfGenres
[playbackService playMediaAtIndex:0 fromCollection:[genre tracks]];
completionBlock();
};
listItem.listImageRowHandler = ^(CPListImageRowItem * item, NSInteger index, dispatch_block_t completionBlock) {
VLCMLGenre *genres = item.userInfo;
NSArray *artists = genres.artists;
NSUInteger artistCount = genres.artists.count;
if (index < artistCount) {
VLCPlaybackService *playbackService = [VLCPlaybackService sharedInstance];
[playbackService playMediaAtIndex:0 fromCollection:[artists[index] tracks]];
}
completionBlock();
};
[itemList addObject:listItem];
}

Expand Down

0 comments on commit d95f29d

Please sign in to comment.