diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-02 03:33:09 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-02 03:48:55 -0800 |
commit | 540437033286aa962b940cefac84686abf6d9ffa (patch) | |
tree | 2c29082de260d6676ec09a955cbeb0c80b764ef5 /MobileCydia.mm | |
parent | 61cc8460c4bb3c19180732df2006a63a9b62680b (diff) |
Use UIApplication::networkActivityIndicator to indicate network activity.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 7b4b70f..5c12b8b 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1184,6 +1184,8 @@ bool isSectionVisible(NSString *section) { @class PackageController; @protocol CydiaDelegate +- (void) retainNetworkActivityIndicator; +- (void) releaseNetworkActivityIndicator; - (void) setPackageController:(PackageController *)view; - (void) clearPackage:(Package *)package; - (void) installPackage:(Package *)package; @@ -1202,6 +1204,8 @@ bool isSectionVisible(NSString *section) { - (PackageController *) packageController; - (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item; @end + +static id<CydiaDelegate> CydiaApp; /* }}} */ /* Status Delegation {{{ */ @@ -3580,6 +3584,8 @@ static NSString *Warning_; return; } + [CydiaApp retainNetworkActivityIndicator]; + bool failed = false; for (pkgAcquire::ItemIterator item = fetcher_->ItemsBegin(); item != fetcher_->ItemsEnd(); item++) { if ((*item)->Status == pkgAcquire::Item::StatDone && (*item)->Complete) @@ -3601,6 +3607,8 @@ static NSString *Warning_; ]; } + [CydiaApp releaseNetworkActivityIndicator]; + if (failed) { _trace(); return; @@ -6684,9 +6692,10 @@ freeing the view controllers on tab change */ } - (void) beginUpdate { - [self dropBar:YES]; [refreshbar_ start]; + [self dropBar:YES]; + [updatedelegate_ retainNetworkActivityIndicator]; updating_ = true; [NSThread @@ -6708,21 +6717,24 @@ freeing the view controllers on tab change */ ]; } -- (void) completeUpdate { - if (!updating_) - return; +- (void) stopUpdateWithSelector:(SEL)selector { updating_ = false; + [updatedelegate_ releaseNetworkActivityIndicator]; [self raiseBar:YES]; [refreshbar_ stop]; - [updatedelegate_ performSelector:@selector(reloadData) withObject:nil afterDelay:0]; + + [updatedelegate_ performSelector:selector withObject:nil afterDelay:0]; +} + +- (void) completeUpdate { + if (!updating_) + return; + [self stopUpdateWithSelector:@selector(reloadData)]; } - (void) cancelUpdate { - updating_ = false; - [self raiseBar:YES]; - [refreshbar_ stop]; - [updatedelegate_ performSelector:@selector(updateData) withObject:nil afterDelay:0]; + [self stopUpdateWithSelector:@selector(updateData)]; } - (void) cancelPressed { @@ -7991,9 +8003,11 @@ typedef enum { Database *database_; + NSURL *starturl_; int tag_; + unsigned locked_; - NSURL *starturl_; + unsigned activity_; SectionsController *sections_; ChangesController *changes_; @@ -8471,6 +8485,16 @@ static _finline void _setHomePage(Cydia *self) { [tabbar_ presentModalViewController:nav animated:YES]; } +- (void) retainNetworkActivityIndicator { + if (activity_++ == 0) + [self setNetworkActivityIndicatorVisible:YES]; +} + +- (void) releaseNetworkActivityIndicator { + if (--activity_ == 0) + [self setNetworkActivityIndicatorVisible:NO]; +} + - (void) setPackageController:(PackageController *)view { WebThreadLock(); [view setPackage:nil]; @@ -8766,6 +8790,8 @@ static _finline void _setHomePage(Cydia *self) { - (void) applicationDidFinishLaunching:(id)unused { _trace(); + CydiaApp = self; + [NSURLCache setSharedURLCache:[[[SDURLCache alloc] initWithMemoryCapacity:524288 diskCapacity:10485760 |