From 9365dad9b080554ded5a1891e39b82824a04465a Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Thu, 19 Nov 2020 16:22:44 +0800 Subject: [PATCH] Update the built-in loaders for the new protocol methods --- SDWebImage/Core/SDWebImageDownloader.m | 8 ++++++++ Tests/Tests/SDWebImageTestLoader.m | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/SDWebImage/Core/SDWebImageDownloader.m b/SDWebImage/Core/SDWebImageDownloader.m index 3d354add..cc220e85 100644 --- a/SDWebImage/Core/SDWebImageDownloader.m +++ b/SDWebImage/Core/SDWebImageDownloader.m @@ -561,6 +561,10 @@ didReceiveResponse:(NSURLResponse *)response @implementation SDWebImageDownloader (SDImageLoader) - (BOOL)canRequestImageForURL:(NSURL *)url { + return [self canRequestImageForURL:url options:0 context:nil]; +} + +- (BOOL)canRequestImageForURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context { if (!url) { return NO; } @@ -596,6 +600,10 @@ didReceiveResponse:(NSURLResponse *)response } - (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error { + return [self shouldBlockFailedURLWithURL:url error:error options:0 context:nil]; +} + +- (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error options:(SDWebImageOptions)options context:(SDWebImageContext *)context { BOOL shouldBlockFailedURL; // Filter the error domain and check error codes if ([error.domain isEqualToString:SDWebImageErrorDomain]) { diff --git a/Tests/Tests/SDWebImageTestLoader.m b/Tests/Tests/SDWebImageTestLoader.m index 14f6f7e5..89cc3ce5 100644 --- a/Tests/Tests/SDWebImageTestLoader.m +++ b/Tests/Tests/SDWebImageTestLoader.m @@ -26,6 +26,10 @@ } - (BOOL)canRequestImageForURL:(NSURL *)url { + return [self canRequestImageForURL:url options:0 context:nil]; +} + +- (BOOL)canRequestImageForURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context { return YES; } @@ -60,6 +64,10 @@ } - (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error { + return [self shouldBlockFailedURLWithURL:url error:error options:0 context:nil]; +} + +- (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error options:(SDWebImageOptions)options context:(SDWebImageContext *)context { return NO; }