Commit 49b540c5 authored by Carola Nitz's avatar Carola Nitz

moved the code related to providing searchresults into it's own file

parent 52018781
Pipeline #99 failed with stage
in 0 seconds
/*****************************************************************************
* VLCLibrarySearchDisplayDataSource.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2017 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Carola Nitz <nitz.carola # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
@interface VLCLibrarySearchDisplayDataSource : NSObject<UITableViewDataSource>
- (NSString *)cellIdentifier;
- (UINib *)nibclass;
- (NSManagedObject *)objectAtIndex:(NSUInteger)index;
- (void)shouldReloadTableForSearchString:(NSString *)searchString searchableFiles:(NSArray *)files;
@end
/*****************************************************************************
* VLCLibrarySearchDisplayDataSource.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2017 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Carola Nitz <nitz.carola # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCLibrarySearchDisplayDataSource.h"
#import "VLCPlaylistTableViewCell.h"
static NSString *PlaylistCellIdentifier = @"PlaylistCell";
@interface VLCLibrarySearchDisplayDataSource() <UITableViewDataSource>
{
NSMutableArray *_searchData;
}
@end
@implementation VLCLibrarySearchDisplayDataSource
- (instancetype)init
{
self = [super init];
if (self) {
_searchData = [NSMutableArray new];
}
return self;
}
- (NSString *)cellIdentifier
{
return PlaylistCellIdentifier;
}
- (UINib *)nibclass
{
return [UINib nibWithNibName:@"VLCPlaylistTableViewCell" bundle:nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
@synchronized (_searchData) {
return _searchData.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
VLCPlaylistTableViewCell *cell = (VLCPlaylistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:PlaylistCellIdentifier forIndexPath:indexPath];
[cell collapsWithAnimation:NO];
NSInteger row = indexPath.row;
@synchronized (_searchData) {
if (row < _searchData.count)
cell.mediaObject = _searchData[row];
}
return cell;
}
- (NSManagedObject *)objectAtIndex:(NSUInteger)index
{
@synchronized (_searchData) {
return index < _searchData.count ? _searchData[index] : nil;
}
}
- (void)removeAllObjects
{
@synchronized (_searchData) {
[_searchData removeAllObjects];
}
}
- (void)addObject:(NSManagedObject *)object
{
@synchronized (_searchData) {
[_searchData addObject:object];
}
}
- (void)shouldReloadTableForSearchString:(NSString *)searchString searchableFiles:(NSArray *)files
{
[self removeAllObjects];
NSRange nameRange;
for (NSManagedObject *item in files) {
if ([item isKindOfClass:[MLAlbum class]]) {
nameRange = [self _searchAlbum:(MLAlbum *)item forString:searchString];
} else if ([item isKindOfClass:[MLAlbumTrack class]]) {
nameRange = [self _searchAlbumTrack:(MLAlbumTrack *)item forString:searchString];
} else if ([item isKindOfClass:[MLShowEpisode class]]) {
nameRange = [self _searchShowEpisode:(MLShowEpisode *)item forString:searchString];
} else if ([item isKindOfClass:[MLShow class]]) {
nameRange = [self _searchShow:(MLShow *)item forString:searchString];
} else if ([item isKindOfClass:[MLLabel class]])
nameRange = [self _searchLabel:(MLLabel *)item forString:searchString];
else // simple file
nameRange = [self _searchFile:(MLFile*)item forString:searchString];
if (nameRange.location != NSNotFound)
[self addObject:item];
}
}
- (NSRange)_searchAlbumTrack:(MLAlbumTrack *)albumTrack forString:(NSString *)searchString
{
NSString *trackTitle = albumTrack.title;
NSRange nameRange = [trackTitle rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
NSMutableArray *stringsToSearch = [[NSMutableArray alloc] initWithObjects:trackTitle, nil];
if ([albumTrack artist])
[stringsToSearch addObject:[albumTrack artist]];
if ([albumTrack genre])
[stringsToSearch addObject:[albumTrack genre]];
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
NSUInteger searchStringCount = stringsToSearch.count;
for (NSUInteger x = 0; x < substringCount; x++) {
for (NSUInteger y = 0; y < searchStringCount; y++) {
nameRange = [stringsToSearch[y] rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
- (NSRange)_searchAlbum:(MLAlbum *)album forString:(NSString *)searchString
{
NSString *albumName = [album name];
NSRange nameRange = [albumName rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
if ([album releaseYear]) {
nameRange = [[album releaseYear] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
}
/* split search string into substrings and try again */
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
if (substringCount > 1) {
for (NSUInteger x = 0; x < substringCount; x++) {
nameRange = [searchString rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
}
if (nameRange.location != NSNotFound)
return nameRange;
/* search our tracks if we can't find what the user is looking for */
NSArray *tracks = [album sortedTracks];
NSUInteger trackCount = tracks.count;
for (NSUInteger x = 0; x < trackCount; x++) {
nameRange = [self _searchAlbumTrack:tracks[x] forString:searchString];
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
- (NSRange)_searchShowEpisode:(MLShowEpisode *)episode forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSString *episodeName = [episode name];
NSRange nameRange;
if (episodeName) {
nameRange = [episodeName rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
}
/* split search string into substrings and try again */
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
if (substringCount > 1) {
for (NSUInteger x = 0; x < substringCount; x++) {
nameRange = [searchString rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
}
return nameRange;
}
- (NSRange)_searchShow:(MLShow *)mediaShow forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSRange nameRange = [[mediaShow name] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
/* split search string into substrings and try again */
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
if (substringCount > 1) {
for (NSUInteger x = 0; x < substringCount; x++) {
nameRange = [searchString rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
}
if (nameRange.location != NSNotFound)
return nameRange;
/* user didn't search for our show name, let's do a deeper search on the episodes */
NSArray *episodes = [mediaShow sortedEpisodes];
NSUInteger episodeCount = episodes.count;
for (NSUInteger x = 0; x < episodeCount; x++)
nameRange = [self _searchShowEpisode:episodes[x] forString:searchString];
return nameRange;
}
- (NSRange)_searchLabel:(MLLabel *)mediaLabel forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSRange nameRange = [[mediaLabel name] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
/* user didn't search for our label name, let's do a deeper search */
NSArray *files = [mediaLabel sortedFolderItems];
NSUInteger fileCount = files.count;
for (NSUInteger x = 0; x < fileCount; x++) {
nameRange = [self _searchFile:files[x] forString:searchString];
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
- (NSRange)_searchFile:(MLFile *)mediaFile forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSRange nameRange = [[mediaFile title] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
NSMutableArray *stringsToSearch = [[NSMutableArray alloc] initWithObjects:[mediaFile title], nil];
if ([mediaFile artist])
[stringsToSearch addObject:[mediaFile artist]];
if ([mediaFile releaseYear])
[stringsToSearch addObject:[mediaFile releaseYear]];
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
NSUInteger searchStringCount = stringsToSearch.count;
for (NSUInteger x = 0; x < substringCount; x++) {
for (NSUInteger y = 0; y < searchStringCount; y++) {
nameRange = [stringsToSearch[y] rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
@end
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#import "VLCFirstStepsViewController.h" #import "VLCFirstStepsViewController.h"
#import "VLCFolderCollectionViewFlowLayout.h" #import "VLCFolderCollectionViewFlowLayout.h"
#import "VLCKeychainCoordinator.h" #import "VLCKeychainCoordinator.h"
#import "VLCLibrarySearchDisplayDataSource.h"
#import "VLCMovieViewController.h" #import "VLCMovieViewController.h"
#import "VLCNavigationController.h" #import "VLCNavigationController.h"
#import "VLCPlaylistCollectionViewCell.h" #import "VLCPlaylistCollectionViewCell.h"
...@@ -63,7 +64,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -63,7 +64,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
BOOL _deleteFromTableView; BOOL _deleteFromTableView;
UILongPressGestureRecognizer *_longPressGestureRecognizer; UILongPressGestureRecognizer *_longPressGestureRecognizer;
NSMutableArray *_searchData; VLCLibrarySearchDisplayDataSource *_searchDataSource;
UISearchBar *_searchBar; UISearchBar *_searchBar;
UISearchDisplayController *_searchDisplayController; UISearchDisplayController *_searchDisplayController;
...@@ -101,6 +102,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -101,6 +102,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
[self setViewFromDeviceOrientation]; [self setViewFromDeviceOrientation];
[self updateViewsForCurrentDisplayMode]; [self updateViewsForCurrentDisplayMode];
_libraryMode = VLCLibraryModeAllFiles; _libraryMode = VLCLibraryModeAllFiles;
_searchDataSource = [VLCLibrarySearchDisplayDataSource new];
self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject]; self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject];
_emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = NSLineBreakByWordWrapping; _emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
...@@ -133,7 +135,6 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -133,7 +135,6 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
_tableView.tableHeaderView = _searchBar; _tableView.tableHeaderView = _searchBar;
_tableView.tableFooterView = [UIView new]; _tableView.tableFooterView = [UIView new];
self.navigationController.scrollNavigationBar.scrollView = self.tableView; self.navigationController.scrollNavigationBar.scrollView = self.tableView;
} }
_tableView.frame = contentView.bounds; _tableView.frame = contentView.bounds;
[contentView addSubview:_tableView]; [contentView addSubview:_tableView];
...@@ -237,18 +238,16 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -237,18 +238,16 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
_searchBar.opaque = navBar.opaque; _searchBar.opaque = navBar.opaque;
_searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self]; _searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
_searchDisplayController.delegate = self; _searchDisplayController.delegate = self;
_searchDisplayController.searchResultsDataSource = self; _searchDisplayController.searchResultsDataSource = _searchDataSource;
_searchDisplayController.searchResultsDelegate = self; _searchDisplayController.searchResultsDelegate = self;
_searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_searchDisplayController.searchResultsTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite; _searchDisplayController.searchResultsTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
[_searchDisplayController.searchResultsTableView registerNib:[_searchDataSource nibclass] forCellReuseIdentifier:[_searchDataSource cellIdentifier]];
_searchBar.delegate = self; _searchBar.delegate = self;
[self setSearchBar:YES resetContent:YES]; [self setSearchBar:YES resetContent:YES];
self.edgesForExtendedLayout = UIRectEdgeNone; self.edgesForExtendedLayout = UIRectEdgeNone;
@synchronized (self) {
_searchData = [[NSMutableArray alloc] init];
}
} }
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
...@@ -708,9 +707,6 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -708,9 +707,6 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
if (tableView == self.searchDisplayController.searchResultsTableView)
return _searchData.count;
return _foundMedia.count; return _foundMedia.count;
} }
...@@ -731,16 +727,9 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -731,16 +727,9 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
NSInteger row = indexPath.row; NSInteger row = indexPath.row;
if (tableView == self.searchDisplayController.searchResultsTableView) { @synchronized (_foundMedia) {
@synchronized (_searchData) { if (row < _foundMedia.count)
if (row < _searchData.count) cell.mediaObject = _foundMedia[row];
cell.mediaObject = _searchData[row];
}
} else {
@synchronized (_foundMedia) {
if (row < _foundMedia.count)
cell.mediaObject = _foundMedia[row];
}
} }
return cell; return cell;
...@@ -826,10 +815,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -826,10 +815,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
NSUInteger row = indexPath.row; NSUInteger row = indexPath.row;
if (tableView == self.searchDisplayController.searchResultsTableView) { if (tableView == self.searchDisplayController.searchResultsTableView) {
@synchronized (_searchData) { selectedObject = [_searchDataSource objectAtIndex:row];
if (row < _searchData.count)
selectedObject = _searchData[row];
}
} else { } else {
@synchronized (_foundMedia) { @synchronized (_foundMedia) {
if (row < _foundMedia.count) if (row < _foundMedia.count)
...@@ -1712,212 +1698,12 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -1712,212 +1698,12 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{ {
@synchronized (_searchData) {
[_searchData removeAllObjects];
}
NSManagedObject *item;
NSRange nameRange;
@synchronized(_foundMedia) { @synchronized(_foundMedia) {
NSInteger listCount = _foundMedia.count; [_searchDataSource shouldReloadTableForSearchString:searchString searchableFiles:_foundMedia];
for (int i = 0; i < listCount; i++) {
item = _foundMedia[i];
if ([item isKindOfClass:[MLAlbum class]]) {
nameRange = [self _searchAlbum:(MLAlbum *)item forString:searchString];
} else if ([item isKindOfClass:[MLAlbumTrack class]]) {
nameRange = [self _searchAlbumTrack:(MLAlbumTrack *)item forString:searchString];
} else if ([item isKindOfClass:[MLShowEpisode class]]) {
nameRange = [self _searchShowEpisode:(MLShowEpisode *)item forString:searchString];
} else if ([item isKindOfClass:[MLShow class]]) {
nameRange = [self _searchShow:(MLShow *)item forString:searchString];
} else if ([item isKindOfClass:[MLLabel class]])
nameRange = [self _searchLabel:(MLLabel *)item forString:searchString];
else // simple file
nameRange = [self _searchFile:(MLFile*)item forString:searchString];
@synchronized (_searchData) {
if (nameRange.location != NSNotFound)
[_searchData addObject:item];
}
}
} }
return YES; return YES;
} }
- (NSRange)_searchAlbumTrack:(MLAlbumTrack *)albumTrack forString:(NSString *)searchString
{
NSString *trackTitle = albumTrack.title;
NSRange nameRange = [trackTitle rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
NSMutableArray *stringsToSearch = [[NSMutableArray alloc] initWithObjects:trackTitle, nil];
if ([albumTrack artist])
[stringsToSearch addObject:[albumTrack artist]];
if ([albumTrack genre])
[stringsToSearch addObject:[albumTrack genre]];
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
NSUInteger searchStringCount = stringsToSearch.count;
for (NSUInteger x = 0; x < substringCount; x++) {
for (NSUInteger y = 0; y < searchStringCount; y++) {
nameRange = [stringsToSearch[y] rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
- (NSRange)_searchAlbum:(MLAlbum *)album forString:(NSString *)searchString
{
NSString *albumName = [album name];
NSRange nameRange = [albumName rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
if ([album releaseYear]) {
nameRange = [[album releaseYear] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
}
/* split search string into substrings and try again */
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
if (substringCount > 1) {
for (NSUInteger x = 0; x < substringCount; x++) {
nameRange = [searchString rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
}
if (nameRange.location != NSNotFound)
return nameRange;
/* search our tracks if we can't find what the user is looking for */
NSArray *tracks = [album sortedTracks];
NSUInteger trackCount = tracks.count;
for (NSUInteger x = 0; x < trackCount; x++) {
nameRange = [self _searchAlbumTrack:tracks[x] forString:searchString];
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
- (NSRange)_searchShowEpisode:(MLShowEpisode *)episode forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSString *episodeName = [episode name];
NSRange nameRange;
if (episodeName) {
nameRange = [episodeName rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
}
/* split search string into substrings and try again */
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
if (substringCount > 1) {
for (NSUInteger x = 0; x < substringCount; x++) {
nameRange = [searchString rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
}
return nameRange;
}
- (NSRange)_searchShow:(MLShow *)mediaShow forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSRange nameRange = [[mediaShow name] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
/* split search string into substrings and try again */
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
if (substringCount > 1) {
for (NSUInteger x = 0; x < substringCount; x++) {
nameRange = [searchString rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
}
if (nameRange.location != NSNotFound)
return nameRange;
/* user didn't search for our show name, let's do a deeper search on the episodes */
NSArray *episodes = [mediaShow sortedEpisodes];
NSUInteger episodeCount = episodes.count;
for (NSUInteger x = 0; x < episodeCount; x++)
nameRange = [self _searchShowEpisode:episodes[x] forString:searchString];
return nameRange;
}
- (NSRange)_searchLabel:(MLLabel *)mediaLabel forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSRange nameRange = [[mediaLabel name] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
/* user didn't search for our label name, let's do a deeper search */
NSArray *files = [mediaLabel sortedFolderItems];
NSUInteger fileCount = files.count;
for (NSUInteger x = 0; x < fileCount; x++) {
nameRange = [self _searchFile:files[x] forString:searchString];
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
- (NSRange)_searchFile:(MLFile *)mediaFile forString:(NSString *)searchString
{
/* basic search first, then try more complex things */
NSRange nameRange = [[mediaFile title] rangeOfString:searchString options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
return nameRange;
NSMutableArray *stringsToSearch = [[NSMutableArray alloc] initWithObjects:[mediaFile title], nil];
if ([mediaFile artist])
[stringsToSearch addObject:[mediaFile artist]];
if ([mediaFile releaseYear])
[stringsToSearch addObject:[mediaFile releaseYear]];
NSArray *substrings = [searchString componentsSeparatedByString:@" "];
NSUInteger substringCount = substrings.count;
NSUInteger searchStringCount = stringsToSearch.count;
for (NSUInteger x = 0; x < substringCount; x++) {
for (NSUInteger y = 0; y < searchStringCount; y++) {
nameRange = [stringsToSearch[y] rangeOfString:substrings[x] options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound)
break;
}
if (nameRange.location != NSNotFound)
break;
}
return nameRange;
}
#pragma mark - handoff #pragma mark - handoff
- (void)restoreUserActivityState:(NSUserActivity *)activity - (void)restoreUserActivityState:(NSUserActivity *)activity
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
41B93C081A53853B00102E8B /* VLCCloudServiceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 41B93C071A53853B00102E8B /* VLCCloudServiceCell.xib */; }; 41B93C081A53853B00102E8B /* VLCCloudServiceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 41B93C071A53853B00102E8B /* VLCCloudServiceCell.xib */; };
41CD695C1A29D72600E60BCE /* VLCBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD69591A29D72600E60BCE /* VLCBoxController.m */; }; 41CD695C1A29D72600E60BCE /* VLCBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD69591A29D72600E60BCE /* VLCBoxController.m */; };
41CD695D1A29D72600E60BCE /* VLCBoxTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */; }; 41CD695D1A29D72600E60BCE /* VLCBoxTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */; };
41F5C0781F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 41F5C0771F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.m */; };
6A804FA9706D38FB40A4136A /* libPods-VLC-watchOS-Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F82CE64560C0AD3059DAAFC /* libPods-VLC-watchOS-Extension.a */; }; 6A804FA9706D38FB40A4136A /* libPods-VLC-watchOS-Extension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F82CE64560C0AD3059DAAFC /* libPods-VLC-watchOS-Extension.a */; };
6B4E33D11BF2A39400A35255 /* playerControl.css in Resources */ = {isa = PBXBuildFile; fileRef = 6B4E33CF1BF2A39400A35255 /* playerControl.css */; }; 6B4E33D11BF2A39400A35255 /* playerControl.css in Resources */ = {isa = PBXBuildFile; fileRef = 6B4E33CF1BF2A39400A35255 /* playerControl.css */; };
6B4E33D21BF2A39400A35255 /* playerControl.js in Resources */ = {isa = PBXBuildFile; fileRef = 6B4E33D01BF2A39400A35255 /* playerControl.js */; }; 6B4E33D21BF2A39400A35255 /* playerControl.js in Resources */ = {isa = PBXBuildFile; fileRef = 6B4E33D01BF2A39400A35255 /* playerControl.js */; };
...@@ -1158,6 +1159,8 @@ ...@@ -1158,6 +1159,8 @@
41CD69591A29D72600E60BCE /* VLCBoxController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBoxController.m; path = Sources/VLCBoxController.m; sourceTree = SOURCE_ROOT; }; 41CD69591A29D72600E60BCE /* VLCBoxController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBoxController.m; path = Sources/VLCBoxController.m; sourceTree = SOURCE_ROOT; };
41CD695A1A29D72600E60BCE /* VLCBoxTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCBoxTableViewController.h; path = Sources/VLCBoxTableViewController.h; sourceTree = SOURCE_ROOT; }; 41CD695A1A29D72600E60BCE /* VLCBoxTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCBoxTableViewController.h; path = Sources/VLCBoxTableViewController.h; sourceTree = SOURCE_ROOT; };
41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBoxTableViewController.m; path = Sources/VLCBoxTableViewController.m; sourceTree = SOURCE_ROOT; }; 41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBoxTableViewController.m; path = Sources/VLCBoxTableViewController.m; sourceTree = SOURCE_ROOT; };
41F5C0761F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCLibrarySearchDisplayDataSource.h; path = Sources/VLCLibrarySearchDisplayDataSource.h; sourceTree = SOURCE_ROOT; };
41F5C0771F41ED55005EB9CB /* VLCLibrarySearchDisplayDataSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCLibrarySearchDisplayDataSource.m; path = Sources/VLCLibrarySearchDisplayDataSource.m; sourceTree = SOURCE_ROOT; };
4EB2A836EBC6DE6E89855975 /* Pods-VLC-watchOS-Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-watchOS-Extension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-watchOS-Extension/Pods-VLC-watchOS-Extension.debug.xcconfig"; sourceTree = "<group>"; }; 4EB2A836EBC6DE6E89855975 /* Pods-VLC-watchOS-Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-watchOS-Extension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-watchOS-Extension/Pods-VLC-watchOS-Extension.debug.xcconfig"; sourceTree = "<group>"; };
5B343E4F4D971F5A169EB864 /* Pods-VLC-iOS.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOS.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-iOS/Pods-VLC-iOS.distribution.xcconfig"; sourceTree = "<group>"; }; 5B343E4F4D971F5A169EB864 /* Pods-VLC-iOS.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-iOS.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-iOS/Pods-VLC-iOS.distribution.xcconfig"; sourceTree = "<group>"; };
633AEC92459BCABEC8671A34 /* Pods-VLC-tvOS-Debug.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-tvOS-Debug.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-tvOS-Debug/Pods-VLC-tvOS-Debug.debug.xcconfig"; sourceTree = "<group>"; }; 633AEC92459BCABEC8671A34 /* Pods-VLC-tvOS-Debug.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VLC-tvOS-Debug.debug.xcconfig"; path = "Pods/Target Support Files/Pods-VLC-tvOS-Debug/Pods-VLC-tvOS-Debug.debug.xcconfig"; sourceTree = "<group>"; };
...@@ -2262,6 +2265,8 @@ ...@@ -2262,6 +2265,8 @@
7D378498183A98D1009EE944 /* VLCLibraryViewController.m */, 7D378498183A98D1009EE944 /* VLCLibraryViewController.m */,