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

library: resolve selector mismatch which lead to an outdated content state (close #9257)

parent 2041f52b
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
} }
if (_foundMedia.count < 1) if (_foundMedia.count < 1)
[self performSelector:@selector(reloadContents) withObject:nil afterDelay:.0]; [self updateViewContents];
[[MLMediaLibrary sharedMediaLibrary] performSelector:@selector(libraryDidAppear) withObject:nil afterDelay:1.]; [[MLMediaLibrary sharedMediaLibrary] performSelector:@selector(libraryDidAppear) withObject:nil afterDelay:1.];
if (SYSTEM_RUNS_IN_THE_FUTURE) if (SYSTEM_RUNS_IN_THE_FUTURE)
...@@ -173,15 +173,15 @@ ...@@ -173,15 +173,15 @@
} }
[fileManager removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil]; [fileManager removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
[[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase]; [[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
[self reloadContents]; [self updateViewContents];
} }
- (void)_displayEmptyLibraryViewIfNeeded - (void)_displayEmptyLibraryViewIfNeeded
{ {
if (_foundMedia.count > 0) { if (self.emptyLibraryView.superview)
if (self.emptyLibraryView.superview) [self.emptyLibraryView removeFromSuperview];
[self.emptyLibraryView removeFromSuperview];
} else { if (_foundMedia.count <= 0) {
self.emptyLibraryView.frame = self.view.frame; self.emptyLibraryView.frame = self.view.frame;
[self.view addSubview:self.emptyLibraryView]; [self.view addSubview:self.emptyLibraryView];
} }
...@@ -205,11 +205,18 @@ ...@@ -205,11 +205,18 @@
self.navigationItem.leftBarButtonItem = _menuButton; self.navigationItem.leftBarButtonItem = _menuButton;
[self.emptyLibraryView removeFromSuperview]; [self.emptyLibraryView removeFromSuperview];
[self reloadContents]; [self updateViewContents];
}
- (void)libraryWasUpdated
{
NSLog(@"libraryWasUpdated");
[self updateViewContents];
} }
- (void)reloadContents - (void)updateViewContents
{ {
NSLog(@"old count %i", _foundMedia.count);
if (_libraryMode == kVLCLibraryModeAllAlbums) { if (_libraryMode == kVLCLibraryModeAllAlbums) {
NSArray *rawAlbums = [MLAlbum allAlbums]; NSArray *rawAlbums = [MLAlbum allAlbums];
_foundMedia = [[NSMutableArray alloc] init]; _foundMedia = [[NSMutableArray alloc] init];
...@@ -237,16 +244,18 @@ ...@@ -237,16 +244,18 @@
} else } else
_foundMedia = [NSMutableArray arrayWithArray:[MLFile allFiles]]; _foundMedia = [NSMutableArray arrayWithArray:[MLFile allFiles]];
[self updateViewContents]; NSLog(@"old count %i", _foundMedia.count);
[self reloadViews];
} }
- (void)updateViewContents - (void)reloadViews
{ {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
[self.tableView reloadData]; [self.tableView reloadData];
else { else {
[self.gridView reloadData]; [self.gridView reloadData];
[self.gridView setNeedsLayout]; [self.gridView performSelector:@selector(reloadData) withObject:nil afterDelay:2.];
} }
[self _displayEmptyLibraryViewIfNeeded]; [self _displayEmptyLibraryViewIfNeeded];
...@@ -305,13 +314,13 @@ ...@@ -305,13 +314,13 @@
self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)]; self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
[self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")]; [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
self.title = [(MLAlbum*)currentObject name]; self.title = [(MLAlbum*)currentObject name];
[self updateViewContents]; [self reloadViews];
} else if ([currentObject isKindOfClass:[MLShow class]]) { } else if ([currentObject isKindOfClass:[MLShow class]]) {
_foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]]; _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)]; self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
[self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")]; [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
self.title = [(MLShow*)currentObject name]; self.title = [(MLShow*)currentObject name];
[self updateViewContents]; [self reloadViews];
} else { } else {
if (!self.movieViewController) if (!self.movieViewController)
self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil]; self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
...@@ -364,13 +373,13 @@ ...@@ -364,13 +373,13 @@
self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)]; self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
[self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")]; [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
self.title = [(MLAlbum*)currentObject name]; self.title = [(MLAlbum*)currentObject name];
[self updateViewContents]; [self reloadViews];
} else if ([currentObject isKindOfClass:[MLShow class]]) { } else if ([currentObject isKindOfClass:[MLShow class]]) {
_foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]]; _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)]; self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
[self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")]; [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
self.title = [(MLShow*)currentObject name]; self.title = [(MLShow*)currentObject name];
[self updateViewContents]; [self reloadViews];
} else { } else {
if (!self.movieViewController) if (!self.movieViewController)
self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil]; self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
...@@ -487,7 +496,7 @@ ...@@ -487,7 +496,7 @@
else else
self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @""); self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
[self reloadContents]; [self updateViewContents];
} }
@end @end
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