Change the optional method into required, force the custom loader author to provide the error check
This commit is contained in:
parent
691873117a
commit
2640301e82
|
@ -86,11 +86,9 @@ FOUNDATION_EXPORT UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NS
|
|||
completed:(nullable SDImageLoaderCompletedBlock)completedBlock;
|
||||
|
||||
|
||||
@optional
|
||||
/**
|
||||
Whether the error from image loader should be marked indded un-recoverable or not.
|
||||
If this return YES, failed URL which does not using `SDWebImageRetryFailed` will be blocked into black list. Else not.
|
||||
If does not implements this method, assume always return NO.
|
||||
|
||||
@param url The URL represent the image. Note this may not be a HTTP URL
|
||||
@param error The URL's loading error, from previous `requestImageWithURL:options:context:progress:completed:` completedBlock's error.
|
||||
|
|
|
@ -104,11 +104,7 @@
|
|||
NSArray<id<SDImageLoader>> *loaders = self.loaders;
|
||||
for (id<SDImageLoader> loader in loaders.reverseObjectEnumerator) {
|
||||
if ([loader canRequestImageForURL:url]) {
|
||||
if ([loader respondsToSelector:@selector(shouldBlockFailedURLWithURL:error:)]) {
|
||||
return [loader shouldBlockFailedURLWithURL:url error:error];
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
return [loader shouldBlockFailedURLWithURL:url error:error];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
|
|
|
@ -374,11 +374,7 @@ static id<SDImageLoader> _defaultImageLoader;
|
|||
if ([self.delegate respondsToSelector:@selector(imageManager:shouldBlockFailedURL:withError:)]) {
|
||||
shouldBlockFailedURL = [self.delegate imageManager:self shouldBlockFailedURL:url withError:error];
|
||||
} else {
|
||||
if ([self.imageLoader respondsToSelector:@selector(shouldBlockFailedURLWithURL:error:)]) {
|
||||
shouldBlockFailedURL = [self.imageLoader shouldBlockFailedURLWithURL:url error:error];
|
||||
} else {
|
||||
shouldBlockFailedURL = NO;
|
||||
}
|
||||
shouldBlockFailedURL = [self.imageLoader shouldBlockFailedURLWithURL:url error:error];
|
||||
}
|
||||
|
||||
return shouldBlockFailedURL;
|
||||
|
|
|
@ -50,4 +50,8 @@
|
|||
return task;
|
||||
}
|
||||
|
||||
- (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue