Merge pull request #2671 from zhongwuzw/fix_cancel_current_image_load
Cancel latest image load when call cancelCurrentImageLoad
This commit is contained in:
commit
8a4932420c
|
@ -23,6 +23,14 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
|
||||||
objc_setAssociatedObject(self, @selector(sd_imageURL), sd_imageURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(self, @selector(sd_imageURL), sd_imageURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (nullable NSString *)sd_latestOperationKey {
|
||||||
|
return objc_getAssociatedObject(self, @selector(sd_latestOperationKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setSd_latestOperationKey:(NSString * _Nullable)sd_latestOperationKey {
|
||||||
|
objc_setAssociatedObject(self, @selector(sd_latestOperationKey), sd_latestOperationKey, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||||
|
}
|
||||||
|
|
||||||
- (NSProgress *)sd_imageProgress {
|
- (NSProgress *)sd_imageProgress {
|
||||||
NSProgress *progress = objc_getAssociatedObject(self, @selector(sd_imageProgress));
|
NSProgress *progress = objc_getAssociatedObject(self, @selector(sd_imageProgress));
|
||||||
if (!progress) {
|
if (!progress) {
|
||||||
|
@ -48,6 +56,7 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
|
||||||
if (!validOperationKey) {
|
if (!validOperationKey) {
|
||||||
validOperationKey = NSStringFromClass([self class]);
|
validOperationKey = NSStringFromClass([self class]);
|
||||||
}
|
}
|
||||||
|
self.sd_latestOperationKey = validOperationKey;
|
||||||
[self sd_cancelImageLoadOperationWithKey:validOperationKey];
|
[self sd_cancelImageLoadOperationWithKey:validOperationKey];
|
||||||
self.sd_imageURL = url;
|
self.sd_imageURL = url;
|
||||||
|
|
||||||
|
@ -171,7 +180,7 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sd_cancelCurrentImageLoad {
|
- (void)sd_cancelCurrentImageLoad {
|
||||||
[self sd_cancelImageLoadOperationWithKey:NSStringFromClass([self class])];
|
[self sd_cancelImageLoadOperationWithKey:self.sd_latestOperationKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sd_setImage:(UIImage *)image imageData:(NSData *)imageData basedOnClassOrViaCustomSetImageBlock:(SDSetImageBlock)setImageBlock cacheType:(SDImageCacheType)cacheType imageURL:(NSURL *)imageURL {
|
- (void)sd_setImage:(UIImage *)image imageData:(NSData *)imageData basedOnClassOrViaCustomSetImageBlock:(SDSetImageBlock)setImageBlock cacheType:(SDImageCacheType)cacheType imageURL:(NSURL *)imageURL {
|
||||||
|
|
Loading…
Reference in New Issue