Update and remove the deprecated method. Add some documents for un-documented methods

This commit is contained in:
DreamPiggy 2018-01-16 00:15:15 +08:00
parent 6f6f54e6c5
commit 9e48da8a8a
6 changed files with 40 additions and 38 deletions

View File

@ -10,8 +10,20 @@
@interface UIImage (ForceDecode)
/**
Decompress (force decode before rendering) the provided image
@param image The image to be decompressed
@return The decompressed image
*/
+ (nullable UIImage *)sd_decodedImageWithImage:(nullable UIImage *)image;
/**
Decompress and scale down the provided image
@param image The image to be decompressed
@return The decompressed and scaled down image
*/
+ (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image;
@end

View File

@ -11,8 +11,27 @@
@interface UIImage (MultiFormat)
/**
Create and decode a image with the specify image data
@param data The image data
@return The created image
*/
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data;
/**
Encode the current image to the data, the image format is unspecified
@return The encoded data. If can't encode, return nil
*/
- (nullable NSData *)sd_imageData;
/**
Encode the current image to data with the specify image format
@param imageFormat The specify image format
@return The encoded data. If can't encode, return nil
*/
- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat;
@end

View File

@ -154,31 +154,6 @@
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock;
/**
* Set the imageView `image` with an `url` and custom options. The placeholder image is from previous cached image and will use the provided one instead if the query failed.
* This method was designed to ensure that placeholder and query cache process happened in the same runloop to avoid flashing on cell during two `setImage:` call. But it's really misunderstanding and deprecated.
* This can be done by using `sd_setImageWithURL:` with `SDWebImageQueryDiskSync`. But take care that if the memory cache missed, query disk cache synchronously may reduce the frame rate
*
* The download is asynchronous and cached.
*
* @param url The url for the image.
* @param placeholder The image to be set initially, until the image request finishes.
* @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
* @param progressBlock A block called while image is downloading
* @note the progress block is executed on a background queue
* @param completedBlock A block called when operation has been completed. This block has no return value
* and takes the requested UIImage as first parameter. In case of error the image parameter
* is nil and the second parameter may contain an NSError. The third parameter is a Boolean
* indicating if the image was retrieved from the local cache or from the network.
* The fourth parameter is the original image url.
* @deprecated consider using `SDWebImageQueryDiskSync` options with `sd_setImageWithURL:` instead
*/
- (void)sd_setImageWithPreviousCachedImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock __deprecated_msg("This method is misunderstanding and deprecated, consider using `SDWebImageQueryDiskSync` options with `sd_setImageWithURL:` instead");
#if SD_UIKIT
#pragma mark - Animation of multiple images
@ -190,6 +165,9 @@
*/
- (void)sd_setAnimationImagesWithURLs:(nonnull NSArray<NSURL *> *)arrayOfURLs;
/**
* Cancel the current animation images load
*/
- (void)sd_cancelCurrentAnimationImagesLoad;
#endif

View File

@ -54,17 +54,6 @@
completed:completedBlock];
}
- (void)sd_setImageWithPreviousCachedImageWithURL:(nullable NSURL *)url
placeholderImage:(nullable UIImage *)placeholder
options:(SDWebImageOptions)options
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock {
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url];
UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromCacheForKey:key];
[self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock];
}
#if SD_UIKIT
#pragma mark - Animation of multiple images

View File

@ -34,7 +34,7 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima
*
* @note Note that because of the limitations of categories this property can get out of sync if you use setImage: directly.
*/
- (nullable NSURL *)sd_imageURL;
@property (nonatomic, strong, readonly, nullable) NSURL *sd_imageURL;
/**
* The current image loading progress associated to the view. The unit count is the received size and excepted size of download.

View File

@ -32,6 +32,10 @@ static char TAG_ACTIVITY_SHOW;
return objc_getAssociatedObject(self, &imageURLKey);
}
- (void)setSd_imageURL:(NSURL * _Nullable)sd_imageURL {
objc_setAssociatedObject(self, &imageURLKey, sd_imageURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (NSProgress *)sd_imageProgress {
NSProgress *progress = objc_getAssociatedObject(self, @selector(sd_imageProgress));
if (!progress) {
@ -65,7 +69,7 @@ static char TAG_ACTIVITY_SHOW;
context:(nullable NSDictionary *)context {
NSString *validOperationKey = operationKey ?: NSStringFromClass([self class]);
[self sd_cancelImageLoadOperationWithKey:validOperationKey];
objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
self.sd_imageURL = url;
if (!(options & SDWebImageDelayPlaceholder)) {
if ([context valueForKey:SDWebImageInternalSetImageGroupKey]) {