Merge pull request #351 from Vyazovoy/master
New name for SDWebImageDownloaderQueueMode type, typo fixing, strong cycle fixing.
This commit is contained in:
commit
eda987815b
|
@ -34,12 +34,13 @@
|
||||||
if (self.imageURL)
|
if (self.imageURL)
|
||||||
{
|
{
|
||||||
__block UIActivityIndicatorView *activityIndicator;
|
__block UIActivityIndicatorView *activityIndicator;
|
||||||
|
__weak UIImageView *weakImageView = self.imageView;
|
||||||
[self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
|
[self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
|
||||||
{
|
{
|
||||||
if (!activityIndicator)
|
if (!activityIndicator)
|
||||||
{
|
{
|
||||||
[self.imageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
|
[weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
|
||||||
activityIndicator.center = self.imageView.center;
|
activityIndicator.center = weakImageView.center;
|
||||||
[activityIndicator startAnimating];
|
[activityIndicator startAnimating];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,7 +333,7 @@
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
[SDWebImageManager.sharedManager.imageDownloader setValue:@"SDWebImage Demo" forHTTPHeaderField:@"AppName"];
|
[SDWebImageManager.sharedManager.imageDownloader setValue:@"SDWebImage Demo" forHTTPHeaderField:@"AppName"];
|
||||||
SDWebImageManager.sharedManager.imageDownloader.queueMode = SDWebImageDownloaderLIFOQueueMode;
|
SDWebImageManager.sharedManager.imageDownloader.executionOrder = SDWebImageDownloaderLIFOExecutionOrder;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ enum SDImageCacheType
|
||||||
*/
|
*/
|
||||||
SDImageCacheTypeDisk,
|
SDImageCacheTypeDisk,
|
||||||
/**
|
/**
|
||||||
* The image was obtained from the disk cache.
|
* The image was obtained from the memory cache.
|
||||||
*/
|
*/
|
||||||
SDImageCacheTypeMemory
|
SDImageCacheTypeMemory
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,9 +28,15 @@ typedef enum
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SDWebImageDownloaderFILOQueueMode,
|
SDWebImageDownloaderFIFOExecutionOrder,
|
||||||
SDWebImageDownloaderLIFOQueueMode
|
/**
|
||||||
} SDWebImageDownloaderQueueMode;
|
* Default value. All download operations will execute in queue style (first-in-first-out).
|
||||||
|
*/
|
||||||
|
SDWebImageDownloaderLIFOExecutionOrder
|
||||||
|
/**
|
||||||
|
* All download operations will execute in stack style (last-in-first-out).
|
||||||
|
*/
|
||||||
|
} SDWebImageDownloaderExecutionOrder;
|
||||||
|
|
||||||
extern NSString *const SDWebImageDownloadStartNotification;
|
extern NSString *const SDWebImageDownloadStartNotification;
|
||||||
extern NSString *const SDWebImageDownloadStopNotification;
|
extern NSString *const SDWebImageDownloadStopNotification;
|
||||||
|
@ -46,9 +52,9 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data,
|
||||||
@property (assign, nonatomic) NSInteger maxConcurrentDownloads;
|
@property (assign, nonatomic) NSInteger maxConcurrentDownloads;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes download operations unqueue mode. Default value is `SDWebImageDownloaderFILOQueueMode`.
|
* Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
|
||||||
*/
|
*/
|
||||||
@property (assign, nonatomic) SDWebImageDownloaderQueueMode queueMode;
|
@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder;
|
||||||
|
|
||||||
+ (SDWebImageDownloader *)sharedDownloader;
|
+ (SDWebImageDownloader *)sharedDownloader;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
_queueMode = SDWebImageDownloaderFILOQueueMode;
|
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
|
||||||
_downloadQueue = NSOperationQueue.new;
|
_downloadQueue = NSOperationQueue.new;
|
||||||
_downloadQueue.maxConcurrentOperationCount = 2;
|
_downloadQueue.maxConcurrentOperationCount = 2;
|
||||||
_URLCallbacks = NSMutableDictionary.new;
|
_URLCallbacks = NSMutableDictionary.new;
|
||||||
|
@ -158,9 +158,9 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
||||||
[sself removeCallbacksForURL:url];
|
[sself removeCallbacksForURL:url];
|
||||||
}];
|
}];
|
||||||
[wself.downloadQueue addOperation:operation];
|
[wself.downloadQueue addOperation:operation];
|
||||||
if (wself.queueMode == SDWebImageDownloaderLIFOQueueMode)
|
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder)
|
||||||
{
|
{
|
||||||
// Emulate LIFO queue mode by systematically adding new operations as last operation's dependency
|
// Emulate LIFO execution order by systematically adding new operations as last operation's dependency
|
||||||
[wself.lastAddedOperation addDependency:operation];
|
[wself.lastAddedOperation addDependency:operation];
|
||||||
wself.lastAddedOperation = operation;
|
wself.lastAddedOperation = operation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue