Renamed SDWebImageManager `downloadImageWithURL:options:progress:completed:` to `loadImageWithURL:options:progress:completed:` as it makes more sense, since we check the cache first and download only if needed
Conflicts: SDWebImage/UIImageView+WebCache.m
This commit is contained in:
parent
0384a059c4
commit
a32a1775c2
20
README.md
20
README.md
|
@ -95,16 +95,16 @@ Here is a simple example of how to use SDWebImageManager:
|
|||
|
||||
```objective-c
|
||||
SDWebImageManager *manager = [SDWebImageManager sharedManager];
|
||||
[manager downloadImageWithURL:imageURL
|
||||
options:0
|
||||
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
|
||||
// progression tracking code
|
||||
}
|
||||
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (image) {
|
||||
// do something with image
|
||||
}
|
||||
}];
|
||||
[manager loadImageWithURL:imageURL
|
||||
options:0
|
||||
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
|
||||
// progression tracking code
|
||||
}
|
||||
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (image) {
|
||||
// do something with image
|
||||
}
|
||||
}];
|
||||
```
|
||||
|
||||
### Using Asynchronous Image Downloader Independently
|
||||
|
|
|
@ -46,7 +46,7 @@ static char imageURLKey;
|
|||
|
||||
if (url) {
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
__strong MKAnnotationView *sself = wself;
|
||||
|
|
|
@ -138,14 +138,14 @@ typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url);
|
|||
* @code
|
||||
|
||||
SDWebImageManager *manager = [SDWebImageManager sharedManager];
|
||||
[manager downloadImageWithURL:imageURL
|
||||
options:0
|
||||
progress:nil
|
||||
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (image) {
|
||||
// do something with image
|
||||
}
|
||||
}];
|
||||
[manager loadImageWithURL:imageURL
|
||||
options:0
|
||||
progress:nil
|
||||
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (image) {
|
||||
// do something with image
|
||||
}
|
||||
}];
|
||||
|
||||
* @endcode
|
||||
*/
|
||||
|
@ -203,10 +203,10 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
|
|||
*
|
||||
* @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation
|
||||
*/
|
||||
- (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url
|
||||
options:(SDWebImageOptions)options
|
||||
progress:(SDWebImageDownloaderProgressBlock)progressBlock
|
||||
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock;
|
||||
- (id <SDWebImageOperation>)loadImageWithURL:(NSURL *)url
|
||||
options:(SDWebImageOptions)options
|
||||
progress:(SDWebImageDownloaderProgressBlock)progressBlock
|
||||
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock;
|
||||
|
||||
/**
|
||||
* Saves image to cache for given URL
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
}];
|
||||
}
|
||||
|
||||
- (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url
|
||||
- (id <SDWebImageOperation>)loadImageWithURL:(NSURL *)url
|
||||
options:(SDWebImageOptions)options
|
||||
progress:(SDWebImageDownloaderProgressBlock)progressBlock
|
||||
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock {
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
- (void)startPrefetchingAtIndex:(NSUInteger)index {
|
||||
if (index >= self.prefetchURLs.count) return;
|
||||
self.requestedCount++;
|
||||
[self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
[self.manager loadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!finished) return;
|
||||
self.finishedCount++;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ static char imageURLStorageKey;
|
|||
self.imageURLStorage[@(state)] = url;
|
||||
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
__strong UIButton *sself = wself;
|
||||
|
@ -117,7 +117,7 @@ static char imageURLStorageKey;
|
|||
|
||||
if (url) {
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
__strong UIButton *sself = wself;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
if (url) {
|
||||
__weak __typeof(self)wself = self;
|
||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe (^
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ static char TAG_ACTIVITY_SHOW;
|
|||
}
|
||||
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
[wself removeActivityIndicator];
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
|
@ -113,7 +113,7 @@ static char TAG_ACTIVITY_SHOW;
|
|||
NSMutableArray *operationsArray = [[NSMutableArray alloc] init];
|
||||
|
||||
for (NSURL *logoImageURL in arrayOfURLs) {
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager loadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
__strong UIImageView *sself = wself;
|
||||
|
|
|
@ -40,7 +40,7 @@ static int64_t kAsyncTestTimeout = 5;
|
|||
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://www.google.gr/images/srpr/logo11w.png"];
|
||||
|
||||
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
[[SDWebImageManager sharedManager] loadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
expect(image).toNot.beNil();
|
||||
expect(error).to.beNil();
|
||||
expect(originalImageURL).to.equal(imageURL);
|
||||
|
@ -57,7 +57,7 @@ static int64_t kAsyncTestTimeout = 5;
|
|||
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"];
|
||||
|
||||
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
[[SDWebImageManager sharedManager] loadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
expect(image).to.beNil();
|
||||
expect(error).toNot.beNil();
|
||||
expect(originalImageURL).to.equal(imageURL);
|
||||
|
|
Loading…
Reference in New Issue