Merge pull request #2531 from zhongwuzw/fix_reuse_wrong_image
Add image url check when set image
This commit is contained in:
commit
4fd0e83521
|
@ -101,7 +101,7 @@ static char TAG_ACTIVITY_SHOW;
|
||||||
};
|
};
|
||||||
id <SDWebImageOperation> operation = [manager loadImageWithURL:url options:options progress:combinedProgressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
id <SDWebImageOperation> operation = [manager loadImageWithURL:url options:options progress:combinedProgressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||||
__strong __typeof (wself) sself = wself;
|
__strong __typeof (wself) sself = wself;
|
||||||
if (!sself) { return; }
|
if (!sself || ![imageURL isEqual:sself.sd_imageURL]) { return; }
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
[sself sd_removeActivityIndicator];
|
[sself sd_removeActivityIndicator];
|
||||||
#endif
|
#endif
|
||||||
|
@ -114,9 +114,10 @@ static char TAG_ACTIVITY_SHOW;
|
||||||
BOOL shouldNotSetImage = ((image && (options & SDWebImageAvoidAutoSetImage)) ||
|
BOOL shouldNotSetImage = ((image && (options & SDWebImageAvoidAutoSetImage)) ||
|
||||||
(!image && !(options & SDWebImageDelayPlaceholder)));
|
(!image && !(options & SDWebImageDelayPlaceholder)));
|
||||||
SDWebImageNoParamsBlock callCompletedBlockClojure = ^{
|
SDWebImageNoParamsBlock callCompletedBlockClojure = ^{
|
||||||
if (!sself) { return; }
|
__strong __typeof(wself) strongSelf = wself;
|
||||||
|
if (!strongSelf || ![strongSelf.sd_imageURL isEqual:imageURL]) { return; }
|
||||||
if (!shouldNotSetImage) {
|
if (!shouldNotSetImage) {
|
||||||
[sself sd_setNeedsLayout];
|
[strongSelf sd_setNeedsLayout];
|
||||||
}
|
}
|
||||||
if (completedBlock && shouldCallCompletedBlock) {
|
if (completedBlock && shouldCallCompletedBlock) {
|
||||||
completedBlock(image, error, cacheType, url);
|
completedBlock(image, error, cacheType, url);
|
||||||
|
@ -154,6 +155,7 @@ static char TAG_ACTIVITY_SHOW;
|
||||||
if (group) {
|
if (group) {
|
||||||
dispatch_group_enter(group);
|
dispatch_group_enter(group);
|
||||||
}
|
}
|
||||||
|
if (![sself.sd_imageURL isEqual:imageURL]) { return ; }
|
||||||
#if SD_UIKIT || SD_MAC
|
#if SD_UIKIT || SD_MAC
|
||||||
[sself sd_setImage:targetImage imageData:targetData basedOnClassOrViaCustomSetImageBlock:setImageBlock transition:transition cacheType:cacheType imageURL:imageURL];
|
[sself sd_setImage:targetImage imageData:targetData basedOnClassOrViaCustomSetImageBlock:setImageBlock transition:transition cacheType:cacheType imageURL:imageURL];
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue