Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Jul 11, 2012
@epatey epatey Fix threading issue with AFNetworkActivityIndicatorManager.
Changed updateNetworkActivityIndicatorVisibilityDelayed
to use the main run loop rather than the current run loop
for its suppression timer.
Also, avoided extra dispatch to the main queue when not needed.
a8210a9
Commits on Jul 23, 2012
@mattt mattt Merge branch 'fixes/ActivityThreading' of git://github.com/talko/AFNe…
…tworking
e6bbfab
@mattt mattt Minor refactoring of changes to AFNetworkActivityIndicatorManager
Slightly reducing invisibility delay
69ff078
Showing with 5 additions and 6 deletions.
  1. +5 −6 AFNetworking/AFNetworkActivityIndicatorManager.m
View
11 AFNetworking/AFNetworkActivityIndicatorManager.m
@@ -25,14 +25,15 @@
#import "AFHTTPRequestOperation.h"
#if __IPHONE_OS_VERSION_MIN_REQUIRED
-static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.25;
+static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
@interface AFNetworkActivityIndicatorManager ()
@property (readwrite, atomic, assign) NSInteger activityCount;
@property (readwrite, nonatomic, retain) NSTimer *activityIndicatorVisibilityTimer;
@property (readonly, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
- (void)updateNetworkActivityIndicatorVisibility;
+- (void)updateNetworkActivityIndicatorVisibilityDelayed;
@end
@implementation AFNetworkActivityIndicatorManager
@@ -78,9 +79,9 @@ - (void)updateNetworkActivityIndicatorVisibilityDelayed {
if (![self isNetworkActivityIndicatorVisible]) {
[self.activityIndicatorVisibilityTimer invalidate];
self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO];
- [[NSRunLoop currentRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes];
+ [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes];
} else {
- [self updateNetworkActivityIndicatorVisibility];
+ [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
}
}
}
@@ -90,9 +91,7 @@ - (BOOL)isNetworkActivityIndicatorVisible {
}
- (void)updateNetworkActivityIndicatorVisibility {
- dispatch_async(dispatch_get_main_queue(), ^{
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
- });
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
}
// Not exposed, but used if activityCount is set via KVC.

No commit comments for this range

Something went wrong with that request. Please try again.