Renaming `SDWebImageProgressiveDownload` to `SDWebImageProgressiveLoad`. Which is more suitable for custom loader which also support progressive image loading. (No need to be download)
This commit is contained in:
parent
ac47ce3a0d
commit
e9cf356e57
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
[self.imageView sd_setImageWithURL:self.imageURL
|
||||
placeholderImage:nil
|
||||
options:SDWebImageProgressiveDownload];
|
||||
options:SDWebImageProgressiveLoad];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
self.imageView3.animates = YES;
|
||||
self.imageView4.animates = YES;
|
||||
self.imageView1.sd_imageIndicator = SDWebImageProgressIndicator.defaultIndicator;
|
||||
[self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg"] placeholderImage:nil options:SDWebImageProgressiveDownload];
|
||||
[self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg"] placeholderImage:nil options:SDWebImageProgressiveLoad];
|
||||
[self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"https:raw.githubusercontent.com/onevcat/APNGKit/master/TestImages/APNG-cube.apng"]];
|
||||
[self.imageView3 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"]];
|
||||
self.imageView4.wantsLayer = YES;
|
||||
|
|
|
@ -70,7 +70,7 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
|
|||
* 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,
|
||||
SDWebImageProgressiveLoad = 1 << 3,
|
||||
|
||||
/**
|
||||
* Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.
|
||||
|
@ -128,7 +128,7 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
|
|||
/**
|
||||
* By default, images are decoded respecting their original size. On iOS, this flag will scale down the
|
||||
* images to a size compatible with the constrained memory of devices.
|
||||
* This flag take no effect if `SDWebImageAvoidDecodeImage` is set. And it will be ignored if `SDWebImageProgressiveDownload` is set.
|
||||
* This flag take no effect if `SDWebImageAvoidDecodeImage` is set. And it will be ignored if `SDWebImageProgressiveLoad` is set.
|
||||
*/
|
||||
SDWebImageScaleDownLargeImages = 1 << 12,
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
|
|||
/**
|
||||
* This flag enables progressive download, the image is displayed progressively during download as a browser would do.
|
||||
*/
|
||||
SDWebImageDownloaderProgressiveDownload = 1 << 1,
|
||||
SDWebImageDownloaderProgressiveLoad = 1 << 1,
|
||||
|
||||
/**
|
||||
* By default, request prevent the use of NSURLCache. With this flag, NSURLCache
|
||||
|
@ -64,7 +64,7 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
|
|||
/**
|
||||
* By default, images are decoded respecting their original size. On iOS, this flag will scale down the
|
||||
* images to a size compatible with the constrained memory of devices.
|
||||
* This flag take no effect if `SDWebImageDownloaderAvoidDecodeImage` is set. And it will be ignored if `SDWebImageDownloaderProgressiveDownload` is set.
|
||||
* This flag take no effect if `SDWebImageDownloaderAvoidDecodeImage` is set. And it will be ignored if `SDWebImageDownloaderProgressiveLoad` is set.
|
||||
*/
|
||||
SDWebImageDownloaderScaleDownLargeImages = 1 << 8,
|
||||
|
||||
|
@ -197,8 +197,8 @@ typedef SDWebImageLoaderCompletedBlock SDWebImageDownloaderCompletedBlock;
|
|||
* @param completedBlock A block called once the download is completed.
|
||||
* If the download succeeded, the image parameter is set, in case of error,
|
||||
* error parameter is set with the error. The last parameter is always YES
|
||||
* if SDWebImageDownloaderProgressiveDownload isn't use. With the
|
||||
* SDWebImageDownloaderProgressiveDownload option, this block is called
|
||||
* if SDWebImageDownloaderProgressiveLoad isn't use. With the
|
||||
* SDWebImageDownloaderProgressiveLoad option, this block is called
|
||||
* repeatedly with the partial image object and the finished argument set to NO
|
||||
* before to be called a last time with the full image and finished argument
|
||||
* set to YES. In case of error, the finished argument is always YES.
|
||||
|
|
|
@ -480,7 +480,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
}
|
||||
SDWebImageDownloaderOptions downloaderOptions = 0;
|
||||
if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority;
|
||||
if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload;
|
||||
if (options & SDWebImageProgressiveLoad) downloaderOptions |= SDWebImageDownloaderProgressiveLoad;
|
||||
if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache;
|
||||
if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground;
|
||||
if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies;
|
||||
|
@ -490,7 +490,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
|
||||
if (cachedImage && options & SDWebImageRefreshCached) {
|
||||
// force progressive off if image already cached but forced refreshing
|
||||
downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;
|
||||
downloaderOptions &= ~SDWebImageDownloaderProgressiveLoad;
|
||||
// ignore image read from NSURLCache if image if cached but force refreshing
|
||||
downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
}
|
||||
[self.imageData appendData:data];
|
||||
|
||||
if ((self.options & SDWebImageDownloaderProgressiveDownload) && self.expectedSize > 0) {
|
||||
if ((self.options & SDWebImageDownloaderProgressiveLoad) && self.expectedSize > 0) {
|
||||
// Get the image data
|
||||
NSData *imageData = [self.imageData copy];
|
||||
// Get the total bytes downloaded
|
||||
|
|
|
@ -38,7 +38,7 @@ FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextLoader
|
|||
FOUNDATION_EXPORT UIImage * _Nullable SDWebImageLoaderDecodeImageData(NSData * _Nonnull imageData, NSURL * _Nonnull imageURL, SDWebImageOptions options, SDWebImageContext * _Nullable context);
|
||||
|
||||
/**
|
||||
This is the built-in decoding process for image progressive download from network. It's used when `SDWebImageProgressiveDownload` option is set. (It's not required when your loader does not support progressive image loading)
|
||||
This is the built-in decoding process for image progressive download from network. It's used when `SDWebImageProgressiveLoad` option is set. (It's not required when your loader does not support progressive image loading)
|
||||
@note If you want to implement your custom loader with `loadImageWithURL:options:context:progress:completed:` API, but also want to keep compatible with SDWebImage's behavior, you'd better use this to produce image.
|
||||
|
||||
@param imageData The image data from the network so far. Should not be nil
|
||||
|
|
|
@ -194,7 +194,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
|
|||
* The forth parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache
|
||||
* or from the memory cache or from the network.
|
||||
*
|
||||
* The fith parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is
|
||||
* The fith parameter is set to NO when the SDWebImageProgressiveLoad option is used and the image is
|
||||
* downloading. This block is thus called repeatedly with a partial image. When image is fully downloaded, the
|
||||
* block is called a last time with the full image and the last parameter set to YES.
|
||||
*
|
||||
|
|
|
@ -59,7 +59,7 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima
|
|||
* The forth parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache
|
||||
* or from the memory cache or from the network.
|
||||
*
|
||||
* The fith parameter normally is always YES. However, if you provide SDWebImageAvoidAutoSetImage with SDWebImageProgressiveDownload options to enable progressive downloading and set the image yourself. This block is thus called repeatedly with a partial image. When image is fully downloaded, the
|
||||
* The fith parameter normally is always YES. However, if you provide SDWebImageAvoidAutoSetImage with SDWebImageProgressiveLoad options to enable progressive downloading and set the image yourself. This block is thus called repeatedly with a partial image. When image is fully downloaded, the
|
||||
* block is called a last time with the full image and the last parameter set to YES.
|
||||
*
|
||||
* The last parameter is the original image URL
|
||||
|
|
|
@ -196,7 +196,7 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"test SDAnimatedImageView view category"];
|
||||
SDAnimatedImageView *imageView = [SDAnimatedImageView new];
|
||||
NSURL *testURL = [NSURL URLWithString:kTestGIFURL];
|
||||
[imageView sd_setImageWithURL:testURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
|
||||
[imageView sd_setImageWithURL:testURL placeholderImage:nil options:SDWebImageProgressiveLoad progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIImage *image = imageView.image;
|
||||
// Progressive image may be nil when download data is not enough
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
- (void)test09ThatProgressiveJPEGWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Progressive JPEG download"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:SDWebImageDownloaderProgressiveDownload progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:SDWebImageDownloaderProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (image && data && !error && finished) {
|
||||
[expectation fulfill];
|
||||
} else if (finished) {
|
||||
|
@ -251,7 +251,7 @@
|
|||
- (void)test16ThatProgressiveWebPWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Progressive WebP download"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://www.ioncannon.net/wp-content/uploads/2011/06/test9.webp"];
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:SDWebImageDownloaderProgressiveDownload progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:SDWebImageDownloaderProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (image && data && !error && finished) {
|
||||
[expectation fulfill];
|
||||
} else if (finished) {
|
||||
|
|
Loading…
Reference in New Issue