]> git.saurik.com Git - cydia.git/commitdiff
Use UIApplication::networkActivityIndicator to indicate network activity.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 2 Dec 2010 11:33:09 +0000 (03:33 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 2 Dec 2010 11:48:55 +0000 (03:48 -0800)
MobileCydia.mm
UICaboodle/BrowserView.h
UICaboodle/BrowserView.mm

index 7b4b70fe983a98c381a483ab37c5a5c551b224af..5c12b8b10d7c9fc2f88ba78320aa58ede3e22c34 100644 (file)
@@ -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
index f5d50294e45d2d05b5037f6d84401f166fc57a86..f224326a17895ca9b68b1072c216a3a5cb2fe23d 100644 (file)
@@ -50,6 +50,8 @@
 @end
 
 @protocol BrowserControllerDelegate
+- (void) retainNetworkActivityIndicator;
+- (void) releaseNetworkActivityIndicator;
 - (CYViewController *) pageForURL:(NSURL *)url hasTag:(int *)tag;
 @end
 
index 5fd65c21ee0b4be57effd3ac692a611c3bab4d76..f1053f85e65f5c5fa76185f6c4900ca510adb104 100644 (file)
@@ -451,6 +451,8 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
     if (title_ != nil)
         [title_ release];
 
+    if ([loading_ count] != 0)
+        [delegate_ releaseNetworkActivityIndicator];
     [loading_ release];
 
     [reloaditem_ release];
@@ -904,11 +906,16 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
 
 - (void) _didStartLoading {
     [self applyRightButton];
+
+    if ([loading_ count] != 1)
+        return;
+    [delegate_ retainNetworkActivityIndicator];
 }
 
 - (void) _didFinishLoading {
     if ([loading_ count] != 0)
         return;
+    [delegate_ releaseNetworkActivityIndicator];
 
     [self applyRightButton];