Merge pull request #86 from tvon/patch-1
SDWebImageDownloader adds excessive observers when SDNetworkActivityIndicator is used
This commit is contained in:
commit
2283e2e458
|
@ -41,7 +41,13 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot
|
||||||
// To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
|
// To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
|
||||||
if (NSClassFromString(@"SDNetworkActivityIndicator"))
|
if (NSClassFromString(@"SDNetworkActivityIndicator"))
|
||||||
{
|
{
|
||||||
|
|
||||||
id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")];
|
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
|
[[NSNotificationCenter defaultCenter] addObserver:activityIndicator
|
||||||
selector:NSSelectorFromString(@"startActivity")
|
selector:NSSelectorFromString(@"startActivity")
|
||||||
name:SDWebImageDownloadStartNotification object:nil];
|
name:SDWebImageDownloadStartNotification object:nil];
|
||||||
|
|
Loading…
Reference in New Issue