Merge pull request #86 from tvon/patch-1

SDWebImageDownloader adds excessive observers when SDNetworkActivityIndicator is used
This commit is contained in:
Olivier Poitrey 2012-03-28 13:34:27 -07:00
commit 2283e2e458
1 changed files with 6 additions and 0 deletions

View File

@ -41,7 +41,13 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot
// To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
if (NSClassFromString(@"SDNetworkActivityIndicator"))
{
id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")];
// Remove observer in case it was previously added.
[[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:activityIndicator
selector:NSSelectorFromString(@"startActivity")
name:SDWebImageDownloadStartNotification object:nil];