зеркало из https://github.com/github/AFNetworking.git
Merge pull request #842 from 0xced/no-nil-network-activity
Update network activity indicator only if requests have a non nil URL
This commit is contained in:
Коммит
48ca0846bb
|
@ -62,8 +62,8 @@ static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
|
|||
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;
|
||||
}
|
||||
|
@ -126,6 +126,20 @@ static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
|
|||
[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
|
||||
|
|
Загрузка…
Ссылка в новой задаче