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)
|
||||
{
|
||||
__block UIActivityIndicatorView *activityIndicator;
|
||||
__weak UIImageView *weakImageView = self.imageView;
|
||||
[self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
|
||||
{
|
||||
if (!activityIndicator)
|
||||
{
|
||||
[self.imageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
|
||||
activityIndicator.center = self.imageView.center;
|
||||
[weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
|
||||
activityIndicator.center = weakImageView.center;
|
||||
[activityIndicator startAnimating];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@
|
|||
nil];
|
||||
}
|
||||
[SDWebImageManager.sharedManager.imageDownloader setValue:@"SDWebImage Demo" forHTTPHeaderField:@"AppName"];
|
||||
SDWebImageManager.sharedManager.imageDownloader.queueMode = SDWebImageDownloaderLIFOQueueMode;
|
||||
SDWebImageManager.sharedManager.imageDownloader.executionOrder = SDWebImageDownloaderLIFOExecutionOrder;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ enum SDImageCacheType
|
|||
*/
|
||||
SDImageCacheTypeDisk,
|
||||
/**
|
||||
* The image was obtained from the disk cache.
|
||||
* The image was obtained from the memory cache.
|
||||
*/
|
||||
SDImageCacheTypeMemory
|
||||
};
|
||||
|
|
|
@ -28,9 +28,15 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SDWebImageDownloaderFILOQueueMode,
|
||||
SDWebImageDownloaderLIFOQueueMode
|
||||
} SDWebImageDownloaderQueueMode;
|
||||
SDWebImageDownloaderFIFOExecutionOrder,
|
||||
/**
|
||||
* 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 SDWebImageDownloadStopNotification;
|
||||
|
@ -46,9 +52,9 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data,
|
|||
@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;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
_queueMode = SDWebImageDownloaderFILOQueueMode;
|
||||
_executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
|
||||
_downloadQueue = NSOperationQueue.new;
|
||||
_downloadQueue.maxConcurrentOperationCount = 2;
|
||||
_URLCallbacks = NSMutableDictionary.new;
|
||||
|
@ -158,9 +158,9 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
[sself removeCallbacksForURL:url];
|
||||
}];
|
||||
[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 = operation;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue