diff --git a/SDWebImage/SDImageCache.h b/SDWebImage/SDImageCache.h index 417a559..8989a18 100644 --- a/SDWebImage/SDImageCache.h +++ b/SDWebImage/SDImageCache.h @@ -13,15 +13,15 @@ typedef NS_ENUM(NSInteger, SDImageCacheType) { /** * The image wasn't available the SDWebImage caches, but was downloaded from the web. */ - SDImageCacheTypeNone, + SDImageCacheTypeNone, /** * The image was obtained from the disk cache. */ - SDImageCacheTypeDisk, + SDImageCacheTypeDisk, /** * The image was obtained from the memory cache. */ - SDImageCacheTypeMemory + SDImageCacheTypeMemory }; typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); diff --git a/SDWebImage/SDWebImageCompat.h b/SDWebImage/SDWebImageCompat.h index 6085ec4..2d90d3c 100644 --- a/SDWebImage/SDWebImageCompat.h +++ b/SDWebImage/SDWebImageCompat.h @@ -54,11 +54,9 @@ extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); #define dispatch_main_sync_safe(block)\ - if ([NSThread isMainThread])\ - {\ + if ([NSThread isMainThread]) {\ block();\ }\ - else\ - {\ + else {\ dispatch_sync(dispatch_get_main_queue(), block);\ } diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index 33ed776..0895997 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -13,48 +13,56 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { SDWebImageDownloaderLowPriority = 1 << 0, SDWebImageDownloaderProgressiveDownload = 1 << 1, + /** * By default, request prevent the of NSURLCache. With this flag, NSURLCache * is used with default policies. */ - SDWebImageDownloaderUseNSURLCache = 1 << 2, + SDWebImageDownloaderUseNSURLCache = 1 << 2, + /** * Call completion block with nil image/imageData if the image was read from NSURLCache * (to be combined with `SDWebImageDownloaderUseNSURLCache`). */ - SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, + + SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, /** * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for * extra time in background to let the request finish. If the background task expires the operation will be cancelled. */ - SDWebImageDownloaderContinueInBackground = 1 << 4, + + SDWebImageDownloaderContinueInBackground = 1 << 4, + /** * Handles cookies stored in NSHTTPCookieStore by setting * NSMutableURLRequest.HTTPShouldHandleCookies = YES; */ - SDWebImageDownloaderHandleCookies = 1 << 5, + SDWebImageDownloaderHandleCookies = 1 << 5, + /** * Enable to allow untrusted SSL ceriticates. * Useful for testing purposes. Use with caution in production. */ - SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, + SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, + /** - * + * Put the image in the high priority queue. */ - SDWebImageDownloaderHighPriority = 1 << 7, + SDWebImageDownloaderHighPriority = 1 << 7, }; typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { - SDWebImageDownloaderFIFOExecutionOrder, /** * Default value. All download operations will execute in queue style (first-in-first-out). */ - SDWebImageDownloaderLIFOExecutionOrder + SDWebImageDownloaderFIFOExecutionOrder, + /** * All download operations will execute in stack style (last-in-first-out). */ + SDWebImageDownloaderLIFOExecutionOrder }; extern NSString *const SDWebImageDownloadStartNotification; diff --git a/SDWebImage/SDWebImageManager.h b/SDWebImage/SDWebImageManager.h index 1284ba7..45598c4 100644 --- a/SDWebImage/SDWebImageManager.h +++ b/SDWebImage/SDWebImageManager.h @@ -16,21 +16,25 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. * This flag disable this blacklisting. */ - SDWebImageRetryFailed = 1 << 0, + SDWebImageRetryFailed = 1 << 0, + /** * By default, image downloads are started during UI interactions, this flags disable this feature, * leading to delayed download on UIScrollView deceleration for instance. */ - SDWebImageLowPriority = 1 << 1, + SDWebImageLowPriority = 1 << 1, + /** * This flag disables on-disk caching */ - SDWebImageCacheMemoryOnly = 1 << 2, + SDWebImageCacheMemoryOnly = 1 << 2, + /** * This flag enables progressive download, the image is displayed progressively during download as a browser would do. * By default, the image is only displayed once completely downloaded. */ - SDWebImageProgressiveDownload = 1 << 3, + SDWebImageProgressiveDownload = 1 << 3, + /** * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. @@ -39,29 +43,32 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { * * Use this flag only if you can't make your URLs static with embeded cache busting parameter. */ - SDWebImageRefreshCached = 1 << 4, + SDWebImageRefreshCached = 1 << 4, /** * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for * extra time in background to let the request finish. If the background task expires the operation will be cancelled. */ - SDWebImageContinueInBackground = 1 << 5, + SDWebImageContinueInBackground = 1 << 5, + /** * Handles cookies stored in NSHTTPCookieStore by setting * NSMutableURLRequest.HTTPShouldHandleCookies = YES; */ - SDWebImageHandleCookies = 1 << 6, + SDWebImageHandleCookies = 1 << 6, + /** * Enable to allow untrusted SSL ceriticates. * Useful for testing purposes. Use with caution in production. */ - SDWebImageAllowInvalidSSLCertificates = 1 << 7, + SDWebImageAllowInvalidSSLCertificates = 1 << 7, + /** * By default, image are loaded in the order they were queued. This flag move them to * 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 }; typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType); @@ -113,10 +120,8 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadWithURL:imageURL options:0 progress:nil - completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) - { - if (image) - { + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) { + if (image) { // do something with image } }]; @@ -139,8 +144,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager]; * * @code -[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) -{ +[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; return [url absoluteString]; }]; diff --git a/SDWebImage/UIImage+WebP.m b/SDWebImage/UIImage+WebP.m index 59efecb..50036d6 100644 --- a/SDWebImage/UIImage+WebP.m +++ b/SDWebImage/UIImage+WebP.m @@ -18,11 +18,9 @@ static void FreeImageData(void *info, const void *data, size_t size) @implementation UIImage (WebP) -+ (UIImage *)sd_imageWithWebPData:(NSData *)data -{ ++ (UIImage *)sd_imageWithWebPData:(NSData *)data { WebPDecoderConfig config; - if (!WebPInitDecoderConfig(&config)) - { + if (!WebPInitDecoderConfig(&config)) { return nil; } @@ -30,15 +28,13 @@ static void FreeImageData(void *info, const void *data, size_t size) config.options.use_threads = 1; // Decode the WebP image data into a RGBA value array. - if (WebPDecode(data.bytes, data.length, &config) != VP8_STATUS_OK) - { + if (WebPDecode(data.bytes, data.length, &config) != VP8_STATUS_OK) { return nil; } int width = config.input.width; int height = config.input.height; - if (config.options.use_scaling) - { + if (config.options.use_scaling) { width = config.options.scaled_width; height = config.options.scaled_height; } diff --git a/SDWebImage/UIImageView+WebCache.h b/SDWebImage/UIImageView+WebCache.h index 306f874..46f1f0b 100644 --- a/SDWebImage/UIImageView+WebCache.h +++ b/SDWebImage/UIImageView+WebCache.h @@ -26,8 +26,7 @@ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; - if (cell == nil) - { + if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; }