From f7ee9d337513fdb181543f9b7ad80e38f7fcb3ec Mon Sep 17 00:00:00 2001 From: Bill Burgess Date: Mon, 28 Apr 2014 12:30:27 -0500 Subject: [PATCH] Moved the delay placeholder flag to SDWebImageOptions --- SDWebImage/SDWebImageManager.h | 8 +++++++- SDWebImage/UIImageView+WebCache.h | 18 ------------------ SDWebImage/UIImageView+WebCache.m | 8 ++------ 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/SDWebImage/SDWebImageManager.h b/SDWebImage/SDWebImageManager.h index 45598c4..003d1ff 100644 --- a/SDWebImage/SDWebImageManager.h +++ b/SDWebImage/SDWebImageManager.h @@ -68,7 +68,13 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which * could take a while). */ - SDWebImageHighPriority = 1 << 8 + SDWebImageHighPriority = 1 << 8, + + /** + * By default, placeholder images are loaded while the image is loading. This flag will delay the loading + * of the placeholder image until after the image has finished loading. + */ + SDWebImageDelayPlaceholder = 1 << 9 }; typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType); diff --git a/SDWebImage/UIImageView+WebCache.h b/SDWebImage/UIImageView+WebCache.h index c337088..cfdd675 100644 --- a/SDWebImage/UIImageView+WebCache.h +++ b/SDWebImage/UIImageView+WebCache.h @@ -133,24 +133,6 @@ */ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock; -/** - * Set the imageView 'image' with an 'url', placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param delayPlaceholder The value that determines if the placeholder is loaded while the image is fetched, - * or after the image fails to load. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param progressBlock A block called while image is downloading - * @param completedBlock A block called when operation has been completed. This block as no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache of from the network. - */ -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder delayPlaceholderLoad:(BOOL)delayPlaceholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock; - /** * Download an array of images and starts them in an animation loop * diff --git a/SDWebImage/UIImageView+WebCache.m b/SDWebImage/UIImageView+WebCache.m index d7f7fa4..f425506 100644 --- a/SDWebImage/UIImageView+WebCache.m +++ b/SDWebImage/UIImageView+WebCache.m @@ -39,13 +39,9 @@ static char operationArrayKey; } - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { - [self setImageWithURL:url placeholderImage:placeholder delayPlaceholderLoad:NO options:options progress:progressBlock completed:completedBlock]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder delayPlaceholderLoad:(BOOL)delayPlaceholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { [self cancelCurrentImageLoad]; - if (!delayPlaceholder) { + if (options != SDWebImageDelayPlaceholder) { self.image = placeholder; } @@ -59,7 +55,7 @@ static char operationArrayKey; wself.image = image; [wself setNeedsLayout]; } else { - if (delayPlaceholder) { + if (options == SDWebImageDelayPlaceholder) { wself.image = placeholder; [wself setNeedsLayout]; }