mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Rename image request class, add deliveryMode into the request params
This commit is contained in:
@@ -374,10 +374,10 @@
|
||||
B350625D1B0111740018CF92 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943141A1575670030A7D0 /* Photos.framework */; };
|
||||
B350625E1B0111780018CF92 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943121A1575630030A7D0 /* AssetsLibrary.framework */; };
|
||||
B350625F1B0111800018CF92 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 058D09AF195D04C000B7D73C /* Foundation.framework */; };
|
||||
CC7FD9DE1BB5E962005CCB2B /* ASPhotosImageRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = CC7FD9DC1BB5E962005CCB2B /* ASPhotosImageRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
CC7FD9DF1BB5E962005CCB2B /* ASPhotosImageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = CC7FD9DD1BB5E962005CCB2B /* ASPhotosImageRequest.m */; settings = {ASSET_TAGS = (); }; };
|
||||
CC7FD9E11BB5F750005CCB2B /* ASPhotosImageRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC7FD9E01BB5F750005CCB2B /* ASPhotosImageRequestTests.m */; settings = {ASSET_TAGS = (); }; };
|
||||
CC7FD9E21BB603FF005CCB2B /* ASPhotosImageRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = CC7FD9DC1BB5E962005CCB2B /* ASPhotosImageRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
CC7FD9DE1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = CC7FD9DC1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
CC7FD9DF1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = CC7FD9DD1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m */; settings = {ASSET_TAGS = (); }; };
|
||||
CC7FD9E11BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC7FD9E01BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m */; settings = {ASSET_TAGS = (); }; };
|
||||
CC7FD9E21BB603FF005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = CC7FD9DC1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D785F6621A74327E00291744 /* ASScrollNode.h in Headers */ = {isa = PBXBuildFile; fileRef = D785F6601A74327E00291744 /* ASScrollNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D785F6631A74327E00291744 /* ASScrollNode.m in Sources */ = {isa = PBXBuildFile; fileRef = D785F6611A74327E00291744 /* ASScrollNode.m */; };
|
||||
DB7121BCD50849C498C886FB /* libPods-AsyncDisplayKitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EFA731F0396842FF8AB635EE /* libPods-AsyncDisplayKitTests.a */; };
|
||||
@@ -623,9 +623,9 @@
|
||||
ACF6ED5B1B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASStackLayoutSpecSnapshotTests.mm; sourceTree = "<group>"; };
|
||||
B35061DA1B010EDF0018CF92 /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AsyncDisplayKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B35061DD1B010EDF0018CF92 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "../AsyncDisplayKit-iOS/Info.plist"; sourceTree = "<group>"; };
|
||||
CC7FD9DC1BB5E962005CCB2B /* ASPhotosImageRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASPhotosImageRequest.h; sourceTree = "<group>"; };
|
||||
CC7FD9DD1BB5E962005CCB2B /* ASPhotosImageRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPhotosImageRequest.m; sourceTree = "<group>"; };
|
||||
CC7FD9E01BB5F750005CCB2B /* ASPhotosImageRequestTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPhotosImageRequestTests.m; sourceTree = "<group>"; };
|
||||
CC7FD9DC1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASPhotosFrameworkImageRequest.h; sourceTree = "<group>"; };
|
||||
CC7FD9DD1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPhotosFrameworkImageRequest.m; sourceTree = "<group>"; };
|
||||
CC7FD9E01BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPhotosFrameworkImageRequestTests.m; sourceTree = "<group>"; };
|
||||
D3779BCFF841AD3EB56537ED /* Pods-AsyncDisplayKitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AsyncDisplayKitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D785F6601A74327E00291744 /* ASScrollNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASScrollNode.h; sourceTree = "<group>"; };
|
||||
D785F6611A74327E00291744 /* ASScrollNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASScrollNode.m; sourceTree = "<group>"; };
|
||||
@@ -808,7 +808,7 @@
|
||||
ACF6ED581B178DC700DA7C62 /* ASLayoutSpecSnapshotTestsHelper.m */,
|
||||
242995D21B29743C00090100 /* ASBasicImageDownloaderTests.m */,
|
||||
29CDC2E11AAE70D000833CA4 /* ASBasicImageDownloaderContextTests.m */,
|
||||
CC7FD9E01BB5F750005CCB2B /* ASPhotosImageRequestTests.m */,
|
||||
CC7FD9E01BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m */,
|
||||
296A0A341A951ABF005ACEAA /* ASBatchFetchingTests.m */,
|
||||
9F06E5CC1B4CAF4200F015D8 /* ASCollectionViewTests.m */,
|
||||
2911485B1A77147A005D0878 /* ASControlNodeTests.m */,
|
||||
@@ -844,8 +844,8 @@
|
||||
058D09E1195D050800B7D73C /* Details */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CC7FD9DC1BB5E962005CCB2B /* ASPhotosImageRequest.h */,
|
||||
CC7FD9DD1BB5E962005CCB2B /* ASPhotosImageRequest.m */,
|
||||
CC7FD9DC1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h */,
|
||||
CC7FD9DD1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m */,
|
||||
058D09E2195D050800B7D73C /* _ASDisplayLayer.h */,
|
||||
058D09E3195D050800B7D73C /* _ASDisplayLayer.mm */,
|
||||
058D09E4195D050800B7D73C /* _ASDisplayView.h */,
|
||||
@@ -1116,7 +1116,7 @@
|
||||
9C8221951BA237B80037F19A /* ASStackBaselinePositionedLayout.h in Headers */,
|
||||
9C49C36F1B853957000B0DD5 /* ASStackLayoutable.h in Headers */,
|
||||
AC21EC101B3D0BF600C8B19A /* ASStackLayoutDefines.h in Headers */,
|
||||
CC7FD9DE1BB5E962005CCB2B /* ASPhotosImageRequest.h in Headers */,
|
||||
CC7FD9DE1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */,
|
||||
ACF6ED2F1B17843500DA7C62 /* ASStackLayoutSpec.h in Headers */,
|
||||
ACF6ED4E1B17847A00DA7C62 /* ASStackLayoutSpecUtilities.h in Headers */,
|
||||
ACF6ED4F1B17847A00DA7C62 /* ASStackPositionedLayout.h in Headers */,
|
||||
@@ -1219,7 +1219,7 @@
|
||||
9C8221961BA237B80037F19A /* ASStackBaselinePositionedLayout.h in Headers */,
|
||||
9C49C3701B853961000B0DD5 /* ASStackLayoutable.h in Headers */,
|
||||
34EFC7701B701CFA00AD841F /* ASStackLayoutDefines.h in Headers */,
|
||||
CC7FD9E21BB603FF005CCB2B /* ASPhotosImageRequest.h in Headers */,
|
||||
CC7FD9E21BB603FF005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */,
|
||||
34EFC7711B701CFF00AD841F /* ASStackLayoutSpec.h in Headers */,
|
||||
2767E9411BB19BD600EA9B77 /* ASViewController.h in Headers */,
|
||||
044284FE1BAA387800D16268 /* ASStackLayoutSpecUtilities.h in Headers */,
|
||||
@@ -1505,7 +1505,7 @@
|
||||
058D0A21195D050800B7D73C /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
|
||||
205F0E101B371875007741D0 /* UICollectionViewLayout+ASConvenience.m in Sources */,
|
||||
058D0A25195D050800B7D73C /* UIView+ASConvenience.m in Sources */,
|
||||
CC7FD9DF1BB5E962005CCB2B /* ASPhotosImageRequest.m in Sources */,
|
||||
CC7FD9DF1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1527,7 +1527,7 @@
|
||||
056D21551ABCEF50001107EF /* ASImageNodeSnapshotTests.m in Sources */,
|
||||
ACF6ED5E1B178DC700DA7C62 /* ASInsetLayoutSpecSnapshotTests.mm in Sources */,
|
||||
ACF6ED601B178DC700DA7C62 /* ASLayoutSpecSnapshotTestsHelper.m in Sources */,
|
||||
CC7FD9E11BB5F750005CCB2B /* ASPhotosImageRequestTests.m in Sources */,
|
||||
CC7FD9E11BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m in Sources */,
|
||||
052EE0661A159FEF002C6279 /* ASMultiplexImageNodeTests.m in Sources */,
|
||||
058D0A3C195D057000B7D73C /* ASMutableAttributedStringBuilderTests.m in Sources */,
|
||||
ACF6ED611B178DC700DA7C62 /* ASOverlayLayoutSpecSnapshotTests.mm in Sources */,
|
||||
|
||||
@@ -195,7 +195,7 @@ didFinishDownloadingImageWithIdentifier:(id)imageIdentifier
|
||||
* @abstract An image URL for the specified identifier.
|
||||
* @param imageNode The sender.
|
||||
* @param imageIdentifier The identifier for the image that will be downloaded.
|
||||
* @discussion Supported URLs include assets-library, URLs converted from ASPhotosImageRequest, HTTP, HTTPS, and FTP URLs. If the
|
||||
* @discussion Supported URLs include assets-library, URLs converted from ASPhotosFrameworkImageRequest, HTTP, HTTPS, and FTP URLs. If the
|
||||
* image is already available to the data source, it should be provided via <[ASMultiplexImageNodeDataSource
|
||||
* multiplexImageNode:imageForImageIdentifier:]> instead.
|
||||
* @returns An NSURL for the image identified by `imageIdentifier`, or nil if none is available.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#import "ASBaseDefines.h"
|
||||
#import "ASDisplayNode+Subclasses.h"
|
||||
#import "ASLog.h"
|
||||
#import "ASPhotosImageRequest.h"
|
||||
#import "ASPhotosFrameworkImageRequest.h"
|
||||
|
||||
#if !AS_IOS8_SDK_OR_LATER
|
||||
#error ASMultiplexImageNode can be used on iOS 7, but must be linked against the iOS 8 SDK.
|
||||
@@ -126,7 +126,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
@param image The image that was loaded. May be nil if no image could be downloaded.
|
||||
@param error An error describing why the load failed, if it failed; nil otherwise.
|
||||
*/
|
||||
- (void)_loadPHAssetWithRequest:(ASPhotosImageRequest *)request identifier:(id)imageIdentifier completion:(void (^)(UIImage *image, NSError *error))completionBlock;
|
||||
- (void)_loadPHAssetWithRequest:(ASPhotosFrameworkImageRequest *)request identifier:(id)imageIdentifier completion:(void (^)(UIImage *image, NSError *error))completionBlock;
|
||||
|
||||
/**
|
||||
@abstract Downloads the image corresponding to the given imageIdentifier from the given URL.
|
||||
@@ -455,7 +455,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
}];
|
||||
}
|
||||
// Likewise, if it's a iOS 8 Photo asset, we need to fetch it accordingly.
|
||||
else if (ASPhotosImageRequest *request = nextImageURL.asyncdisplaykit_photosRequest) {
|
||||
else if (ASPhotosFrameworkImageRequest *request = nextImageURL.asyncdisplaykit_photosRequest) {
|
||||
[self _loadPHAssetWithRequest:request identifier:nextImageIdentifier completion:^(UIImage *image, NSError *error) {
|
||||
ASMultiplexImageNodeCLogDebug(@"[%p] Acquired next image (%@) from Photos Framework", weakSelf, nextImageIdentifier);
|
||||
finishedLoadingBlock(image, nextImageIdentifier, error);
|
||||
@@ -510,7 +510,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)_loadPHAssetWithRequest:(ASPhotosImageRequest *)request identifier:(id)imageIdentifier completion:(void (^)(UIImage *image, NSError *error))completionBlock
|
||||
- (void)_loadPHAssetWithRequest:(ASPhotosFrameworkImageRequest *)request identifier:(id)imageIdentifier completion:(void (^)(UIImage *image, NSError *error))completionBlock
|
||||
{
|
||||
ASDisplayNodeAssert(AS_AT_LEAST_IOS8, @"PhotosKit is unavailable on iOS 7.");
|
||||
ASDisplayNodeAssertNotNil(imageIdentifier, @"imageIdentifier is required");
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#import <AsyncDisplayKit/ASBasicImageDownloader.h>
|
||||
#import <AsyncDisplayKit/ASMultiplexImageNode.h>
|
||||
#import <AsyncDisplayKit/ASNetworkImageNode.h>
|
||||
#import <AsyncDisplayKit/ASPhotosImageRequest.h>
|
||||
#import <AsyncDisplayKit/ASPhotosFrameworkImageRequest.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASTableView.h>
|
||||
#import <AsyncDisplayKit/ASCollectionView.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// ASPhotosImageRequest.h
|
||||
// ASPhotosFrameworkImageRequest.h
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Adlai Holler on 9/25/15.
|
||||
@@ -14,17 +14,17 @@
|
||||
extern NSString *const ASPhotosURLScheme;
|
||||
|
||||
/**
|
||||
@abstract Use ASPhotosImageRequest to encapsulate all the information needed to request an image from
|
||||
@abstract Use ASPhotosFrameworkImageRequest to encapsulate all the information needed to request an image from
|
||||
the Photos framework and store it in a URL.
|
||||
*/
|
||||
@interface ASPhotosImageRequest : NSObject <NSCopying>
|
||||
@interface ASPhotosFrameworkImageRequest : NSObject <NSCopying>
|
||||
|
||||
- (instancetype)initWithAssetIdentifier:(NSString *)assetIdentifier NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
@return A new image request deserialized from `url`, or nil if `url` is not a valid photos URL.
|
||||
*/
|
||||
+ (/*nullable*/ ASPhotosImageRequest *)requestWithURL:(NSURL *)url;
|
||||
+ (/*nullable*/ ASPhotosFrameworkImageRequest *)requestWithURL:(NSURL *)url;
|
||||
|
||||
/**
|
||||
@abstract The asset identifier for this image request provided during initialization.
|
||||
@@ -47,7 +47,9 @@ extern NSString *const ASPhotosURLScheme;
|
||||
@abstract The options specified for this request. Default value is the result of `[PHImageRequestOptions new]`.
|
||||
|
||||
@discussion Some properties of this object are ignored when converting this request into a URL.
|
||||
As of iOS SDK 9.0, these properties are `progressHandler`, `synchronous`, and `deliveryMode`.
|
||||
As of iOS SDK 9.0, these properties are `progressHandler` and `synchronous`.
|
||||
Note that PHImageRequestOptionsDeliveryModeOpportunistic is not recommended when using ASMultiplexImageNode,
|
||||
because it sends multiple images and only the first will be accepted.
|
||||
*/
|
||||
@property (nonatomic, strong) PHImageRequestOptions *options;
|
||||
|
||||
@@ -66,9 +68,9 @@ extern NSString *const ASPhotosURLScheme;
|
||||
@interface NSURL (ASPhotosRequestConverting)
|
||||
|
||||
/**
|
||||
@abstract A convenience function that calls `[ASPhotosImageRequest requestWithURL:self]`.
|
||||
@abstract A convenience function that calls `[ASPhotosFrameworkImageRequest requestWithURL:self]`.
|
||||
*/
|
||||
- (/*nullable*/ ASPhotosImageRequest *)asyncdisplaykit_photosRequest;
|
||||
- (/*nullable*/ ASPhotosFrameworkImageRequest *)asyncdisplaykit_photosRequest;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//
|
||||
// ASPhotosImageRequest.m
|
||||
// ASPhotosFrameworkImageRequest.m
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Adlai Holler on 9/25/15.
|
||||
// Copyright © 2015 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ASPhotosImageRequest.h"
|
||||
#import "ASPhotosFrameworkImageRequest.h"
|
||||
#import "ASBaseDefines.h"
|
||||
|
||||
NSString *const ASPhotosURLScheme = @"ph";
|
||||
@@ -20,6 +20,9 @@ static NSString *const _ASPhotosURLQueryKeyContentMode = @"contentmode";
|
||||
// value is PHImageRequestOptionsResizeMode value
|
||||
static NSString *const _ASPhotosURLQueryKeyResizeMode = @"resizemode";
|
||||
|
||||
// value is PHImageRequestOptionsDeliveryMode value
|
||||
static NSString *const _ASPhotosURLQueryKeyDeliveryMode = @"deliverymode";
|
||||
|
||||
// value is PHImageRequestOptionsVersion value
|
||||
static NSString *const _ASPhotosURLQueryKeyVersion = @"version";
|
||||
|
||||
@@ -31,7 +34,7 @@ static NSString *const _ASPhotosURLQueryKeyCropOriginY = @"crop_y";
|
||||
static NSString *const _ASPhotosURLQueryKeyCropWidth = @"crop_w";
|
||||
static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
|
||||
@implementation ASPhotosImageRequest
|
||||
@implementation ASPhotosFrameworkImageRequest
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
@@ -56,7 +59,7 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
ASPhotosImageRequest *copy = [[ASPhotosImageRequest alloc] initWithAssetIdentifier:self.assetIdentifier];
|
||||
ASPhotosFrameworkImageRequest *copy = [[ASPhotosFrameworkImageRequest alloc] initWithAssetIdentifier:self.assetIdentifier];
|
||||
copy.options = [self.options copy];
|
||||
copy.targetSize = self.targetSize;
|
||||
copy.contentMode = self.contentMode;
|
||||
@@ -76,7 +79,8 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
[NSURLQueryItem queryItemWithName:_ASPhotosURLQueryKeyVersion value:@(_options.version).stringValue],
|
||||
[NSURLQueryItem queryItemWithName:_ASPhotosURLQueryKeyContentMode value:@(_contentMode).stringValue],
|
||||
[NSURLQueryItem queryItemWithName:_ASPhotosURLQueryKeyAllowNetworkAccess value:@(_options.networkAccessAllowed).stringValue],
|
||||
[NSURLQueryItem queryItemWithName:_ASPhotosURLQueryKeyResizeMode value:@(_options.resizeMode).stringValue]
|
||||
[NSURLQueryItem queryItemWithName:_ASPhotosURLQueryKeyResizeMode value:@(_options.resizeMode).stringValue],
|
||||
[NSURLQueryItem queryItemWithName:_ASPhotosURLQueryKeyDeliveryMode value:@(_options.deliveryMode).stringValue]
|
||||
, nil];
|
||||
|
||||
CGRect cropRect = _options.normalizedCropRect;
|
||||
@@ -94,7 +98,7 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
|
||||
#pragma mark Converting from URL
|
||||
|
||||
+ (ASPhotosImageRequest *)requestWithURL:(NSURL *)url
|
||||
+ (ASPhotosFrameworkImageRequest *)requestWithURL:(NSURL *)url
|
||||
{
|
||||
// not a photos URL
|
||||
if (![url.scheme isEqualToString:ASPhotosURLScheme]) {
|
||||
@@ -103,7 +107,7 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
|
||||
NSURLComponents *comp = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
|
||||
|
||||
ASPhotosImageRequest *request = [[ASPhotosImageRequest alloc] initWithAssetIdentifier:url.host];
|
||||
ASPhotosFrameworkImageRequest *request = [[ASPhotosFrameworkImageRequest alloc] initWithAssetIdentifier:url.host];
|
||||
|
||||
CGRect cropRect = CGRectZero;
|
||||
CGSize targetSize = PHImageManagerMaximumSize;
|
||||
@@ -128,6 +132,8 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
cropRect.size.height = item.value.doubleValue;
|
||||
} else if ([_ASPhotosURLQueryKeyResizeMode isEqualToString:item.name]) {
|
||||
request.options.resizeMode = (PHImageRequestOptionsResizeMode)item.value.integerValue;
|
||||
} else if ([_ASPhotosURLQueryKeyDeliveryMode isEqualToString:item.name]) {
|
||||
request.options.deliveryMode = (PHImageRequestOptionsDeliveryMode)item.value.integerValue;
|
||||
}
|
||||
}
|
||||
request.targetSize = targetSize;
|
||||
@@ -139,10 +145,10 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
|
||||
- (BOOL)isEqual:(id)object
|
||||
{
|
||||
if (![object isKindOfClass:ASPhotosImageRequest.class]) {
|
||||
if (![object isKindOfClass:ASPhotosFrameworkImageRequest.class]) {
|
||||
return NO;
|
||||
}
|
||||
ASPhotosImageRequest *other = object;
|
||||
ASPhotosFrameworkImageRequest *other = object;
|
||||
return [other.assetIdentifier isEqualToString:self.assetIdentifier] &&
|
||||
other.contentMode == self.contentMode &&
|
||||
CGSizeEqualToSize(other.targetSize, self.targetSize) &&
|
||||
@@ -155,9 +161,9 @@ static NSString *const _ASPhotosURLQueryKeyCropHeight = @"crop_h";
|
||||
|
||||
@implementation NSURL (ASPhotosRequestConverting)
|
||||
|
||||
- (ASPhotosImageRequest *)asyncdisplaykit_photosRequest
|
||||
- (ASPhotosFrameworkImageRequest *)asyncdisplaykit_photosRequest
|
||||
{
|
||||
return [ASPhotosImageRequest requestWithURL:self];
|
||||
return [ASPhotosFrameworkImageRequest requestWithURL:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// ASPhotosImageRequestTests.m
|
||||
// ASPhotosFrameworkImageRequestTests.m
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Adlai Holler on 9/25/15.
|
||||
@@ -7,21 +7,21 @@
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "ASPhotosImageRequest.h"
|
||||
#import "ASPhotosFrameworkImageRequest.h"
|
||||
|
||||
static NSString *const kTestAssetID = @"testAssetID";
|
||||
|
||||
@interface ASPhotosImageRequestTests : XCTestCase
|
||||
@interface ASPhotosFrameworkImageRequestTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASPhotosImageRequestTests
|
||||
@implementation ASPhotosFrameworkImageRequestTests
|
||||
|
||||
#pragma mark Example Data
|
||||
|
||||
+ (ASPhotosImageRequest *)exampleImageRequest
|
||||
+ (ASPhotosFrameworkImageRequest *)exampleImageRequest
|
||||
{
|
||||
ASPhotosImageRequest *req = [[ASPhotosImageRequest alloc] initWithAssetIdentifier:kTestAssetID];
|
||||
ASPhotosFrameworkImageRequest *req = [[ASPhotosFrameworkImageRequest alloc] initWithAssetIdentifier:kTestAssetID];
|
||||
req.options.networkAccessAllowed = YES;
|
||||
req.options.normalizedCropRect = CGRectMake(0.2, 0.1, 0.6, 0.8);
|
||||
req.targetSize = CGSizeMake(1024, 1536);
|
||||
@@ -51,8 +51,8 @@ static NSString *const kTestAssetID = @"testAssetID";
|
||||
|
||||
- (void)testThatCopyingWorks
|
||||
{
|
||||
ASPhotosImageRequest *example = [self.class exampleImageRequest];
|
||||
ASPhotosImageRequest *copy = [[self.class exampleImageRequest] copy];
|
||||
ASPhotosFrameworkImageRequest *example = [self.class exampleImageRequest];
|
||||
ASPhotosFrameworkImageRequest *copy = [[self.class exampleImageRequest] copy];
|
||||
XCTAssertEqualObjects(example, copy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user