mirror of
https://github.com/zhigang1992/PINRemoteImage.git
synced 2026-01-12 22:49:34 +08:00
Merge pull request #183 from Adlai-Holler/PrefetchingReturnsTasks
Make Prefetching Methods Return Tasks
This commit is contained in:
@@ -258,7 +258,7 @@ typedef void(^PINRemoteImageManagerProgressDownload)(int64_t completedBytes, int
|
||||
|
||||
@param url NSURL where the image to prefetch resides.
|
||||
*/
|
||||
- (void)prefetchImageWithURL:(nonnull NSURL *)url;
|
||||
- (nullable NSUUID *)prefetchImageWithURL:(nonnull NSURL *)url;
|
||||
|
||||
/**
|
||||
Prefetch an image at the given URL with given options.
|
||||
@@ -266,14 +266,14 @@ typedef void(^PINRemoteImageManagerProgressDownload)(int64_t completedBytes, int
|
||||
@param url NSURL where the image to prefetch resides.
|
||||
@param options PINRemoteImageManagerDownloadOptions options with which to pefetch the image.
|
||||
*/
|
||||
- (void)prefetchImageWithURL:(nonnull NSURL *)url options:(PINRemoteImageManagerDownloadOptions)options;
|
||||
- (nullable NSUUID *)prefetchImageWithURL:(nonnull NSURL *)url options:(PINRemoteImageManagerDownloadOptions)options;
|
||||
|
||||
/**
|
||||
Prefetch images at the given URLs.
|
||||
|
||||
@param urls An array of NSURLs where the images to prefetch reside.
|
||||
*/
|
||||
- (void)prefetchImagesWithURLs:(nonnull NSArray <NSURL *> *)urls;
|
||||
- (nonnull NSArray<NSUUID *> *)prefetchImagesWithURLs:(nonnull NSArray <NSURL *> *)urls;
|
||||
|
||||
/**
|
||||
Prefetch images at the given URLs with given options.
|
||||
@@ -281,7 +281,7 @@ typedef void(^PINRemoteImageManagerProgressDownload)(int64_t completedBytes, int
|
||||
@param urls An array of NSURLs where the images to prefetch reside.
|
||||
@param options PINRemoteImageManagerDownloadOptions options with which to pefetch the image.
|
||||
*/
|
||||
- (void)prefetchImagesWithURLs:(nonnull NSArray <NSURL *> *)urls options:(PINRemoteImageManagerDownloadOptions)options;;
|
||||
- (nonnull NSArray<NSUUID *> *)prefetchImagesWithURLs:(nonnull NSArray <NSURL *> *)urls options:(PINRemoteImageManagerDownloadOptions)options;
|
||||
|
||||
/**
|
||||
Download or retrieve from cache the image found at the url. All completions are called on an arbitrary callback queue unless called on the main thread and the result is in the memory cache (this is an optimization to allow synchronous results for the UI when an object is cached in memory).
|
||||
|
||||
@@ -841,26 +841,31 @@ static dispatch_once_t sharedDispatchToken;
|
||||
|
||||
#pragma mark - Prefetching
|
||||
|
||||
- (void)prefetchImagesWithURLs:(NSArray <NSURL *> *)urls
|
||||
- (NSArray<NSUUID *> *)prefetchImagesWithURLs:(NSArray <NSURL *> *)urls
|
||||
{
|
||||
[self prefetchImagesWithURLs:urls options:PINRemoteImageManagerDownloadOptionsNone | PINRemoteImageManagerDownloadOptionsSkipEarlyCheck];
|
||||
}
|
||||
|
||||
- (void)prefetchImagesWithURLs:(NSArray <NSURL *> *)urls options:(PINRemoteImageManagerDownloadOptions)options
|
||||
- (NSArray<NSUUID *> *)prefetchImagesWithURLs:(NSArray <NSURL *> *)urls options:(PINRemoteImageManagerDownloadOptions)options
|
||||
{
|
||||
NSMutableArray *tasks = [NSMutableArray arrayWithCapacity:urls.count];
|
||||
for (NSURL *url in urls) {
|
||||
[self prefetchImageWithURL:url options:options];
|
||||
NSUUID *task = [self prefetchImageWithURL:url options:options];
|
||||
if (task != nil) {
|
||||
[tasks addObject:task];
|
||||
}
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
|
||||
- (void)prefetchImageWithURL:(NSURL *)url
|
||||
- (NSUUID *)prefetchImageWithURL:(NSURL *)url
|
||||
{
|
||||
[self prefetchImageWithURL:url options:PINRemoteImageManagerDownloadOptionsNone | PINRemoteImageManagerDownloadOptionsSkipEarlyCheck];
|
||||
return [self prefetchImageWithURL:url options:PINRemoteImageManagerDownloadOptionsNone | PINRemoteImageManagerDownloadOptionsSkipEarlyCheck];
|
||||
}
|
||||
|
||||
- (void)prefetchImageWithURL:(NSURL *)url options:(PINRemoteImageManagerDownloadOptions)options
|
||||
- (NSUUID *)prefetchImageWithURL:(NSURL *)url options:(PINRemoteImageManagerDownloadOptions)options
|
||||
{
|
||||
[self downloadImageWithURL:url
|
||||
return [self downloadImageWithURL:url
|
||||
options:options
|
||||
priority:PINRemoteImageManagerPriorityVeryLow
|
||||
processorKey:nil
|
||||
|
||||
Reference in New Issue
Block a user