Commit ce3885cc authored by Felix Paul Kühne's avatar Felix Paul Kühne

library: fix automatic sorting of TV Shows / Series (phone form factor only for now)

parent c9c6ee87
......@@ -63,7 +63,7 @@
_sectionHeaderTexts = @[@"SECTION_HEADER_LIBRARY", @"SECTION_HEADER_NETWORK", @"Settings"];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
_menuItemsSectionOne = @[@"LIBRARY_ALL_FILES", @"LIBRARY_MUSIC"];
_menuItemsSectionOne = @[@"LIBRARY_ALL_FILES", @"LIBRARY_MUSIC", @"LIBRARY_SERIES"];
else
_menuItemsSectionOne = @[@"LIBRARY_ALL_FILES"];
_menuItemsSectionTwo = @[@"LOCAL_NETWORK", @"OPEN_NETWORK", @"DOWNLOAD_FROM_HTTP", @"WiFi Upload", @"Dropbox"];
......
......@@ -76,11 +76,18 @@
- (void)_updatedDisplayedInformationForKeyPath:(NSString *)keyPath
{
static NSMutableArray *_thumbnailCacheIndex;
static NSMutableDictionary *_thumbnailCache;
if (!_thumbnailCache)
_thumbnailCache = [[NSMutableDictionary alloc] initWithCapacity:MAX_CACHE_SIZE];
if (!_thumbnailCacheIndex)
_thumbnailCacheIndex = [[NSMutableArray alloc] initWithCapacity:MAX_CACHE_SIZE];
self.albumNameLabel.text = self.artistNameLabel.text = @"";
if ([self.mediaObject isKindOfClass:[MLFile class]]) {
MLFile *mediaObject = (MLFile*)self.mediaObject;
self.albumNameLabel.text = self.artistNameLabel.text = @"";
if (mediaObject.isAlbumTrack) {
self.artistNameLabel.text = mediaObject.albumTrack.artist;
self.albumNameLabel.text = mediaObject.albumTrack.album.name;
......@@ -100,13 +107,6 @@
}
}
if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) {
static NSMutableArray *_thumbnailCacheIndex;
static NSMutableDictionary *_thumbnailCache;
if (!_thumbnailCache)
_thumbnailCache = [[NSMutableDictionary alloc] initWithCapacity:MAX_CACHE_SIZE];
if (!_thumbnailCacheIndex)
_thumbnailCacheIndex = [[NSMutableArray alloc] initWithCapacity:MAX_CACHE_SIZE];
NSManagedObjectID *objID = mediaObject.objectID;
UIImage *displayedImage;
if ([_thumbnailCacheIndex containsObject:objID]) {
......@@ -159,6 +159,49 @@
self.progressIndicator.hidden = ((position < .1f) || (position > .95f)) ? YES : NO;
[self.progressIndicator setNeedsDisplay];
self.mediaIsUnreadView.hidden = !anyFileFromTrack.unread.intValue;
} else if ([self.mediaObject isKindOfClass:[MLShow class]]) {
MLShow *mediaObject = (MLShow *)self.mediaObject;
self.titleLabel.text = mediaObject.name;
self.artistNameLabel.text = @"";
self.albumNameLabel.text = mediaObject.releaseYear;
self.thumbnailView.image = nil;
NSUInteger count = mediaObject.episodes.count;
self.subtitleLabel.text = [NSString stringWithFormat:(count > 1) ? @"%i Tracks, %i unread" : @"%i Track, %i unread", count, mediaObject.unreadEpisodes.count];
self.mediaIsUnreadView.hidden = YES;
self.progressIndicator.hidden = YES;
} else if ([self.mediaObject isKindOfClass:[MLShowEpisode class]]) {
MLShowEpisode *mediaObject = (MLShowEpisode *)self.mediaObject;
self.artistNameLabel.text = mediaObject.show.name;
self.titleLabel.text = mediaObject.name;
MLFile *anyFileFromEpisode = mediaObject.files.anyObject;
if ([keyPath isEqualToString:@"computedThumbnail"] || !keyPath) {
NSManagedObjectID *objID = anyFileFromEpisode.objectID;
UIImage *displayedImage;
if ([_thumbnailCacheIndex containsObject:objID]) {
[_thumbnailCacheIndex removeObject:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
displayedImage = [_thumbnailCache objectForKey:objID];
} else {
if (_thumbnailCacheIndex.count >= MAX_CACHE_SIZE) {
[_thumbnailCache removeObjectForKey:[_thumbnailCacheIndex lastObject]];
[_thumbnailCacheIndex removeLastObject];
}
displayedImage = anyFileFromEpisode.computedThumbnail;
if (displayedImage)
[_thumbnailCache setObject:displayedImage forKey:objID];
[_thumbnailCacheIndex insertObject:objID atIndex:0];
}
self.thumbnailView.image = displayedImage;
}
self.subtitleLabel.text = [NSString stringWithFormat:@"%i/%i — %@", mediaObject.episodeNumber.intValue, mediaObject.seasonNumber.intValue, [VLCTime timeWithNumber:[anyFileFromEpisode duration]]];
CGFloat position = anyFileFromEpisode.lastPosition.floatValue;
self.progressIndicator.progress = position;
self.progressIndicator.hidden = ((position < .1f) || (position > .95f)) ? YES : NO;
[self.progressIndicator setNeedsDisplay];
self.mediaIsUnreadView.hidden = !mediaObject.unread.intValue;
}
[self setNeedsDisplay];
......
......@@ -180,6 +180,18 @@
[_foundMedia addObject:album];
}
rawAlbums = nil;
} else if (_libraryMode == kVLCLibraryModeAllSeries) {
NSArray *rawShows = [MLShow allShows];
_foundMedia = [[NSMutableArray alloc] init];
NSUInteger count = rawShows.count;
MLShow *show;
for (NSUInteger x = 0; x < count; x++) {
show = rawShows[x];
if (show.name.length > 0 && show.episodes.count > 0)
[_foundMedia addObject:show];
}
rawShows = nil;
} else
_foundMedia = [NSMutableArray arrayWithArray:[MLFile allFiles]];
......@@ -246,7 +258,9 @@
NSManagedObject *currentObject = _foundMedia[indexPath.row];
if ([currentObject isKindOfClass:[MLAlbum class]]) {
_foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
NSLog(@"current item is an album with %i kids", _foundMedia.count);
[self updateViewContents];
} else if ([currentObject isKindOfClass:[MLShow class]]) {
_foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
[self updateViewContents];
} else {
if (!self.movieViewController)
......@@ -254,8 +268,10 @@
if ([currentObject isKindOfClass:[MLFile class]])
self.movieViewController.mediaItem = (MLFile *)currentObject;
else
else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
else if ([currentObject isKindOfClass:[MLShowEpisode class]])
self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
[self.navigationController pushViewController:self.movieViewController animated:YES];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment