diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-05 05:29:51 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-07 02:41:38 -0800 |
commit | 3025d5b4114032519a52c541add5c7312e2ab0d2 (patch) | |
tree | 3c2a6b4f4df2dd1a1e2137444c466c2f02e64f5a | |
parent | eea75e8f60446a55ae35f9d2c87e4d3879d365af (diff) |
Make SearchController use yieldToSelector for search.
-rw-r--r-- | MobileCydia.mm | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index e6b6ca5..37d3d93 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -6243,12 +6243,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return true; } -- (void) reloadData { - [super reloadData]; - - era_ = [database_ era]; - NSArray *packages = [database_ packages]; +- (bool) shouldYield { + return false; +} +- (void) _reloadPackages:(NSArray *)packages { [packages_ removeAllObjects]; [sections_ removeAllObjects]; @@ -6257,6 +6256,20 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { if ([self hasPackage:package]) [packages_ addObject:package]; _end +} + +- (void) _reloadData { + era_ = [database_ era]; + NSArray *packages = [database_ packages]; + + if ([self shouldYield]) { + UIProgressHUD *hud([delegate_ addProgressHUD]); + [hud setText:UCLocalize("LOADING")]; + [self yieldToSelector:@selector(_reloadPackages:) withObject:packages]; + [delegate_ removeProgressHUD:hud]; + } else { + [self _reloadPackages:packages]; + } [indices_ removeAllObjects]; @@ -6331,6 +6344,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { _end } +- (void) reloadData { + [super reloadData]; + [self performSelector:@selector(_reloadData) withObject:nil afterDelay:0]; +} + - (void) resetCursor { [list_ scrollRectToVisible:CGRectMake(0, 0, 0, 0) animated:NO]; } @@ -6347,6 +6365,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { - (void) setObject:(id)object; - (void) setObject:(id)object forFilter:(SEL)filter; +- (SEL) filter; +- (void) setFilter:(SEL)filter; + - (id) initWithDatabase:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object; @end @@ -6359,6 +6380,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { [super dealloc]; } +- (SEL) filter { + return filter_; +} + - (void) setFilter:(SEL)filter { filter_ = filter; @@ -7599,17 +7624,34 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://search/%@", [search_ text]]]; } -- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar { +- (void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar { + [self setObject:[search_ text] forFilter:@selector(isUnfilteredAndSelectedForBy:)]; +} + +- (void) searchBarButtonClicked:(UISearchBar *)searchBar { [self setObject:[search_ text] forFilter:@selector(isUnfilteredAndSearchedForBy:)]; [search_ resignFirstResponder]; [self reloadData]; } +- (void) searchBarCancelButtonClicked:(UISearchBar *)searchBar { + [search_ setText:@""]; + [self searchBarButtonClicked:searchBar]; +} + +- (void) searchBarSearchButtonClicked:(UISearchBar *)searchBar { + [self searchBarButtonClicked:searchBar]; +} + - (void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)text { [self setObject:text forFilter:@selector(isUnfilteredAndSelectedForBy:)]; [self reloadData]; } +- (bool) shouldYield { + return [self filter] == @selector(isUnfilteredAndSearchedForBy:); +} + - (id) initWithDatabase:(Database *)database query:(NSString *)query { if ((self = [super initWithDatabase:database title:UCLocalize("SEARCH") filter:@selector(isUnfilteredAndSearchedForBy:) with:query])) { search_ = [[[UISearchBar alloc] init] autorelease]; |