Skip to content

Commit

Permalink
Update network activity indicator only if requests have a non nil URL
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Mar 7, 2013
1 parent 61188e2 commit 9c35300
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions AFNetworking/AFNetworkActivityIndicatorManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ - (id)init {
return nil;
}

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incrementActivityCount) name:AFNetworkingOperationDidStartNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(decrementActivityCount) name:AFNetworkingOperationDidFinishNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidStart:) name:AFNetworkingOperationDidStartNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil];

return self;
}
Expand Down Expand Up @@ -126,6 +126,20 @@ - (void)decrementActivityCount {
[self updateNetworkActivityIndicatorVisibilityDelayed];
}

- (void)networkingOperationDidStart:(NSNotification *)notification {
AFURLConnectionOperation *connectionOperation = [notification object];
if (connectionOperation.request.URL) {
[self incrementActivityCount];
}
}

- (void)networkingOperationDidFinish:(NSNotification *)notification {
AFURLConnectionOperation *connectionOperation = [notification object];
if (connectionOperation.request.URL) {
[self decrementActivityCount];
}
}

@end

#endif

0 comments on commit 9c35300

Please sign in to comment.