This commit is contained in:
parent
9a1f072e5e
commit
c6664248f1
|
@ -48,6 +48,9 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
__weak MKAnnotationView *wself = self;
|
__weak MKAnnotationView *wself = self;
|
||||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
||||||
|
{
|
||||||
|
if (!wself) return;
|
||||||
|
void (^block)(void) = ^
|
||||||
{
|
{
|
||||||
__strong MKAnnotationView *sself = wself;
|
__strong MKAnnotationView *sself = wself;
|
||||||
if (!sself) return;
|
if (!sself) return;
|
||||||
|
@ -59,6 +62,15 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
completedBlock(image, error, cacheType);
|
completedBlock(image, error, cacheType);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if ([NSThread isMainThread])
|
||||||
|
{
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dispatch_sync(dispatch_get_main_queue(), block);
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
__weak UIButton *wself = self;
|
__weak UIButton *wself = self;
|
||||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
||||||
|
{
|
||||||
|
if (!wself) return;
|
||||||
|
void (^block)(void) = ^
|
||||||
{
|
{
|
||||||
__strong UIButton *sself = wself;
|
__strong UIButton *sself = wself;
|
||||||
if (!sself) return;
|
if (!sself) return;
|
||||||
|
@ -58,6 +61,15 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
completedBlock(image, error, cacheType);
|
completedBlock(image, error, cacheType);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if ([NSThread isMainThread])
|
||||||
|
{
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dispatch_sync(dispatch_get_main_queue(), block);
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +110,9 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
__weak UIButton *wself = self;
|
__weak UIButton *wself = self;
|
||||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
||||||
|
{
|
||||||
|
if (!wself) return;
|
||||||
|
void (^block)(void) = ^
|
||||||
{
|
{
|
||||||
__strong UIButton *sself = wself;
|
__strong UIButton *sself = wself;
|
||||||
if (!sself) return;
|
if (!sself) return;
|
||||||
|
@ -109,6 +124,15 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
completedBlock(image, error, cacheType);
|
completedBlock(image, error, cacheType);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if ([NSThread isMainThread])
|
||||||
|
{
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dispatch_sync(dispatch_get_main_queue(), block);
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,9 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
__weak UIImageView *wself = self;
|
__weak UIImageView *wself = self;
|
||||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
|
||||||
|
{
|
||||||
|
if (!wself) return;
|
||||||
|
void (^block)(void) = ^
|
||||||
{
|
{
|
||||||
__strong UIImageView *sself = wself;
|
__strong UIImageView *sself = wself;
|
||||||
if (!sself) return;
|
if (!sself) return;
|
||||||
|
@ -65,6 +68,15 @@ static char operationKey;
|
||||||
{
|
{
|
||||||
completedBlock(image, error, cacheType);
|
completedBlock(image, error, cacheType);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if ([NSThread isMainThread])
|
||||||
|
{
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dispatch_sync(dispatch_get_main_queue(), block);
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(self, &operationKey, operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue