text stringlengths 9 39.2M | dir stringlengths 25 226 | lang stringclasses 163 values | created_date timestamp[s] | updated_date timestamp[s] | repo_name stringclasses 751 values | repo_full_name stringclasses 752 values | star int64 1.01k 183k | len_tokens int64 1 18.5M |
|---|---|---|---|---|---|---|---|---|
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "UIImage+Metadata.h"
#import "NSImage+Compatibility.h"
#import "SDInternalMacros.h"
#import "objc/runtime.h"
@implementation UIImage (Metadata)
#if SD_UIKIT || SD_WATCH
- (NSUInteger)sd_imageLoopCount {
NSUInteger imageLoopCount = 0;
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageLoopCount));
if ([value isKindOfClass:[NSNumber class]]) {
imageLoopCount = value.unsignedIntegerValue;
}
return imageLoopCount;
}
- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount {
NSNumber *value = @(sd_imageLoopCount);
objc_setAssociatedObject(self, @selector(sd_imageLoopCount), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (BOOL)sd_isAnimated {
return (self.images != nil);
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- (BOOL)sd_isVector {
if (@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)) {
// Xcode 11 supports symbol image, keep Xcode 10 compatible currently
SEL SymbolSelector = NSSelectorFromString(@"isSymbolImage");
if ([self respondsToSelector:SymbolSelector] && [self performSelector:SymbolSelector]) {
return YES;
}
// SVG
SEL SVGSelector = SD_SEL_SPI(CGSVGDocument);
if ([self respondsToSelector:SVGSelector] && [self performSelector:SVGSelector]) {
return YES;
}
}
if (@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
// PDF
SEL PDFSelector = SD_SEL_SPI(CGPDFPage);
if ([self respondsToSelector:PDFSelector] && [self performSelector:PDFSelector]) {
return YES;
}
}
return NO;
}
#pragma clang diagnostic pop
#else
- (NSUInteger)sd_imageLoopCount {
NSUInteger imageLoopCount = 0;
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
NSBitmapImageRep *bitmapImageRep;
if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) {
bitmapImageRep = (NSBitmapImageRep *)imageRep;
}
if (bitmapImageRep) {
imageLoopCount = [[bitmapImageRep valueForProperty:NSImageLoopCount] unsignedIntegerValue];
}
return imageLoopCount;
}
- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount {
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
NSBitmapImageRep *bitmapImageRep;
if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) {
bitmapImageRep = (NSBitmapImageRep *)imageRep;
}
if (bitmapImageRep) {
[bitmapImageRep setProperty:NSImageLoopCount withValue:@(sd_imageLoopCount)];
}
}
- (BOOL)sd_isAnimated {
BOOL isAnimated = NO;
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
NSBitmapImageRep *bitmapImageRep;
if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) {
bitmapImageRep = (NSBitmapImageRep *)imageRep;
}
if (bitmapImageRep) {
NSUInteger frameCount = [[bitmapImageRep valueForProperty:NSImageFrameCount] unsignedIntegerValue];
isAnimated = frameCount > 1 ? YES : NO;
}
return isAnimated;
}
- (BOOL)sd_isVector {
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
if ([imageRep isKindOfClass:[NSPDFImageRep class]]) {
return YES;
}
if ([imageRep isKindOfClass:[NSEPSImageRep class]]) {
return YES;
}
if ([NSStringFromClass(imageRep.class) hasSuffix:@"NSSVGImageRep"]) {
return YES;
}
return NO;
}
#endif
- (SDImageFormat)sd_imageFormat {
SDImageFormat imageFormat = SDImageFormatUndefined;
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageFormat));
if ([value isKindOfClass:[NSNumber class]]) {
imageFormat = value.integerValue;
return imageFormat;
}
// Check CGImage's UTType, may return nil for non-Image/IO based image
if (@available(iOS 9.0, tvOS 9.0, macOS 10.11, watchOS 2.0, *)) {
CFStringRef uttype = CGImageGetUTType(self.CGImage);
imageFormat = [NSData sd_imageFormatFromUTType:uttype];
}
return imageFormat;
}
- (void)setSd_imageFormat:(SDImageFormat)sd_imageFormat {
objc_setAssociatedObject(self, @selector(sd_imageFormat), @(sd_imageFormat), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)setSd_isIncremental:(BOOL)sd_isIncremental {
objc_setAssociatedObject(self, @selector(sd_isIncremental), @(sd_isIncremental), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (BOOL)sd_isIncremental {
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_isIncremental));
return value.boolValue;
}
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,304 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDWebImageCacheSerializer.h"
@interface SDWebImageCacheSerializer ()
@property (nonatomic, copy, nonnull) SDWebImageCacheSerializerBlock block;
@end
@implementation SDWebImageCacheSerializer
- (instancetype)initWithBlock:(SDWebImageCacheSerializerBlock)block {
self = [super init];
if (self) {
self.block = block;
}
return self;
}
+ (instancetype)cacheSerializerWithBlock:(SDWebImageCacheSerializerBlock)block {
SDWebImageCacheSerializer *cacheSerializer = [[SDWebImageCacheSerializer alloc] initWithBlock:block];
return cacheSerializer;
}
- (NSData *)cacheDataWithImage:(UIImage *)image originalData:(NSData *)data imageURL:(nullable NSURL *)imageURL {
if (!self.block) {
return nil;
}
return self.block(image, data, imageURL);
}
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 237 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDWebImageCompat.h"
@class SDImageCacheConfig;
/**
A protocol to allow custom disk cache used in SDImageCache.
*/
@protocol SDDiskCache <NSObject>
// All of these method are called from the same global queue to avoid blocking on main queue and thread-safe problem. But it's also recommend to ensure thread-safe yourself using lock or other ways.
@required
/**
Create a new disk cache based on the specified path. You can check `maxDiskSize` and `maxDiskAge` used for disk cache.
@param cachePath Full path of a directory in which the cache will write data.
Once initialized you should not read and write to this directory.
@param config The cache config to be used to create the cache.
@return A new cache object, or nil if an error occurs.
*/
- (nullable instancetype)initWithCachePath:(nonnull NSString *)cachePath config:(nonnull SDImageCacheConfig *)config;
/**
Returns a boolean value that indicates whether a given key is in cache.
This method may blocks the calling thread until file read finished.
@param key A string identifying the data. If nil, just return NO.
@return Whether the key is in cache.
*/
- (BOOL)containsDataForKey:(nonnull NSString *)key;
/**
Returns the data associated with a given key.
This method may blocks the calling thread until file read finished.
@param key A string identifying the data. If nil, just return nil.
@return The value associated with key, or nil if no value is associated with key.
*/
- (nullable NSData *)dataForKey:(nonnull NSString *)key;
/**
Sets the value of the specified key in the cache.
This method may blocks the calling thread until file write finished.
@param data The data to be stored in the cache.
@param key The key with which to associate the value. If nil, this method has no effect.
*/
- (void)setData:(nullable NSData *)data forKey:(nonnull NSString *)key;
/**
Returns the extended data associated with a given key.
This method may blocks the calling thread until file read finished.
@param key A string identifying the data. If nil, just return nil.
@return The value associated with key, or nil if no value is associated with key.
*/
- (nullable NSData *)extendedDataForKey:(nonnull NSString *)key;
/**
Set extended data with a given key.
@discussion You can set any extended data to exist cache key. Without override the exist disk file data.
on UNIX, the common way for this is to use the Extended file attributes (xattr)
@param extendedData The extended data (pass nil to remove).
@param key The key with which to associate the value. If nil, this method has no effect.
*/
- (void)setExtendedData:(nullable NSData *)extendedData forKey:(nonnull NSString *)key;
/**
Removes the value of the specified key in the cache.
This method may blocks the calling thread until file delete finished.
@param key The key identifying the value to be removed. If nil, this method has no effect.
*/
- (void)removeDataForKey:(nonnull NSString *)key;
/**
Empties the cache.
This method may blocks the calling thread until file delete finished.
*/
- (void)removeAllData;
/**
Removes the expired data from the cache. You can choose the data to remove base on `ageLimit`, `countLimit` and `sizeLimit` options.
*/
- (void)removeExpiredData;
/**
The cache path for key
@param key A string identifying the value
@return The cache path for key. Or nil if the key can not associate to a path
*/
- (nullable NSString *)cachePathForKey:(nonnull NSString *)key;
/**
Returns the number of data in this cache.
This method may blocks the calling thread until file read finished.
@return The total data count.
*/
- (NSUInteger)totalCount;
/**
Returns the total size (in bytes) of data in this cache.
This method may blocks the calling thread until file read finished.
@return The total data size in bytes.
*/
- (NSUInteger)totalSize;
@end
/**
The built-in disk cache.
*/
@interface SDDiskCache : NSObject <SDDiskCache>
/**
Cache Config object - storing all kind of settings.
*/
@property (nonatomic, strong, readonly, nonnull) SDImageCacheConfig *config;
- (nonnull instancetype)init NS_UNAVAILABLE;
/**
Move the cache directory from old location to new location, the old location will be removed after finish.
If the old location does not exist, does nothing.
If the new location does not exist, only do a movement of directory.
If the new location does exist, will move and merge the files from old location.
If the new location does exist, but is not a directory, will remove it and do a movement of directory.
@param srcPath old location of cache directory
@param dstPath new location of cache directory
*/
- (void)moveCacheDirectoryFromPath:(nonnull NSString *)srcPath toPath:(nonnull NSString *)dstPath;
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,105 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "NSImage+Compatibility.h"
#if SD_MAC
#import "SDImageCoderHelper.h"
@implementation NSImage (Compatibility)
- (nullable CGImageRef)CGImage {
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
CGImageRef cgImage = [self CGImageForProposedRect:&imageRect context:nil hints:nil];
return cgImage;
}
- (nullable CIImage *)CIImage {
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
if (![imageRep isKindOfClass:NSCIImageRep.class]) {
return nil;
}
return ((NSCIImageRep *)imageRep).CIImage;
}
- (CGFloat)scale {
CGFloat scale = 1;
NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height);
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
CGFloat width = imageRep.size.width;
CGFloat height = imageRep.size.height;
NSUInteger pixelWidth = imageRep.pixelsWide;
NSUInteger pixelHeight = imageRep.pixelsHigh;
if (width > 0 && height > 0) {
CGFloat widthScale = pixelWidth / width;
CGFloat heightScale = pixelHeight / height;
if (widthScale == heightScale && widthScale >= 1) {
// Protect because there may be `NSImageRepMatchesDevice` (0)
scale = widthScale;
}
}
return scale;
}
- (instancetype)initWithCGImage:(nonnull CGImageRef)cgImage scale:(CGFloat)scale orientation:(CGImagePropertyOrientation)orientation {
NSBitmapImageRep *imageRep;
if (orientation != kCGImagePropertyOrientationUp) {
// AppKit design is different from UIKit. Where CGImage based image rep does not respect to any orientation. Only data based image rep which contains the EXIF metadata can automatically detect orientation.
// This should be nonnull, until the memory is exhausted cause `CGBitmapContextCreate` failed.
CGImageRef rotatedCGImage = [SDImageCoderHelper CGImageCreateDecoded:cgImage orientation:orientation];
imageRep = [[NSBitmapImageRep alloc] initWithCGImage:rotatedCGImage];
CGImageRelease(rotatedCGImage);
} else {
imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
}
if (scale < 1) {
scale = 1;
}
CGFloat pixelWidth = imageRep.pixelsWide;
CGFloat pixelHeight = imageRep.pixelsHigh;
NSSize size = NSMakeSize(pixelWidth / scale, pixelHeight / scale);
self = [self initWithSize:size];
if (self) {
imageRep.size = size;
[self addRepresentation:imageRep];
}
return self;
}
- (instancetype)initWithCIImage:(nonnull CIImage *)ciImage scale:(CGFloat)scale orientation:(CGImagePropertyOrientation)orientation {
NSCIImageRep *imageRep;
if (orientation != kCGImagePropertyOrientationUp) {
CIImage *rotatedCIImage = [ciImage imageByApplyingOrientation:orientation];
imageRep = [[NSCIImageRep alloc] initWithCIImage:rotatedCIImage];
} else {
imageRep = [[NSCIImageRep alloc] initWithCIImage:ciImage];
}
if (scale < 1) {
scale = 1;
}
CGFloat pixelWidth = imageRep.pixelsWide;
CGFloat pixelHeight = imageRep.pixelsHigh;
NSSize size = NSMakeSize(pixelWidth / scale, pixelHeight / scale);
self = [self initWithSize:size];
if (self) {
imageRep.size = size;
[self addRepresentation:imageRep];
}
return self;
}
- (instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale {
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithData:data];
if (!imageRep) {
return nil;
}
if (scale < 1) {
scale = 1;
}
CGFloat pixelWidth = imageRep.pixelsWide;
CGFloat pixelHeight = imageRep.pixelsHigh;
NSSize size = NSMakeSize(pixelWidth / scale, pixelHeight / scale);
self = [self initWithSize:size];
if (self) {
imageRep.size = size;
[self addRepresentation:imageRep];
}
return self;
}
@end
#endif
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,049 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
#import "SDImageCoder.h"
/// A player to control the playback of animated image, which can be used to drive Animated ImageView or any rendering usage, like CALayer/WatchKit/SwiftUI rendering.
@interface SDAnimatedImagePlayer : NSObject
/// Current playing frame image. This value is KVO Compliance.
@property (nonatomic, readonly, nullable) UIImage *currentFrame;
/// Current frame index, zero based. This value is KVO Compliance.
@property (nonatomic, readonly) NSUInteger currentFrameIndex;
/// Current loop count since its latest animating. This value is KVO Compliance.
@property (nonatomic, readonly) NSUInteger currentLoopCount;
/// Total frame count for niamted image rendering. Defaults is animated image's frame count.
/// @note For progressive animation, you can update this value when your provider receive more frames.
@property (nonatomic, assign) NSUInteger totalFrameCount;
/// Total loop count for animated image rendering. Default is animated image's loop count.
@property (nonatomic, assign) NSUInteger totalLoopCount;
/// The animation playback rate. Default is 1.0
/// `1.0` means the normal speed.
/// `0.0` means stopping the animation.
/// `0.0-1.0` means the slow speed.
/// `> 1.0` means the fast speed.
/// `< 0.0` is not supported currently and stop animation. (may support reverse playback in the future)
@property (nonatomic, assign) double playbackRate;
/// Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is 0.
/// `0` means automatically adjust by calculating current memory usage.
/// `1` means without any buffer cache, each of frames will be decoded and then be freed after rendering. (Lowest Memory and Highest CPU)
/// `NSUIntegerMax` means cache all the buffer. (Lowest CPU and Highest Memory)
@property (nonatomic, assign) NSUInteger maxBufferSize;
/// You can specify a runloop mode to let it rendering.
/// Default is NSRunLoopCommonModes on multi-core device, NSDefaultRunLoopMode on single-core device
@property (nonatomic, copy, nonnull) NSRunLoopMode runLoopMode;
/// Create a player with animated image provider. If the provider's `animatedImageFrameCount` is less than 1, returns nil.
/// The provider can be any protocol implementation, like `SDAnimatedImage`, `SDImageGIFCoder`, etc.
/// @note This provider can represent mutable content, like prorgessive animated loading. But you need to update the frame count by yourself
/// @param provider The animated provider
- (nullable instancetype)initWithProvider:(nonnull id<SDAnimatedImageProvider>)provider;
/// Create a player with animated image provider. If the provider's `animatedImageFrameCount` is less than 1, returns nil.
/// The provider can be any protocol implementation, like `SDAnimatedImage` or `SDImageGIFCoder`, etc.
/// @note This provider can represent mutable content, like prorgessive animated loading. But you need to update the frame count by yourself
/// @param provider The animated provider
+ (nullable instancetype)playerWithProvider:(nonnull id<SDAnimatedImageProvider>)provider;
/// The handler block when current frame and index changed.
@property (nonatomic, copy, nullable) void (^animationFrameHandler)(NSUInteger index, UIImage * _Nonnull frame);
/// The handler block when one loop count finished.
@property (nonatomic, copy, nullable) void (^animationLoopHandler)(NSUInteger loopCount);
/// Return the status whehther animation is playing.
@property (nonatomic, readonly) BOOL isPlaying;
/// Start the animation. Or resume the previously paused animation.
- (void)startPlaying;
/// Pause the aniamtion. Keep the current frame index and loop count.
- (void)pausePlaying;
/// Stop the animation. Reset the current frame index and loop count.
- (void)stopPlaying;
/// Seek to the desired frame index and loop count.
/// @note This can be used for advanced control like progressive loading, or skipping specify frames.
/// @param index The frame index
/// @param loopCount The loop count
- (void)seekToFrameAtIndex:(NSUInteger)index loopCount:(NSUInteger)loopCount;
/// Clear the frame cache buffer. The frame cache buffer size can be controled by `maxBufferSize`.
/// By default, when stop or pause the animation, the frame buffer is still kept to ready for the next restart
- (void)clearFrameBuffer;
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,025 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <ImageIO/ImageIO.h>
#import "SDWebImageCompat.h"
#import "SDImageFrame.h"
/**
Provide some common helper methods for building the image decoder/encoder.
*/
@interface SDImageCoderHelper : NSObject
/**
Return an animated image with frames array.
For UIKit, this will apply the patch and then create animated UIImage. The patch is because that `+[UIImage animatedImageWithImages:duration:]` just use the average of duration for each image. So it will not work if different frame has different duration. Therefore we repeat the specify frame for specify times to let it work.
For AppKit, NSImage does not support animates other than GIF. This will try to encode the frames to GIF format and then create an animated NSImage for rendering. Attention the animated image may loss some detail if the input frames contain full alpha channel because GIF only supports 1 bit alpha channel. (For 1 pixel, either transparent or not)
@param frames The frames array. If no frames or frames is empty, return nil
@return A animated image for rendering on UIImageView(UIKit) or NSImageView(AppKit)
*/
+ (UIImage * _Nullable)animatedImageWithFrames:(NSArray<SDImageFrame *> * _Nullable)frames;
/**
Return frames array from an animated image.
For UIKit, this will unapply the patch for the description above and then create frames array. This will also work for normal animated UIImage.
For AppKit, NSImage does not support animates other than GIF. This will try to decode the GIF imageRep and then create frames array.
@param animatedImage A animated image. If it's not animated, return nil
@return The frames array
*/
+ (NSArray<SDImageFrame *> * _Nullable)framesFromAnimatedImage:(UIImage * _Nullable)animatedImage NS_SWIFT_NAME(frames(from:));
/**
Return the shared device-dependent RGB color space. This follows The Get Rule.
On iOS, it's created with deviceRGB (if available, use sRGB).
On macOS, it's from the screen colorspace (if failed, use deviceRGB)
Because it's shared, you should not retain or release this object.
@return The device-dependent RGB color space
*/
+ (CGColorSpaceRef _Nonnull)colorSpaceGetDeviceRGB CF_RETURNS_NOT_RETAINED;
/**
Check whether CGImage contains alpha channel.
@param cgImage The CGImage
@return Return YES if CGImage contains alpha channel, otherwise return NO
*/
+ (BOOL)CGImageContainsAlpha:(_Nonnull CGImageRef)cgImage;
/**
Create a decoded CGImage by the provided CGImage. This follows The Create Rule and you are response to call release after usage.
It will detect whether image contains alpha channel, then create a new bitmap context with the same size of image, and draw it. This can ensure that the image do not need extra decoding after been set to the imageView.
@note This actually call `CGImageCreateDecoded:orientation:` with the Up orientation.
@param cgImage The CGImage
@return A new created decoded image
*/
+ (CGImageRef _Nullable)CGImageCreateDecoded:(_Nonnull CGImageRef)cgImage CF_RETURNS_RETAINED;
/**
Create a decoded CGImage by the provided CGImage and orientation. This follows The Create Rule and you are response to call release after usage.
It will detect whether image contains alpha channel, then create a new bitmap context with the same size of image, and draw it. This can ensure that the image do not need extra decoding after been set to the imageView.
@param cgImage The CGImage
@param orientation The EXIF image orientation.
@return A new created decoded image
*/
+ (CGImageRef _Nullable)CGImageCreateDecoded:(_Nonnull CGImageRef)cgImage orientation:(CGImagePropertyOrientation)orientation CF_RETURNS_RETAINED;
/**
Create a scaled CGImage by the provided CGImage and size. This follows The Create Rule and you are response to call release after usage.
It will detect whether the image size matching the scale size, if not, stretch the image to the target size.
@param cgImage The CGImage
@param size The scale size in pixel.
@return A new created scaled image
*/
+ (CGImageRef _Nullable)CGImageCreateScaled:(_Nonnull CGImageRef)cgImage size:(CGSize)size CF_RETURNS_RETAINED;
/**
Return the decoded image by the provided image. This one unlike `CGImageCreateDecoded:`, will not decode the image which contains alpha channel or animated image
@param image The image to be decoded
@return The decoded image
*/
+ (UIImage * _Nullable)decodedImageWithImage:(UIImage * _Nullable)image;
/**
Return the decoded and probably scaled down image by the provided image. If the image is large than the limit size, will try to scale down. Or just works as `decodedImageWithImage:`
@param image The image to be decoded and scaled down
@param bytes The limit bytes size. Provide 0 to use the build-in limit.
@return The decoded and probably scaled down image
*/
+ (UIImage * _Nullable)decodedAndScaledDownImageWithImage:(UIImage * _Nullable)image limitBytes:(NSUInteger)bytes;
/**
Control the default limit bytes to scale down larget images.
This value must be larger than or equal to 1MB. Defaults to 60MB on iOS/tvOS, 90MB on macOS, 30MB on watchOS.
*/
@property (class, readwrite) NSUInteger defaultScaleDownLimitBytes;
#if SD_UIKIT || SD_WATCH
/**
Convert an EXIF image orientation to an iOS one.
@param exifOrientation EXIF orientation
@return iOS orientation
*/
+ (UIImageOrientation)imageOrientationFromEXIFOrientation:(CGImagePropertyOrientation)exifOrientation NS_SWIFT_NAME(imageOrientation(from:));
/**
Convert an iOS orientation to an EXIF image orientation.
@param imageOrientation iOS orientation
@return EXIF orientation
*/
+ (CGImagePropertyOrientation)exifOrientationFromImageOrientation:(UIImageOrientation)imageOrientation;
#endif
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,318 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
* (c) Laurin Brandner
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "UIImage+GIF.h"
#import "SDImageGIFCoder.h"
@implementation UIImage (GIF)
+ (nullable UIImage *)sd_imageWithGIFData:(nullable NSData *)data {
if (!data) {
return nil;
}
return [[SDImageGIFCoder sharedCoder] decodedImageWithData:data options:0];
}
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 139 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
#import "SDWebImageOperation.h"
#import "SDWebImageDefine.h"
/// Image Cache Type
typedef NS_ENUM(NSInteger, SDImageCacheType) {
/**
* For query and contains op in response, means the image isn't available in the image cache
* For op in request, this type is not available and take no effect.
*/
SDImageCacheTypeNone,
/**
* For query and contains op in response, means the image was obtained from the disk cache.
* For op in request, means process only disk cache.
*/
SDImageCacheTypeDisk,
/**
* For query and contains op in response, means the image was obtained from the memory cache.
* For op in request, means process only memory cache.
*/
SDImageCacheTypeMemory,
/**
* For query and contains op in response, this type is not available and take no effect.
* For op in request, means process both memory cache and disk cache.
*/
SDImageCacheTypeAll
};
typedef void(^SDImageCacheCheckCompletionBlock)(BOOL isInCache);
typedef void(^SDImageCacheQueryDataCompletionBlock)(NSData * _Nullable data);
typedef void(^SDImageCacheCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize);
typedef NSString * _Nullable (^SDImageCacheAdditionalCachePathBlock)(NSString * _Nonnull key);
typedef void(^SDImageCacheQueryCompletionBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType);
typedef void(^SDImageCacheContainsCompletionBlock)(SDImageCacheType containsCacheType);
/**
This is the built-in decoding process for image query from cache.
@note If you want to implement your custom loader with `queryImageForKey:options:context:completion:` API, but also want to keep compatible with SDWebImage's behavior, you'd better use this to produce image.
@param imageData The image data from the cache. Should not be nil
@param cacheKey The image cache key from the input. Should not be nil
@param options The options arg from the input
@param context The context arg from the input
@return The decoded image for current image data query from cache
*/
FOUNDATION_EXPORT UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSString * _Nonnull cacheKey, SDWebImageOptions options, SDWebImageContext * _Nullable context);
/**
This is the image cache protocol to provide custom image cache for `SDWebImageManager`.
Though the best practice to custom image cache, is to write your own class which conform `SDMemoryCache` or `SDDiskCache` protocol for `SDImageCache` class (See more on `SDImageCacheConfig.memoryCacheClass & SDImageCacheConfig.diskCacheClass`).
However, if your own cache implementation contains more advanced feature beyond `SDImageCache` itself, you can consider to provide this instead. For example, you can even use a cache manager like `SDImageCachesManager` to register multiple caches.
*/
@protocol SDImageCache <NSObject>
@required
/**
Query the cached image from image cache for given key. The operation can be used to cancel the query.
If image is cached in memory, completion is called synchronously, else aynchronously and depends on the options arg (See `SDWebImageQueryDiskSync`)
@param key The image cache key
@param options A mask to specify options to use for this query
@param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
@param completionBlock The completion block. Will not get called if the operation is cancelled
@return The operation for this query
*/
- (nullable id<SDWebImageOperation>)queryImageForKey:(nullable NSString *)key
options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context
completion:(nullable SDImageCacheQueryCompletionBlock)completionBlock;
/**
Query the cached image from image cache for given key. The operation can be used to cancel the query.
If image is cached in memory, completion is called synchronously, else aynchronously and depends on the options arg (See `SDWebImageQueryDiskSync`)
@param key The image cache key
@param options A mask to specify options to use for this query
@param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
@param cacheType Specify where to query the cache from. By default we use `.all`, which means both memory cache and disk cache. You can choose to query memory only or disk only as well. Pass `.none` is invalid and callback with nil immediatelly.
@param completionBlock The completion block. Will not get called if the operation is cancelled
@return The operation for this query
*/
- (nullable id<SDWebImageOperation>)queryImageForKey:(nullable NSString *)key
options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context
cacheType:(SDImageCacheType)cacheType
completion:(nullable SDImageCacheQueryCompletionBlock)completionBlock;
/**
Store the image into image cache for the given key. If cache type is memory only, completion is called synchronously, else aynchronously.
@param image The image to store
@param imageData The image data to be used for disk storage
@param key The image cache key
@param cacheType The image store op cache type
@param completionBlock A block executed after the operation is finished
*/
- (void)storeImage:(nullable UIImage *)image
imageData:(nullable NSData *)imageData
forKey:(nullable NSString *)key
cacheType:(SDImageCacheType)cacheType
completion:(nullable SDWebImageNoParamsBlock)completionBlock;
/**
Remove the image from image cache for the given key. If cache type is memory only, completion is called synchronously, else aynchronously.
@param key The image cache key
@param cacheType The image remove op cache type
@param completionBlock A block executed after the operation is finished
*/
- (void)removeImageForKey:(nullable NSString *)key
cacheType:(SDImageCacheType)cacheType
completion:(nullable SDWebImageNoParamsBlock)completionBlock;
/**
Check if image cache contains the image for the given key (does not load the image). If image is cached in memory, completion is called synchronously, else aynchronously.
@param key The image cache key
@param cacheType The image contains op cache type
@param completionBlock A block executed after the operation is finished.
*/
- (void)containsImageForKey:(nullable NSString *)key
cacheType:(SDImageCacheType)cacheType
completion:(nullable SDImageCacheContainsCompletionBlock)completionBlock;
/**
Clear all the cached images for image cache. If cache type is memory only, completion is called synchronously, else aynchronously.
@param cacheType The image clear op cache type
@param completionBlock A block executed after the operation is finished
*/
- (void)clearWithCacheType:(SDImageCacheType)cacheType
completion:(nullable SDWebImageNoParamsBlock)completionBlock;
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,594 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
* (c) Jamie Pinkham
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDWebImageError.h"
NSErrorDomain const _Nonnull SDWebImageErrorDomain = @"SDWebImageErrorDomain";
NSErrorUserInfoKey const _Nonnull SDWebImageErrorDownloadStatusCodeKey = @"SDWebImageErrorDownloadStatusCodeKey";
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 113 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "UIImageView+HighlightedWebCache.h"
#if SD_UIKIT
#import "UIView+WebCacheOperation.h"
#import "UIView+WebCache.h"
#import "SDInternalMacros.h"
static NSString * const SDHighlightedImageOperationKey = @"UIImageViewImageOperationHighlighted";
@implementation UIImageView (HighlightedWebCache)
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url {
[self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil];
}
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options {
[self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil];
}
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context {
[self sd_setHighlightedImageWithURL:url options:options context:context progress:nil completed:nil];
}
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock];
}
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock];
}
- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
[self sd_setHighlightedImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock];
}
- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url
options:(SDWebImageOptions)options
context:(nullable SDWebImageContext *)context
progress:(nullable SDImageLoaderProgressBlock)progressBlock
completed:(nullable SDExternalCompletionBlock)completedBlock {
@weakify(self);
SDWebImageMutableContext *mutableContext;
if (context) {
mutableContext = [context mutableCopy];
} else {
mutableContext = [NSMutableDictionary dictionary];
}
mutableContext[SDWebImageContextSetImageOperationKey] = SDHighlightedImageOperationKey;
[self sd_internalSetImageWithURL:url
placeholderImage:nil
options:options
context:mutableContext
setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
@strongify(self);
self.highlightedImage = image;
}
progress:progressBlock
completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
if (completedBlock) {
completedBlock(image, error, cacheType, imageURL);
}
}];
}
@end
#endif
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 676 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDWebImageDefine.h"
#import "UIImage+Metadata.h"
#import "NSImage+Compatibility.h"
#import "SDAssociatedObject.h"
#pragma mark - Image scale
static inline NSArray<NSNumber *> * _Nonnull SDImageScaleFactors() {
return @[@2, @3];
}
inline CGFloat SDImageScaleFactorForKey(NSString * _Nullable key) {
CGFloat scale = 1;
if (!key) {
return scale;
}
// Check if target OS support scale
#if SD_WATCH
if ([[WKInterfaceDevice currentDevice] respondsToSelector:@selector(screenScale)])
#elif SD_UIKIT
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
#elif SD_MAC
if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)])
#endif
{
// a@2x.png -> 8
if (key.length >= 8) {
// Fast check
BOOL isURL = [key hasPrefix:@"http://"] || [key hasPrefix:@"https://"];
for (NSNumber *scaleFactor in SDImageScaleFactors()) {
// @2x. for file name and normal url
NSString *fileScale = [NSString stringWithFormat:@"@%@x.", scaleFactor];
if ([key containsString:fileScale]) {
scale = scaleFactor.doubleValue;
return scale;
}
if (isURL) {
// %402x. for url encode
NSString *urlScale = [NSString stringWithFormat:@"%%40%@x.", scaleFactor];
if ([key containsString:urlScale]) {
scale = scaleFactor.doubleValue;
return scale;
}
}
}
}
}
return scale;
}
inline UIImage * _Nullable SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullable image) {
if (!image) {
return nil;
}
CGFloat scale = SDImageScaleFactorForKey(key);
return SDScaledImageForScaleFactor(scale, image);
}
inline UIImage * _Nullable SDScaledImageForScaleFactor(CGFloat scale, UIImage * _Nullable image) {
if (!image) {
return nil;
}
if (scale <= 1) {
return image;
}
if (scale == image.scale) {
return image;
}
UIImage *scaledImage;
if (image.sd_isAnimated) {
UIImage *animatedImage;
#if SD_UIKIT || SD_WATCH
// `UIAnimatedImage` images share the same size and scale.
NSMutableArray<UIImage *> *scaledImages = [NSMutableArray array];
for (UIImage *tempImage in image.images) {
UIImage *tempScaledImage = [[UIImage alloc] initWithCGImage:tempImage.CGImage scale:scale orientation:tempImage.imageOrientation];
[scaledImages addObject:tempScaledImage];
}
animatedImage = [UIImage animatedImageWithImages:scaledImages duration:image.duration];
animatedImage.sd_imageLoopCount = image.sd_imageLoopCount;
#else
// Animated GIF for `NSImage` need to grab `NSBitmapImageRep`;
NSRect imageRect = NSMakeRect(0, 0, image.size.width, image.size.height);
NSImageRep *imageRep = [image bestRepresentationForRect:imageRect context:nil hints:nil];
NSBitmapImageRep *bitmapImageRep;
if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) {
bitmapImageRep = (NSBitmapImageRep *)imageRep;
}
if (bitmapImageRep) {
NSSize size = NSMakeSize(image.size.width / scale, image.size.height / scale);
animatedImage = [[NSImage alloc] initWithSize:size];
bitmapImageRep.size = size;
[animatedImage addRepresentation:bitmapImageRep];
}
#endif
scaledImage = animatedImage;
} else {
#if SD_UIKIT || SD_WATCH
scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
#else
scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:kCGImagePropertyOrientationUp];
#endif
}
SDImageCopyAssociatedObject(image, scaledImage);
return scaledImage;
}
#pragma mark - Context option
SDWebImageContextOption const SDWebImageContextSetImageOperationKey = @"setImageOperationKey";
SDWebImageContextOption const SDWebImageContextCustomManager = @"customManager";
SDWebImageContextOption const SDWebImageContextImageCache = @"imageCache";
SDWebImageContextOption const SDWebImageContextImageLoader = @"imageLoader";
SDWebImageContextOption const SDWebImageContextImageCoder = @"imageCoder";
SDWebImageContextOption const SDWebImageContextImageTransformer = @"imageTransformer";
SDWebImageContextOption const SDWebImageContextImageScaleFactor = @"imageScaleFactor";
SDWebImageContextOption const SDWebImageContextImagePreserveAspectRatio = @"imagePreserveAspectRatio";
SDWebImageContextOption const SDWebImageContextImageThumbnailPixelSize = @"imageThumbnailPixelSize";
SDWebImageContextOption const SDWebImageContextQueryCacheType = @"queryCacheType";
SDWebImageContextOption const SDWebImageContextStoreCacheType = @"storeCacheType";
SDWebImageContextOption const SDWebImageContextOriginalQueryCacheType = @"originalQueryCacheType";
SDWebImageContextOption const SDWebImageContextOriginalStoreCacheType = @"originalStoreCacheType";
SDWebImageContextOption const SDWebImageContextAnimatedImageClass = @"animatedImageClass";
SDWebImageContextOption const SDWebImageContextDownloadRequestModifier = @"downloadRequestModifier";
SDWebImageContextOption const SDWebImageContextDownloadResponseModifier = @"downloadResponseModifier";
SDWebImageContextOption const SDWebImageContextDownloadDecryptor = @"downloadDecryptor";
SDWebImageContextOption const SDWebImageContextCacheKeyFilter = @"cacheKeyFilter";
SDWebImageContextOption const SDWebImageContextCacheSerializer = @"cacheSerializer";
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,253 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
* (c) Fabrice Aneche
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
/**
You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value.
For custom coder plugin, it can also extern the enum for supported format. See `SDImageCoder` for more detailed information.
*/
typedef NSInteger SDImageFormat NS_TYPED_EXTENSIBLE_ENUM;
static const SDImageFormat SDImageFormatUndefined = -1;
static const SDImageFormat SDImageFormatJPEG = 0;
static const SDImageFormat SDImageFormatPNG = 1;
static const SDImageFormat SDImageFormatGIF = 2;
static const SDImageFormat SDImageFormatTIFF = 3;
static const SDImageFormat SDImageFormatWebP = 4;
static const SDImageFormat SDImageFormatHEIC = 5;
static const SDImageFormat SDImageFormatHEIF = 6;
static const SDImageFormat SDImageFormatPDF = 7;
static const SDImageFormat SDImageFormatSVG = 8;
/**
NSData category about the image content type and UTI.
*/
@interface NSData (ImageContentType)
/**
* Return image format
*
* @param data the input image data
*
* @return the image format as `SDImageFormat` (enum)
*/
+ (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data;
/**
* Convert SDImageFormat to UTType
*
* @param format Format as SDImageFormat
* @return The UTType as CFStringRef
* @note For unknown format, `kUTTypeImage` abstract type will return
*/
+ (nonnull CFStringRef)sd_UTTypeFromImageFormat:(SDImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(sd_UTType(from:));
/**
* Convert UTTyppe to SDImageFormat
*
* @param uttype The UTType as CFStringRef
* @return The Format as SDImageFormat
* @note For unknown type, `SDImageFormatUndefined` will return
*/
+ (SDImageFormat)sd_imageFormatFromUTType:(nonnull CFStringRef)uttype;
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 530 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDWebImageCompat.h"
#import "SDImageCoder.h"
/**
This is the protocol for SDAnimatedImage class only but not for SDAnimatedImageCoder. If you want to provide a custom animated image class with full advanced function, you can conform to this instead of the base protocol.
*/
@protocol SDAnimatedImage <SDAnimatedImageProvider>
@required
/**
Initializes and returns the image object with the specified data, scale factor and possible animation decoding options.
@note We use this to create animated image instance for normal animation decoding.
@param data The data object containing the image data.
@param scale The scale factor to assume when interpreting the image data. Applying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the `size` property.
@param options A dictionary containing any animation decoding options.
@return An initialized object
*/
- (nullable instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale options:(nullable SDImageCoderOptions *)options;
/**
Initializes the image with an animated coder. You can use the coder to decode the image frame later.
@note We use this with animated coder which conforms to `SDProgressiveImageCoder` for progressive animation decoding.
@param animatedCoder An animated coder which conform `SDAnimatedImageCoder` protocol
@param scale The scale factor to assume when interpreting the image data. Applying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the `size` property.
@return An initialized object
*/
- (nullable instancetype)initWithAnimatedCoder:(nonnull id<SDAnimatedImageCoder>)animatedCoder scale:(CGFloat)scale;
@optional
// These methods are used for optional advanced feature, like image frame preloading.
/**
Pre-load all animated image frame into memory. Then later frame image request can directly return the frame for index without decoding.
This method may be called on background thread.
@note If one image instance is shared by lots of imageViews, the CPU performance for large animated image will drop down because the request frame index will be random (not in order) and the decoder should take extra effort to keep it re-entrant. You can use this to reduce CPU usage if need. Attention this will consume more memory usage.
*/
- (void)preloadAllFrames;
/**
Unload all animated image frame from memory if are already pre-loaded. Then later frame image request need decoding. You can use this to free up the memory usage if need.
*/
- (void)unloadAllFrames;
/**
Returns a Boolean value indicating whether all animated image frames are already pre-loaded into memory.
*/
@property (nonatomic, assign, readonly, getter=isAllFramesLoaded) BOOL allFramesLoaded;
/**
Return the animated image coder if the image is created with `initWithAnimatedCoder:scale:` method.
@note We use this with animated coder which conforms to `SDProgressiveImageCoder` for progressive animation decoding.
*/
@property (nonatomic, strong, readonly, nullable) id<SDAnimatedImageCoder> animatedCoder;
@end
/**
The image class which supports animating on `SDAnimatedImageView`. You can also use it on normal UIImageView/NSImageView.
*/
@interface SDAnimatedImage : UIImage <SDAnimatedImage>
// This class override these methods from UIImage(NSImage), and it supports NSSecureCoding.
// You should use these methods to create a new animated image. Use other methods just call super instead.
// Pay attention, when the animated image frame count <= 1, all the `SDAnimatedImageProvider` protocol methods will return nil or 0 value, you'd better check the frame count before usage and keep fallback.
+ (nullable instancetype)imageNamed:(nonnull NSString *)name; // Cache in memory, no Asset Catalog support
#if __has_include(<UIKit/UITraitCollection.h>)
+ (nullable instancetype)imageNamed:(nonnull NSString *)name inBundle:(nullable NSBundle *)bundle compatibleWithTraitCollection:(nullable UITraitCollection *)traitCollection; // Cache in memory, no Asset Catalog support
#else
+ (nullable instancetype)imageNamed:(nonnull NSString *)name inBundle:(nullable NSBundle *)bundle; // Cache in memory, no Asset Catalog support
#endif
+ (nullable instancetype)imageWithContentsOfFile:(nonnull NSString *)path;
+ (nullable instancetype)imageWithData:(nonnull NSData *)data;
+ (nullable instancetype)imageWithData:(nonnull NSData *)data scale:(CGFloat)scale;
- (nullable instancetype)initWithContentsOfFile:(nonnull NSString *)path;
- (nullable instancetype)initWithData:(nonnull NSData *)data;
- (nullable instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale;
/**
Current animated image format.
*/
@property (nonatomic, assign, readonly) SDImageFormat animatedImageFormat;
/**
Current animated image data, you can use this to grab the compressed format data and create another animated image instance.
If this image instance is an animated image created by using animated image coder (which means using the API listed above or using `initWithAnimatedCoder:scale:`), this property is non-nil.
*/
@property (nonatomic, copy, readonly, nullable) NSData *animatedImageData;
/**
The scale factor of the image.
@note For UIKit, this just call super instead.
@note For AppKit, `NSImage` can contains multiple image representations with different scales. However, this class does not do that from the design. We processs the scale like UIKit. This wil actually be calculated from image size and pixel size.
*/
@property (nonatomic, readonly) CGFloat scale;
// By default, animated image frames are returned by decoding just in time without keeping into memory. But you can choose to preload them into memory as well, See the decsription in `SDAnimatedImage` protocol.
// After preloaded, there is no huge difference on performance between this and UIImage's `animatedImageWithImages:duration:`. But UIImage's animation have some issues such like blanking and pausing during segue when using in `UIImageView`. It's recommend to use only if need.
- (void)preloadAllFrames;
- (void)unloadAllFrames;
@property (nonatomic, assign, readonly, getter=isAllFramesLoaded) BOOL allFramesLoaded;
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,377 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "SDWebImageCompat.h"
#if !__has_feature(objc_arc)
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
#if !OS_OBJECT_USE_OBJC
#error SDWebImage need ARC for dispatch object
#endif
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 122 |
```unknown
framework module MJRefresh {
umbrella header "MJRefresh-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/MJRefresh.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 28 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "MJRefreshAutoFooter.h"
#import "MJRefreshBackFooter.h"
#import "MJRefreshComponent.h"
#import "MJRefreshFooter.h"
#import "MJRefreshHeader.h"
#import "MJRefreshAutoGifFooter.h"
#import "MJRefreshAutoNormalFooter.h"
#import "MJRefreshAutoStateFooter.h"
#import "MJRefreshBackGifFooter.h"
#import "MJRefreshBackNormalFooter.h"
#import "MJRefreshBackStateFooter.h"
#import "MJRefreshGifHeader.h"
#import "MJRefreshNormalHeader.h"
#import "MJRefreshStateHeader.h"
#import "MJRefresh.h"
#import "MJRefreshConfig.h"
#import "MJRefreshConst.h"
#import "NSBundle+MJRefresh.h"
#import "UIScrollView+MJExtension.h"
#import "UIScrollView+MJRefresh.h"
#import "UIView+MJExtension.h"
FOUNDATION_EXPORT double MJRefreshVersionNumber;
FOUNDATION_EXPORT const unsigned char MJRefreshVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/MJRefresh-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 234 |
```unknown
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/MJRefresh-prefix.pch | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 46 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.4.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/MJRefresh-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```unknown
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/MJRefresh
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/MJRefresh.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 128 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_MJRefresh : NSObject
@end
@implementation PodsDummy_MJRefresh
@end
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/MJRefresh-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 25 |
```objective-c
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "UIImage+ForceDecode.h"
#import "SDImageCoderHelper.h"
#import "objc/runtime.h"
@implementation UIImage (ForceDecode)
- (BOOL)sd_isDecoded {
NSNumber *value = objc_getAssociatedObject(self, @selector(sd_isDecoded));
return value.boolValue;
}
- (void)setSd_isDecoded:(BOOL)sd_isDecoded {
objc_setAssociatedObject(self, @selector(sd_isDecoded), @(sd_isDecoded), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
+ (nullable UIImage *)sd_decodedImageWithImage:(nullable UIImage *)image {
if (!image) {
return nil;
}
return [SDImageCoderHelper decodedImageWithImage:image];
}
+ (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image {
return [self sd_decodedAndScaledDownImageWithImage:image limitBytes:0];
}
+ (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image limitBytes:(NSUInteger)bytes {
if (!image) {
return nil;
}
return [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:bytes];
}
@end
``` | /content/code_sandbox/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 311 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods_PlayerDemo : NSObject
@end
@implementation PodsDummy_Pods_PlayerDemo
@end
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 25 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.15</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/MJRefresh/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```unknown
CLANG_MODULES_AUTOLINK = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage/GPUImage.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController/TZImagePickerController.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage/GPUImage.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController/TZImagePickerController.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController"
OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "AVFoundation" -framework "AssetsLibrary" -framework "CoreGraphics" -framework "CoreMedia" -framework "Foundation" -framework "GPUImage" -framework "ImageIO" -framework "MJRefresh" -framework "Masonry" -framework "MobileCoreServices" -framework "OpenGLES" -framework "Photos" -framework "QuartzCore" -framework "SDWebImage" -framework "Security" -framework "SystemConfiguration" -framework "TZImagePickerController" -framework "UIKit"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.release.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 632 |
```shell
#!/bin/sh
set -e
set -u
set -o pipefail
if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
# If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
# resources to, so exit 0 (signalling the script phase was successful).
exit 0
fi
mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
> "$RESOURCES_TO_COPY"
XCASSET_FILES=()
# This protects against multiple targets copying the same framework dependency at the same time. The solution
# was originally proposed here: path_to_url
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
case "${TARGETED_DEVICE_FAMILY:-}" in
1,2)
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
;;
1)
TARGET_DEVICE_ARGS="--target-device iphone"
;;
2)
TARGET_DEVICE_ARGS="--target-device ipad"
;;
3)
TARGET_DEVICE_ARGS="--target-device tv"
;;
4)
TARGET_DEVICE_ARGS="--target-device watch"
;;
*)
TARGET_DEVICE_ARGS="--target-device mac"
;;
esac
install_resource()
{
if [[ "$1" = /* ]] ; then
RESOURCE_PATH="$1"
else
RESOURCE_PATH="${PODS_ROOT}/$1"
fi
if [[ ! -e "$RESOURCE_PATH" ]] ; then
cat << EOM
error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
EOM
exit 1
fi
case $RESOURCE_PATH in
*.storyboard)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;
*.xib)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;
*.framework)
echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
;;
*.xcdatamodel)
echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true
xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
;;
*.xcdatamodeld)
echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true
xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
;;
*.xcmappingmodel)
echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true
xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
;;
*.xcassets)
ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
;;
*)
echo "$RESOURCE_PATH" || true
echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
;;
esac
}
mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
fi
rm -f "$RESOURCES_TO_COPY"
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ]
then
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
while read line; do
if [[ $line != "${PODS_ROOT}*" ]]; then
XCASSET_FILES+=("$line")
fi
done <<<"$OTHER_XCASSETS"
if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
else
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist"
fi
fi
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-resources.sh | shell | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,630 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
FOUNDATION_EXPORT double Pods_PlayerDemoVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_PlayerDemoVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 66 |
```unknown
CLANG_MODULES_AUTOLINK = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage/GPUImage.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController/TZImagePickerController.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage/GPUImage.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Masonry/Masonry.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage/SDWebImage.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController/TZImagePickerController.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/GPUImage" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Masonry" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController"
OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "AVFoundation" -framework "AssetsLibrary" -framework "CoreGraphics" -framework "CoreMedia" -framework "Foundation" -framework "GPUImage" -framework "ImageIO" -framework "MJRefresh" -framework "Masonry" -framework "MobileCoreServices" -framework "OpenGLES" -framework "Photos" -framework "QuartzCore" -framework "SDWebImage" -framework "Security" -framework "SystemConfiguration" -framework "TZImagePickerController" -framework "UIKit"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.debug.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 632 |
```unknown
framework module Pods_PlayerDemo {
umbrella header "Pods-PlayerDemo-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 32 |
```markdown
# Acknowledgements
This application makes use of the following third party libraries:
## AFNetworking
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## GPUImage
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the GPUImage framework nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## MJRefresh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## Masonry
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## SDWebImage
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## TZImagePickerController
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Generated by CocoaPods - path_to_url
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-acknowledgements.markdown | markdown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,341 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```shell
#!/bin/sh
set -e
set -u
set -o pipefail
function on_error {
echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
}
trap 'on_error $LINENO' ERR
if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
# If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
# frameworks to, so exit 0 (signalling the script phase was successful).
exit 0
fi
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
# Used as a return value for each invocation of `strip_invalid_archs` function.
STRIP_BINARY_RETVAL=0
# This protects against multiple targets copying the same framework dependency at the same time. The solution
# was originally proposed here: path_to_url
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
# Copies and strips a vendored framework
install_framework()
{
if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
local source="${BUILT_PRODUCTS_DIR}/$1"
elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
elif [ -r "$1" ]; then
local source="$1"
fi
local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
if [ -L "${source}" ]; then
echo "Symlinked..."
source="$(readlink "${source}")"
fi
# Use filter instead of exclude so missing patterns don't throw errors.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
local basename
basename="$(basename -s .framework "$1")"
binary="${destination}/${basename}.framework/${basename}"
if ! [ -r "$binary" ]; then
binary="${destination}/${basename}"
elif [ -L "${binary}" ]; then
echo "Destination binary is symlinked..."
dirname="$(dirname "${binary}")"
binary="${dirname}/$(readlink "${binary}")"
fi
# Strip invalid architectures so "fat" simulator / device frameworks work on device
if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
strip_invalid_archs "$binary"
fi
# Resign the code if required by the build settings to avoid unstable apps
code_sign_if_enabled "${destination}/$(basename "$1")"
# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
local swift_runtime_libs
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u)
for lib in $swift_runtime_libs; do
echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
code_sign_if_enabled "${destination}/${lib}"
done
fi
}
# Copies and strips a vendored dSYM
install_dsym() {
local source="$1"
if [ -r "$source" ]; then
# Copy the dSYM into a the targets temp dir.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
local basename
basename="$(basename -s .framework.dSYM "$source")"
binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}"
# Strip invalid architectures so "fat" simulator / device frameworks work on device
if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then
strip_invalid_archs "$binary"
fi
if [[ $STRIP_BINARY_RETVAL == 1 ]]; then
# Move the stripped file into its final destination.
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
else
# The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM"
fi
fi
}
# Copies the bcsymbolmap files of a vendored framework
install_bcsymbolmap() {
local bcsymbolmap_path="$1"
local destination="${BUILT_PRODUCTS_DIR}"
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}""
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"
}
# Signs a framework with the provided identity
code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identity
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
fi
echo "$code_sign_cmd"
eval "$code_sign_cmd"
fi
}
# Strip invalid architectures
strip_invalid_archs() {
binary="$1"
# Get architectures for current target binary
binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
# Intersect them with the architectures we are building for
intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
# If there are no archs supported by this binary then warn the user
if [[ -z "$intersected_archs" ]]; then
echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
STRIP_BINARY_RETVAL=0
return
fi
stripped=""
for arch in $binary_archs; do
if ! [[ "${ARCHS}" == *"$arch"* ]]; then
# Strip non-valid architectures in-place
lipo -remove "$arch" -output "$binary" "$binary"
stripped="$stripped $arch"
fi
done
if [[ "$stripped" ]]; then
echo "Stripped $binary of architectures:$stripped"
fi
STRIP_BINARY_RETVAL=1
}
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework"
install_framework "${BUILT_PRODUCTS_DIR}/GPUImage/GPUImage.framework"
install_framework "${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework"
install_framework "${BUILT_PRODUCTS_DIR}/TZImagePickerController/TZImagePickerController.framework"
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework"
install_framework "${BUILT_PRODUCTS_DIR}/GPUImage/GPUImage.framework"
install_framework "${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework"
install_framework "${BUILT_PRODUCTS_DIR}/TZImagePickerController/TZImagePickerController.framework"
fi
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
wait
fi
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-frameworks.sh | shell | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 2,323 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/AFNetworking-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<string>MIT</string>
<key>Title</key>
<string>AFNetworking</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the GPUImage framework nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</string>
<string>BSD</string>
<key>Title</key>
<string>GPUImage</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<string>MIT</string>
<key>Title</key>
<string>MJRefresh</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<string>MIT</string>
<key>Title</key>
<string>Masonry</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<string>MIT</string>
<key>Title</key>
<string>SDWebImage</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<string>MIT</string>
<key>Title</key>
<string>TZImagePickerController</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - path_to_url
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-acknowledgements.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,928 |
```unknown
framework module AFNetworking {
umbrella header "AFNetworking-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 28 |
```unknown
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 162 |
```unknown
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#ifndef TARGET_OS_IOS
#define TARGET_OS_IOS TARGET_OS_IPHONE
#endif
#ifndef TARGET_OS_WATCH
#define TARGET_OS_WATCH 0
#endif
#ifndef TARGET_OS_TV
#define TARGET_OS_TV 0
#endif
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 96 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_AFNetworking : NSObject
@end
@implementation PodsDummy_AFNetworking
@end
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 23 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "AFNetworking.h"
#import "AFHTTPSessionManager.h"
#import "AFURLSessionManager.h"
#import "AFCompatibilityMacros.h"
#import "AFNetworkReachabilityManager.h"
#import "AFSecurityPolicy.h"
#import "AFURLRequestSerialization.h"
#import "AFURLResponseSerialization.h"
#import "AFAutoPurgingImageCache.h"
#import "AFImageDownloader.h"
#import "AFNetworkActivityIndicatorManager.h"
#import "UIActivityIndicatorView+AFNetworking.h"
#import "UIButton+AFNetworking.h"
#import "UIImage+AFNetworking.h"
#import "UIImageView+AFNetworking.h"
#import "UIKit+AFNetworking.h"
#import "UIProgressView+AFNetworking.h"
#import "UIRefreshControl+AFNetworking.h"
#import "UIWebView+AFNetworking.h"
FOUNDATION_EXPORT double AFNetworkingVersionNumber;
FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 222 |
```unknown
framework module Masonry {
umbrella header "Masonry-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Masonry.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 28 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Masonry-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/AFNetworking/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```unknown
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Masonry-prefix.pch | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 46 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "MASCompositeConstraint.h"
#import "MASConstraint+Private.h"
#import "MASConstraint.h"
#import "MASConstraintMaker.h"
#import "MASLayoutConstraint.h"
#import "Masonry.h"
#import "MASUtilities.h"
#import "MASViewAttribute.h"
#import "MASViewConstraint.h"
#import "NSArray+MASAdditions.h"
#import "NSArray+MASShorthandAdditions.h"
#import "NSLayoutConstraint+MASDebugAdditions.h"
#import "View+MASAdditions.h"
#import "View+MASShorthandAdditions.h"
#import "ViewController+MASAdditions.h"
FOUNDATION_EXPORT double MasonryVersionNumber;
FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Masonry-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 184 |
```unknown
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Masonry
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "Foundation" -framework "UIKit"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Masonry.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 148 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_Masonry : NSObject
@end
@implementation PodsDummy_Masonry
@end
``` | /content/code_sandbox/Pods/Target Support Files/Masonry/Masonry-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 23 |
```unknown
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "ImageIO"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/SDWebImage
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
SUPPORTS_MACCATALYST = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 169 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "NSButton+WebCache.h"
#import "NSData+ImageContentType.h"
#import "NSImage+Compatibility.h"
#import "SDAnimatedImage.h"
#import "SDAnimatedImagePlayer.h"
#import "SDAnimatedImageRep.h"
#import "SDAnimatedImageView+WebCache.h"
#import "SDAnimatedImageView.h"
#import "SDDiskCache.h"
#import "SDGraphicsImageRenderer.h"
#import "SDImageAPNGCoder.h"
#import "SDImageCache.h"
#import "SDImageCacheConfig.h"
#import "SDImageCacheDefine.h"
#import "SDImageCachesManager.h"
#import "SDImageCoder.h"
#import "SDImageCoderHelper.h"
#import "SDImageCodersManager.h"
#import "SDImageFrame.h"
#import "SDImageGIFCoder.h"
#import "SDImageGraphics.h"
#import "SDImageHEICCoder.h"
#import "SDImageIOAnimatedCoder.h"
#import "SDImageIOCoder.h"
#import "SDImageLoader.h"
#import "SDImageLoadersManager.h"
#import "SDImageTransformer.h"
#import "SDMemoryCache.h"
#import "SDWebImageCacheKeyFilter.h"
#import "SDWebImageCacheSerializer.h"
#import "SDWebImageCompat.h"
#import "SDWebImageDefine.h"
#import "SDWebImageDownloader.h"
#import "SDWebImageDownloaderConfig.h"
#import "SDWebImageDownloaderDecryptor.h"
#import "SDWebImageDownloaderOperation.h"
#import "SDWebImageDownloaderRequestModifier.h"
#import "SDWebImageDownloaderResponseModifier.h"
#import "SDWebImageError.h"
#import "SDWebImageIndicator.h"
#import "SDWebImageManager.h"
#import "SDWebImageOperation.h"
#import "SDWebImageOptionsProcessor.h"
#import "SDWebImagePrefetcher.h"
#import "SDWebImageTransition.h"
#import "UIButton+WebCache.h"
#import "UIImage+ExtendedCacheData.h"
#import "UIImage+ForceDecode.h"
#import "UIImage+GIF.h"
#import "UIImage+MemoryCacheCost.h"
#import "UIImage+Metadata.h"
#import "UIImage+MultiFormat.h"
#import "UIImage+Transform.h"
#import "UIImageView+HighlightedWebCache.h"
#import "UIImageView+WebCache.h"
#import "UIView+WebCache.h"
#import "UIView+WebCacheOperation.h"
#import "SDWebImage.h"
FOUNDATION_EXPORT double SDWebImageVersionNumber;
FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 546 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.8.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/SDWebImage-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```unknown
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 46 |
```unknown
framework module SDWebImage {
umbrella header "SDWebImage-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 30 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_SDWebImage : NSObject
@end
@implementation PodsDummy_SDWebImage
@end
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 25 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/SDWebImage/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```unknown
framework module TZImagePickerController {
umbrella header "TZImagePickerController-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/TZImagePickerController.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 30 |
```unknown
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "AssetsLibrary" -framework "Photos"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/TZImagePickerController
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/TZImagePickerController.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 151 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "NSBundle+TZImagePicker.h"
#import "TZAssetCell.h"
#import "TZAssetModel.h"
#import "TZGifPhotoPreviewController.h"
#import "TZImageCropManager.h"
#import "TZImageManager.h"
#import "TZImagePickerController.h"
#import "TZLocationManager.h"
#import "TZPhotoPickerController.h"
#import "TZPhotoPreviewCell.h"
#import "TZPhotoPreviewController.h"
#import "TZProgressView.h"
#import "TZVideoPlayerController.h"
#import "UIView+Layout.h"
FOUNDATION_EXPORT double TZImagePickerControllerVersionNumber;
FOUNDATION_EXPORT const unsigned char TZImagePickerControllerVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/TZImagePickerController-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 173 |
```unknown
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/TZImagePickerController-prefix.pch | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 46 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.1.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/TZImagePickerController-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_TZImagePickerController : NSObject
@end
@implementation PodsDummy_TZImagePickerController
@end
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/TZImagePickerController-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 27 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/GPUImage-Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.1.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/TZImagePickerController/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```unknown
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/GPUImage-prefix.pch | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 46 |
```objective-c
#import <Foundation/Foundation.h>
@interface PodsDummy_GPUImage : NSObject
@end
@implementation PodsDummy_GPUImage
@end
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/GPUImage-dummy.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 23 |
```unknown
CLANG_MODULES_AUTOLINK = YES
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/GPUImage
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "AVFoundation" -framework "CoreMedia" -framework "OpenGLES" -framework "QuartzCore"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/GPUImage
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/GPUImage.xcconfig | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 173 |
```unknown
framework module GPUImage {
umbrella header "GPUImage-umbrella.h"
export *
module * { export * }
}
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/GPUImage.modulemap | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 28 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/Info.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 254 |
```objective-c
//
// UIView+Layout.m
//
// Created by on 15/2/24.
//
#import "UIView+Layout.h"
@implementation UIView (Layout)
- (CGFloat)tz_left {
return self.frame.origin.x;
}
- (void)setTz_left:(CGFloat)x {
CGRect frame = self.frame;
frame.origin.x = x;
self.frame = frame;
}
- (CGFloat)tz_top {
return self.frame.origin.y;
}
- (void)setTz_top:(CGFloat)y {
CGRect frame = self.frame;
frame.origin.y = y;
self.frame = frame;
}
- (CGFloat)tz_right {
return self.frame.origin.x + self.frame.size.width;
}
- (void)setTz_right:(CGFloat)right {
CGRect frame = self.frame;
frame.origin.x = right - frame.size.width;
self.frame = frame;
}
- (CGFloat)tz_bottom {
return self.frame.origin.y + self.frame.size.height;
}
- (void)setTz_bottom:(CGFloat)bottom {
CGRect frame = self.frame;
frame.origin.y = bottom - frame.size.height;
self.frame = frame;
}
- (CGFloat)tz_width {
return self.frame.size.width;
}
- (void)setTz_width:(CGFloat)width {
CGRect frame = self.frame;
frame.size.width = width;
self.frame = frame;
}
- (CGFloat)tz_height {
return self.frame.size.height;
}
- (void)setTz_height:(CGFloat)height {
CGRect frame = self.frame;
frame.size.height = height;
self.frame = frame;
}
- (CGFloat)tz_centerX {
return self.center.x;
}
- (void)setTz_centerX:(CGFloat)centerX {
self.center = CGPointMake(centerX, self.center.y);
}
- (CGFloat)tz_centerY {
return self.center.y;
}
- (void)setTz_centerY:(CGFloat)centerY {
self.center = CGPointMake(self.center.x, centerY);
}
- (CGPoint)tz_origin {
return self.frame.origin;
}
- (void)setTz_origin:(CGPoint)origin {
CGRect frame = self.frame;
frame.origin = origin;
self.frame = frame;
}
- (CGSize)tz_size {
return self.frame.size;
}
- (void)setTz_size:(CGSize)size {
CGRect frame = self.frame;
frame.size = size;
self.frame = frame;
}
+ (void)showOscillatoryAnimationWithLayer:(CALayer *)layer type:(TZOscillatoryAnimationType)type{
NSNumber *animationScale1 = type == TZOscillatoryAnimationToBigger ? @(1.15) : @(0.5);
NSNumber *animationScale2 = type == TZOscillatoryAnimationToBigger ? @(0.92) : @(1.15);
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
[layer setValue:animationScale1 forKeyPath:@"transform.scale"];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
[layer setValue:animationScale2 forKeyPath:@"transform.scale"];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut animations:^{
[layer setValue:@(1.0) forKeyPath:@"transform.scale"];
} completion:nil];
}];
}];
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/UIView+Layout.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 763 |
```objective-c
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "GLProgram.h"
#import "GPUImage.h"
#import "GPUImage3x3ConvolutionFilter.h"
#import "GPUImage3x3TextureSamplingFilter.h"
#import "GPUImageAdaptiveThresholdFilter.h"
#import "GPUImageAddBlendFilter.h"
#import "GPUImageAlphaBlendFilter.h"
#import "GPUImageAmatorkaFilter.h"
#import "GPUImageAverageColor.h"
#import "GPUImageAverageLuminanceThresholdFilter.h"
#import "GPUImageBilateralFilter.h"
#import "GPUImageBoxBlurFilter.h"
#import "GPUImageBrightnessFilter.h"
#import "GPUImageBuffer.h"
#import "GPUImageBulgeDistortionFilter.h"
#import "GPUImageCannyEdgeDetectionFilter.h"
#import "GPUImageCGAColorspaceFilter.h"
#import "GPUImageChromaKeyBlendFilter.h"
#import "GPUImageChromaKeyFilter.h"
#import "GPUImageClosingFilter.h"
#import "GPUImageColorBlendFilter.h"
#import "GPUImageColorBurnBlendFilter.h"
#import "GPUImageColorDodgeBlendFilter.h"
#import "GPUImageColorInvertFilter.h"
#import "GPUImageColorMatrixFilter.h"
#import "GPUImageColorPackingFilter.h"
#import "GPUImageContrastFilter.h"
#import "GPUImageCropFilter.h"
#import "GPUImageCrosshairGenerator.h"
#import "GPUImageCrosshatchFilter.h"
#import "GPUImageDarkenBlendFilter.h"
#import "GPUImageDifferenceBlendFilter.h"
#import "GPUImageDilationFilter.h"
#import "GPUImageDirectionalNonMaximumSuppressionFilter.h"
#import "GPUImageDirectionalSobelEdgeDetectionFilter.h"
#import "GPUImageDissolveBlendFilter.h"
#import "GPUImageDivideBlendFilter.h"
#import "GPUImageEmbossFilter.h"
#import "GPUImageErosionFilter.h"
#import "GPUImageExclusionBlendFilter.h"
#import "GPUImageExposureFilter.h"
#import "GPUImageFalseColorFilter.h"
#import "GPUImageFASTCornerDetectionFilter.h"
#import "GPUImageFilter.h"
#import "GPUImageFilterGroup.h"
#import "GPUImageFilterPipeline.h"
#import "GPUImageFramebuffer.h"
#import "GPUImageFramebufferCache.h"
#import "GPUImageGammaFilter.h"
#import "GPUImageGaussianBlurFilter.h"
#import "GPUImageGaussianBlurPositionFilter.h"
#import "GPUImageGaussianSelectiveBlurFilter.h"
#import "GPUImageGlassSphereFilter.h"
#import "GPUImageGrayscaleFilter.h"
#import "GPUImageHalftoneFilter.h"
#import "GPUImageHardLightBlendFilter.h"
#import "GPUImageHarrisCornerDetectionFilter.h"
#import "GPUImageHazeFilter.h"
#import "GPUImageHighlightShadowFilter.h"
#import "GPUImageHighPassFilter.h"
#import "GPUImageHistogramEqualizationFilter.h"
#import "GPUImageHistogramFilter.h"
#import "GPUImageHistogramGenerator.h"
#import "GPUImageHoughTransformLineDetector.h"
#import "GPUImageHSBFilter.h"
#import "GPUImageHueBlendFilter.h"
#import "GPUImageHueFilter.h"
#import "GPUImageiOSBlurFilter.h"
#import "GPUImageJFAVoronoiFilter.h"
#import "GPUImageKuwaharaFilter.h"
#import "GPUImageKuwaharaRadius3Filter.h"
#import "GPUImageLanczosResamplingFilter.h"
#import "GPUImageLaplacianFilter.h"
#import "GPUImageLevelsFilter.h"
#import "GPUImageLightenBlendFilter.h"
#import "GPUImageLinearBurnBlendFilter.h"
#import "GPUImageLineGenerator.h"
#import "GPUImageLocalBinaryPatternFilter.h"
#import "GPUImageLookupFilter.h"
#import "GPUImageLowPassFilter.h"
#import "GPUImageLuminanceRangeFilter.h"
#import "GPUImageLuminanceThresholdFilter.h"
#import "GPUImageLuminosity.h"
#import "GPUImageLuminosityBlendFilter.h"
#import "GPUImageMaskFilter.h"
#import "GPUImageMedianFilter.h"
#import "GPUImageMissEtikateFilter.h"
#import "GPUImageMonochromeFilter.h"
#import "GPUImageMosaicFilter.h"
#import "GPUImageMotionBlurFilter.h"
#import "GPUImageMotionDetector.h"
#import "GPUImageMovie.h"
#import "GPUImageMovieComposition.h"
#import "GPUImageMultiplyBlendFilter.h"
#import "GPUImageNobleCornerDetectionFilter.h"
#import "GPUImageNonMaximumSuppressionFilter.h"
#import "GPUImageNormalBlendFilter.h"
#import "GPUImageOpacityFilter.h"
#import "GPUImageOpeningFilter.h"
#import "GPUImageOutput.h"
#import "GPUImageOverlayBlendFilter.h"
#import "GPUImageParallelCoordinateLineTransformFilter.h"
#import "GPUImagePerlinNoiseFilter.h"
#import "GPUImagePinchDistortionFilter.h"
#import "GPUImagePixellateFilter.h"
#import "GPUImagePixellatePositionFilter.h"
#import "GPUImagePoissonBlendFilter.h"
#import "GPUImagePolarPixellateFilter.h"
#import "GPUImagePolkaDotFilter.h"
#import "GPUImagePosterizeFilter.h"
#import "GPUImagePrewittEdgeDetectionFilter.h"
#import "GPUImageRawDataInput.h"
#import "GPUImageRawDataOutput.h"
#import "GPUImageRGBClosingFilter.h"
#import "GPUImageRGBDilationFilter.h"
#import "GPUImageRGBErosionFilter.h"
#import "GPUImageRGBFilter.h"
#import "GPUImageRGBOpeningFilter.h"
#import "GPUImageSaturationBlendFilter.h"
#import "GPUImageSaturationFilter.h"
#import "GPUImageScreenBlendFilter.h"
#import "GPUImageSepiaFilter.h"
#import "GPUImageSharpenFilter.h"
#import "GPUImageShiTomasiFeatureDetectionFilter.h"
#import "GPUImageSingleComponentGaussianBlurFilter.h"
#import "GPUImageSketchFilter.h"
#import "GPUImageSmoothToonFilter.h"
#import "GPUImageSobelEdgeDetectionFilter.h"
#import "GPUImageSoftEleganceFilter.h"
#import "GPUImageSoftLightBlendFilter.h"
#import "GPUImageSolidColorGenerator.h"
#import "GPUImageSourceOverBlendFilter.h"
#import "GPUImageSphereRefractionFilter.h"
#import "GPUImageStillCamera.h"
#import "GPUImageStretchDistortionFilter.h"
#import "GPUImageSubtractBlendFilter.h"
#import "GPUImageSwirlFilter.h"
#import "GPUImageTextureInput.h"
#import "GPUImageTextureOutput.h"
#import "GPUImageThreeInputFilter.h"
#import "GPUImageThresholdEdgeDetectionFilter.h"
#import "GPUImageThresholdedNonMaximumSuppressionFilter.h"
#import "GPUImageThresholdSketchFilter.h"
#import "GPUImageTiltShiftFilter.h"
#import "GPUImageToneCurveFilter.h"
#import "GPUImageToonFilter.h"
#import "GPUImageTransformFilter.h"
#import "GPUImageTwoInputCrossTextureSamplingFilter.h"
#import "GPUImageTwoInputFilter.h"
#import "GPUImageTwoPassFilter.h"
#import "GPUImageTwoPassTextureSamplingFilter.h"
#import "GPUImageUIElement.h"
#import "GPUImageUnsharpMaskFilter.h"
#import "GPUImageVideoCamera.h"
#import "GPUImageVignetteFilter.h"
#import "GPUImageVoronoiConsumerFilter.h"
#import "GPUImageWeakPixelInclusionFilter.h"
#import "GPUImageWhiteBalanceFilter.h"
#import "GPUImageXYDerivativeFilter.h"
#import "GPUImageZoomBlurFilter.h"
#import "GPUImageFramework.h"
#import "GPUImageContext.h"
#import "GPUImageMovieWriter.h"
#import "GPUImagePicture+TextureSubimage.h"
#import "GPUImagePicture.h"
#import "GPUImageView.h"
FOUNDATION_EXPORT double GPUImageVersionNumber;
FOUNDATION_EXPORT const unsigned char GPUImageVersionString[];
``` | /content/code_sandbox/Pods/Target Support Files/GPUImage/GPUImage-umbrella.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,650 |
```objective-c
//
// TZPhotoPreviewCell.h
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import <UIKit/UIKit.h>
@class TZAssetModel;
@interface TZAssetPreviewCell : UICollectionViewCell
@property (nonatomic, strong) TZAssetModel *model;
@property (nonatomic, copy) void (^singleTapGestureBlock)(void);
- (void)configSubviews;
- (void)photoPreviewCollectionViewDidScroll;
@end
@class TZAssetModel,TZProgressView,TZPhotoPreviewView;
@interface TZPhotoPreviewCell : TZAssetPreviewCell
@property (nonatomic, copy) void (^imageProgressUpdateBlock)(double progress);
@property (nonatomic, strong) TZPhotoPreviewView *previewView;
@property (nonatomic, assign) BOOL allowCrop;
@property (nonatomic, assign) CGRect cropRect;
- (void)recoverSubviews;
@end
@interface TZPhotoPreviewView : UIView
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *imageContainerView;
@property (nonatomic, strong) TZProgressView *progressView;
@property (nonatomic, assign) BOOL allowCrop;
@property (nonatomic, assign) CGRect cropRect;
@property (nonatomic, strong) TZAssetModel *model;
@property (nonatomic, strong) id asset;
@property (nonatomic, copy) void (^singleTapGestureBlock)(void);
@property (nonatomic, copy) void (^imageProgressUpdateBlock)(double progress);
@property (nonatomic, assign) int32_t imageRequestID;
- (void)recoverSubviews;
@end
@class AVPlayer, AVPlayerLayer;
@interface TZVideoPreviewCell : TZAssetPreviewCell
@property (strong, nonatomic) AVPlayer *player;
@property (strong, nonatomic) AVPlayerLayer *playerLayer;
@property (strong, nonatomic) UIButton *playButton;
@property (strong, nonatomic) UIImage *cover;
- (void)pausePlayerAndShowNaviBar;
@end
@interface TZGifPreviewCell : TZAssetPreviewCell
@property (strong, nonatomic) TZPhotoPreviewView *previewView;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 433 |
```objective-c
//
// TZGifPhotoPreviewController.h
// TZImagePickerController
//
// Created by ttouch on 2016/12/13.
//
#import <UIKit/UIKit.h>
@class TZAssetModel;
@interface TZGifPhotoPreviewController : UIViewController
@property (nonatomic, strong) TZAssetModel *model;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 70 |
```objective-c
//
// UIView+Layout.h
//
// Created by on 15/2/24.
//
#import <UIKit/UIKit.h>
typedef enum : NSUInteger {
TZOscillatoryAnimationToBigger,
TZOscillatoryAnimationToSmaller,
} TZOscillatoryAnimationType;
@interface UIView (Layout)
@property (nonatomic) CGFloat tz_left; ///< Shortcut for frame.origin.x.
@property (nonatomic) CGFloat tz_top; ///< Shortcut for frame.origin.y
@property (nonatomic) CGFloat tz_right; ///< Shortcut for frame.origin.x + frame.size.width
@property (nonatomic) CGFloat tz_bottom; ///< Shortcut for frame.origin.y + frame.size.height
@property (nonatomic) CGFloat tz_width; ///< Shortcut for frame.size.width.
@property (nonatomic) CGFloat tz_height; ///< Shortcut for frame.size.height.
@property (nonatomic) CGFloat tz_centerX; ///< Shortcut for center.x
@property (nonatomic) CGFloat tz_centerY; ///< Shortcut for center.y
@property (nonatomic) CGPoint tz_origin; ///< Shortcut for frame.origin.
@property (nonatomic) CGSize tz_size; ///< Shortcut for frame.size.
+ (void)showOscillatoryAnimationWithLayer:(CALayer *)layer type:(TZOscillatoryAnimationType)type;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/UIView+Layout.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 269 |
```objective-c
//
// TZLocationManager.h
// TZImagePickerController
//
// Created by on 2017/06/03.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface TZLocationManager : NSObject
+ (instancetype)manager;
///
- (void)startLocation;
- (void)startLocationWithSuccessBlock:(void (^)(NSArray<CLLocation *> *))successBlock failureBlock:(void (^)(NSError *error))failureBlock;
- (void)startLocationWithGeocoderBlock:(void (^)(NSArray *geocoderArray))geocoderBlock;
- (void)startLocationWithSuccessBlock:(void (^)(NSArray<CLLocation *> *))successBlock failureBlock:(void (^)(NSError *error))failureBlock geocoderBlock:(void (^)(NSArray *geocoderArray))geocoderBlock;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZLocationManager.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 170 |
```objective-c
//
// TZGifPhotoPreviewController.m
// TZImagePickerController
//
// Created by ttouch on 2016/12/13.
//
#import "TZGifPhotoPreviewController.h"
#import "TZImagePickerController.h"
#import "TZAssetModel.h"
#import "UIView+Layout.h"
#import "TZPhotoPreviewCell.h"
#import "TZImageManager.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface TZGifPhotoPreviewController () {
UIView *_toolBar;
UIButton *_doneButton;
UIProgressView *_progress;
TZPhotoPreviewView *_previewView;
UIStatusBarStyle _originStatusBarStyle;
}
@end
@implementation TZGifPhotoPreviewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc) {
self.navigationItem.title = [NSString stringWithFormat:@"GIF %@",tzImagePickerVc.previewBtnTitleStr];
}
[self configPreviewView];
[self configBottomToolBar];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
[UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[UIApplication sharedApplication].statusBarStyle = _originStatusBarStyle;
}
- (void)configPreviewView {
_previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
_previewView.model = self.model;
__weak typeof(self) weakSelf = self;
[_previewView setSingleTapGestureBlock:^{
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf signleTapAction];
}];
[self.view addSubview:_previewView];
}
- (void)configBottomToolBar {
_toolBar = [[UIView alloc] initWithFrame:CGRectZero];
CGFloat rgb = 34 / 255.0;
_toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7];
_doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc) {
[_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
[_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
} else {
[_doneButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal];
[_doneButton setTitleColor:[UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0] forState:UIControlStateNormal];
}
[_toolBar addSubview:_doneButton];
UILabel *byteLabel = [[UILabel alloc] init];
byteLabel.textColor = [UIColor whiteColor];
byteLabel.font = [UIFont systemFontOfSize:13];
byteLabel.frame = CGRectMake(10, 0, 100, 44);
[[TZImageManager manager] getPhotosBytesWithArray:@[_model] completion:^(NSString *totalBytes) {
byteLabel.text = totalBytes;
}];
[_toolBar addSubview:byteLabel];
[self.view addSubview:_toolBar];
if (tzImagePickerVc.gifPreviewPageUIConfigBlock) {
tzImagePickerVc.gifPreviewPageUIConfigBlock(_toolBar, _doneButton);
}
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_previewView.frame = self.view.bounds;
_previewView.scrollView.frame = self.view.bounds;
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44;
_toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight);
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.gifPreviewPageDidLayoutSubviewsBlock) {
tzImagePickerVc.gifPreviewPageDidLayoutSubviewsBlock(_toolBar, _doneButton);
}
}
#pragma mark - Click Event
- (void)signleTapAction {
_toolBar.hidden = !_toolBar.isHidden;
[self.navigationController setNavigationBarHidden:_toolBar.isHidden];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (iOS7Later) {
if (_toolBar.isHidden) {
[UIApplication sharedApplication].statusBarHidden = YES;
} else if (tzImagePickerVc.needShowStatusBar) {
[UIApplication sharedApplication].statusBarHidden = NO;
}
}
}
- (void)doneButtonClick {
if (self.navigationController) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (imagePickerVc.autoDismiss) {
[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod];
}];
} else {
[self callDelegateMethod];
}
} else {
[self dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod];
}];
}
}
- (void)callDelegateMethod {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
UIImage *animatedImage = _previewView.imageView.image;
if ([imagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingGifImage:sourceAssets:)]) {
[imagePickerVc.pickerDelegate imagePickerController:imagePickerVc didFinishPickingGifImage:animatedImage sourceAssets:_model.asset];
}
if (imagePickerVc.didFinishPickingGifImageHandle) {
imagePickerVc.didFinishPickingGifImageHandle(animatedImage,_model.asset);
}
}
#pragma clang diagnostic pop
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,342 |
```objective-c
//
// TZVideoPlayerController.m
// TZImagePickerController
//
// Created by on 16/1/5.
//
#import "TZVideoPlayerController.h"
#import <MediaPlayer/MediaPlayer.h>
#import "UIView+Layout.h"
#import "TZImageManager.h"
#import "TZAssetModel.h"
#import "TZImagePickerController.h"
#import "TZPhotoPreviewController.h"
@interface TZVideoPlayerController () {
AVPlayer *_player;
AVPlayerLayer *_playerLayer;
UIButton *_playButton;
UIImage *_cover;
UIView *_toolBar;
UIButton *_doneButton;
UIProgressView *_progress;
UIStatusBarStyle _originStatusBarStyle;
}
@property (assign, nonatomic) BOOL needShowStatusBar;
@end
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@implementation TZVideoPlayerController
- (void)viewDidLoad {
[super viewDidLoad];
self.needShowStatusBar = ![UIApplication sharedApplication].statusBarHidden;
self.view.backgroundColor = [UIColor blackColor];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc) {
self.navigationItem.title = tzImagePickerVc.previewBtnTitleStr;
}
[self configMoviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:UIApplicationWillResignActiveNotification object:nil];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
[UIApplication sharedApplication].statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[UIApplication sharedApplication].statusBarStyle = _originStatusBarStyle;
}
- (void)configMoviePlayer {
[[TZImageManager manager] getPhotoWithAsset:_model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!isDegraded && photo) {
self->_cover = photo;
self->_doneButton.enabled = YES;
}
}];
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
self->_player = [AVPlayer playerWithPlayerItem:playerItem];
self->_playerLayer = [AVPlayerLayer playerLayerWithPlayer:self->_player];
self->_playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:self->_playerLayer];
[self addProgressObserver];
[self configPlayButton];
[self configBottomToolBar];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:self->_player.currentItem];
});
}];
}
/// Show progressdo it next time / ,
- (void)addProgressObserver{
AVPlayerItem *playerItem = _player.currentItem;
UIProgressView *progress = _progress;
[_player addPeriodicTimeObserverForInterval:CMTimeMake(1.0, 1.0) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
float current = CMTimeGetSeconds(time);
float total = CMTimeGetSeconds([playerItem duration]);
if (current) {
[progress setProgress:(current/total) animated:YES];
}
}];
}
- (void)configPlayButton {
_playButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay"] forState:UIControlStateNormal];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlayHL"] forState:UIControlStateHighlighted];
[_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_playButton];
}
- (void)configBottomToolBar {
_toolBar = [[UIView alloc] initWithFrame:CGRectZero];
CGFloat rgb = 34 / 255.0;
_toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7];
_doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
if (!_cover) {
_doneButton.enabled = NO;
}
[_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc) {
[_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
[_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
} else {
[_doneButton setTitle:[NSBundle tz_localizedStringForKey:@"Done"] forState:UIControlStateNormal];
[_doneButton setTitleColor:[UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0] forState:UIControlStateNormal];
}
[_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled];
[_toolBar addSubview:_doneButton];
[self.view addSubview:_toolBar];
if (tzImagePickerVc.videoPreviewPageUIConfigBlock) {
tzImagePickerVc.videoPreviewPageUIConfigBlock(_playButton, _toolBar, _doneButton);
}
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
CGFloat statusBarAndNaviBarHeight = statusBarHeight + self.navigationController.navigationBar.tz_height;
_playerLayer.frame = self.view.bounds;
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44;
_toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight);
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_playButton.frame = CGRectMake(0, statusBarAndNaviBarHeight, self.view.tz_width, self.view.tz_height - statusBarAndNaviBarHeight - toolBarHeight);
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.videoPreviewPageDidLayoutSubviewsBlock) {
tzImagePickerVc.videoPreviewPageDidLayoutSubviewsBlock(_playButton, _toolBar, _doneButton);
}
}
#pragma mark - Click Event
- (void)playButtonClick {
CMTime currentTime = _player.currentItem.currentTime;
CMTime durationTime = _player.currentItem.duration;
if (_player.rate == 0.0f) {
if (currentTime.value == durationTime.value) [_player.currentItem seekToTime:CMTimeMake(0, 1)];
[_player play];
[self.navigationController setNavigationBarHidden:YES];
_toolBar.hidden = YES;
[_playButton setImage:nil forState:UIControlStateNormal];
if (iOS7Later) [UIApplication sharedApplication].statusBarHidden = YES;
} else {
[self pausePlayerAndShowNaviBar];
}
}
- (void)doneButtonClick {
if (self.navigationController) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (imagePickerVc.autoDismiss) {
[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod];
}];
} else {
[self callDelegateMethod];
}
} else {
[self dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod];
}];
}
}
- (void)callDelegateMethod {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if ([imagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingVideo:sourceAssets:)]) {
[imagePickerVc.pickerDelegate imagePickerController:imagePickerVc didFinishPickingVideo:_cover sourceAssets:_model.asset];
}
if (imagePickerVc.didFinishPickingVideoHandle) {
imagePickerVc.didFinishPickingVideoHandle(_cover,_model.asset);
}
}
#pragma mark - Notification Method
- (void)pausePlayerAndShowNaviBar {
[_player pause];
_toolBar.hidden = NO;
[self.navigationController setNavigationBarHidden:NO];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay"] forState:UIControlStateNormal];
if (self.needShowStatusBar && iOS7Later) {
[UIApplication sharedApplication].statusBarHidden = NO;
}
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma clang diagnostic pop
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,872 |
```objective-c
//
// TZImagePickerController.m
// TZImagePickerController
//
// Created by on 15/12/24.
// version 2.1.9 - 2018.07.12
// githubpath_to_url
#import "TZImagePickerController.h"
#import "TZPhotoPickerController.h"
#import "TZPhotoPreviewController.h"
#import "TZAssetModel.h"
#import "TZAssetCell.h"
#import "UIView+Layout.h"
#import "TZImageManager.h"
#import <sys/utsname.h>
@interface TZImagePickerController () {
NSTimer *_timer;
UILabel *_tipLabel;
UIButton *_settingBtn;
BOOL _pushPhotoPickerVc;
BOOL _didPushPhotoPickerVc;
UIButton *_progressHUD;
UIView *_HUDContainer;
UIActivityIndicatorView *_HUDIndicatorView;
UILabel *_HUDLabel;
UIStatusBarStyle _originStatusBarStyle;
}
/// Default is 4, Use in photos collectionView in TZPhotoPickerController
/// 4, TZPhotoPickerControllercollectionView
@property (nonatomic, assign) NSInteger columnNumber;
@end
@implementation TZImagePickerController
- (instancetype)init {
self = [super init];
if (self) {
self = [self initWithMaxImagesCount:9 delegate:nil];
}
return self;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)viewDidLoad {
[super viewDidLoad];
self.needShowStatusBar = ![UIApplication sharedApplication].statusBarHidden;
self.view.backgroundColor = [UIColor whiteColor];
self.navigationBar.barStyle = UIBarStyleBlack;
self.navigationBar.translucent = YES;
[TZImageManager manager].shouldFixOrientation = NO;
// Default appearance, you can reset these after this method
//
self.oKButtonTitleColorNormal = [UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:1.0];
self.oKButtonTitleColorDisabled = [UIColor colorWithRed:(83/255.0) green:(179/255.0) blue:(17/255.0) alpha:0.5];
if (iOS7Later) {
self.navigationBar.barTintColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:1.0];
self.navigationBar.tintColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO;
if (self.needShowStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
}
}
- (void)setNaviBgColor:(UIColor *)naviBgColor {
_naviBgColor = naviBgColor;
if (iOS7Later) {
self.navigationBar.barTintColor = naviBgColor;
}
}
- (void)setNaviTitleColor:(UIColor *)naviTitleColor {
_naviTitleColor = naviTitleColor;
[self configNaviTitleAppearance];
}
- (void)setNaviTitleFont:(UIFont *)naviTitleFont {
_naviTitleFont = naviTitleFont;
[self configNaviTitleAppearance];
}
- (void)configNaviTitleAppearance {
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
if (self.naviTitleColor) {
textAttrs[NSForegroundColorAttributeName] = self.naviTitleColor;
}
if (self.naviTitleFont) {
textAttrs[NSFontAttributeName] = self.naviTitleFont;
}
self.navigationBar.titleTextAttributes = textAttrs;
}
- (void)setBarItemTextFont:(UIFont *)barItemTextFont {
_barItemTextFont = barItemTextFont;
[self configBarButtonItemAppearance];
}
- (void)setBarItemTextColor:(UIColor *)barItemTextColor {
_barItemTextColor = barItemTextColor;
[self configBarButtonItemAppearance];
}
- (void)setIsStatusBarDefault:(BOOL)isStatusBarDefault {
_isStatusBarDefault = isStatusBarDefault;
if (isStatusBarDefault) {
self.statusBarStyle = iOS7Later ? UIStatusBarStyleDefault : UIStatusBarStyleBlackOpaque;
} else {
self.statusBarStyle = iOS7Later ? UIStatusBarStyleLightContent : UIStatusBarStyleBlackOpaque;
}
}
- (void)configBarButtonItemAppearance {
UIBarButtonItem *barItem;
if (@available(iOS 9, *)) {
barItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
} else {
barItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
}
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName] = self.barItemTextColor;
textAttrs[NSFontAttributeName] = self.barItemTextFont;
[barItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_originStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
[UIApplication sharedApplication].statusBarStyle = self.statusBarStyle;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[UIApplication sharedApplication].statusBarStyle = _originStatusBarStyle;
[self hideProgressHUD];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return self.statusBarStyle;
}
- (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount delegate:(id<TZImagePickerControllerDelegate>)delegate {
return [self initWithMaxImagesCount:maxImagesCount columnNumber:4 delegate:delegate pushPhotoPickerVc:YES];
}
- (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount columnNumber:(NSInteger)columnNumber delegate:(id<TZImagePickerControllerDelegate>)delegate {
return [self initWithMaxImagesCount:maxImagesCount columnNumber:columnNumber delegate:delegate pushPhotoPickerVc:YES];
}
- (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount columnNumber:(NSInteger)columnNumber delegate:(id<TZImagePickerControllerDelegate>)delegate pushPhotoPickerVc:(BOOL)pushPhotoPickerVc {
_pushPhotoPickerVc = pushPhotoPickerVc;
TZAlbumPickerController *albumPickerVc = [[TZAlbumPickerController alloc] init];
albumPickerVc.isFirstAppear = YES;
albumPickerVc.columnNumber = columnNumber;
self = [super initWithRootViewController:albumPickerVc];
if (self) {
self.maxImagesCount = maxImagesCount > 0 ? maxImagesCount : 9; // Default is 9 / 9
self.pickerDelegate = delegate;
self.selectedAssets = [NSMutableArray array];
// Allow user picking original photo and video, you also can set No after this method
// , NO
self.allowPickingOriginalPhoto = YES;
self.allowPickingVideo = YES;
self.allowPickingImage = YES;
self.allowTakePicture = YES;
self.allowTakeVideo = YES;
self.videoMaximumDuration = 10 * 60;
self.sortAscendingByModificationDate = YES;
self.autoDismiss = YES;
self.columnNumber = columnNumber;
[self configDefaultSetting];
if (![[TZImageManager manager] authorizationStatusAuthorized]) {
_tipLabel = [[UILabel alloc] init];
_tipLabel.frame = CGRectMake(8, 120, self.view.tz_width - 16, 60);
_tipLabel.textAlignment = NSTextAlignmentCenter;
_tipLabel.numberOfLines = 0;
_tipLabel.font = [UIFont systemFontOfSize:16];
_tipLabel.textColor = [UIColor blackColor];
NSDictionary *infoDict = [TZCommonTools tz_getInfoDictionary];
NSString *appName = [infoDict valueForKey:@"CFBundleDisplayName"];
if (!appName) appName = [infoDict valueForKey:@"CFBundleName"];
NSString *tipText = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Allow %@ to access your album in \"Settings -> Privacy -> Photos\""],appName];
_tipLabel.text = tipText;
[self.view addSubview:_tipLabel];
if (iOS8Later) {
_settingBtn = [UIButton buttonWithType:UIButtonTypeSystem];
[_settingBtn setTitle:self.settingBtnTitleStr forState:UIControlStateNormal];
_settingBtn.frame = CGRectMake(0, 180, self.view.tz_width, 44);
_settingBtn.titleLabel.font = [UIFont systemFontOfSize:18];
[_settingBtn addTarget:self action:@selector(settingBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_settingBtn];
}
if ([TZImageManager authorizationStatus] == 0) {
_timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(observeAuthrizationStatusChange) userInfo:nil repeats:NO];
}
} else {
[self pushPhotoPickerVc];
}
}
return self;
}
/// This init method just for previewing photos /
- (instancetype)initWithSelectedAssets:(NSMutableArray *)selectedAssets selectedPhotos:(NSMutableArray *)selectedPhotos index:(NSInteger)index{
TZPhotoPreviewController *previewVc = [[TZPhotoPreviewController alloc] init];
self = [super initWithRootViewController:previewVc];
if (self) {
self.selectedAssets = [NSMutableArray arrayWithArray:selectedAssets];
self.allowPickingOriginalPhoto = self.allowPickingOriginalPhoto;
[self configDefaultSetting];
previewVc.photos = [NSMutableArray arrayWithArray:selectedPhotos];
previewVc.currentIndex = index;
__weak typeof(self) weakSelf = self;
[previewVc setDoneButtonClickBlockWithPreviewType:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf dismissViewControllerAnimated:YES completion:^{
if (!strongSelf) return;
if (strongSelf.didFinishPickingPhotosHandle) {
strongSelf.didFinishPickingPhotosHandle(photos,assets,isSelectOriginalPhoto);
}
}];
}];
}
return self;
}
/// This init method for crop photo /
- (instancetype)initCropTypeWithAsset:(id)asset photo:(UIImage *)photo completion:(void (^)(UIImage *cropImage,id asset))completion {
TZPhotoPreviewController *previewVc = [[TZPhotoPreviewController alloc] init];
self = [super initWithRootViewController:previewVc];
if (self) {
self.maxImagesCount = 1;
self.allowCrop = YES;
self.selectedAssets = [NSMutableArray arrayWithArray:@[asset]];
[self configDefaultSetting];
previewVc.photos = [NSMutableArray arrayWithArray:@[photo]];
previewVc.isCropImage = YES;
previewVc.currentIndex = 0;
__weak typeof(self) weakSelf = self;
[previewVc setDoneButtonClickBlockCropMode:^(UIImage *cropImage, id asset) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf dismissViewControllerAnimated:YES completion:^{
if (completion) {
completion(cropImage,asset);
}
}];
}];
}
return self;
}
- (void)configDefaultSetting {
self.timeout = 15;
self.photoWidth = 828.0;
self.photoPreviewMaxWidth = 600;
self.naviTitleColor = [UIColor whiteColor];
self.naviTitleFont = [UIFont systemFontOfSize:17];
self.barItemTextFont = [UIFont systemFontOfSize:15];
self.barItemTextColor = [UIColor whiteColor];
self.allowPreview = YES;
self.notScaleImage = NO;
self.statusBarStyle = UIStatusBarStyleLightContent;
self.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
self.allowCameraLocation = YES;
self.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
[self configDefaultBtnTitle];
CGFloat cropViewWH = MIN(self.view.tz_width, self.view.tz_height) / 3 * 2;
self.cropRect = CGRectMake((self.view.tz_width - cropViewWH) / 2, (self.view.tz_height - cropViewWH) / 2, cropViewWH, cropViewWH);
}
- (void)configDefaultImageName {
self.takePictureImageName = @"takePicture80";
self.photoSelImageName = @"photo_sel_photoPickerVc";
self.photoDefImageName = @"photo_def_photoPickerVc";
self.photoNumberIconImage = [self createImageWithColor:nil size:CGSizeMake(48, 48) radius:24]; // @"photo_number_icon";
self.photoPreviewOriginDefImageName = @"preview_original_def";
self.photoOriginDefImageName = @"photo_original_def";
self.photoOriginSelImageName = @"photo_original_sel";
}
- (void)setTakePictureImageName:(NSString *)takePictureImageName {
_takePictureImageName = takePictureImageName;
_takePictureImage = [UIImage imageNamedFromMyBundle:takePictureImageName];
}
- (void)setPhotoSelImageName:(NSString *)photoSelImageName {
_photoSelImageName = photoSelImageName;
_photoSelImage = [UIImage imageNamedFromMyBundle:photoSelImageName];
}
- (void)setPhotoDefImageName:(NSString *)photoDefImageName {
_photoDefImageName = photoDefImageName;
_photoDefImage = [UIImage imageNamedFromMyBundle:photoDefImageName];
}
- (void)setPhotoNumberIconImageName:(NSString *)photoNumberIconImageName {
_photoNumberIconImageName = photoNumberIconImageName;
_photoNumberIconImage = [UIImage imageNamedFromMyBundle:photoNumberIconImageName];
}
- (void)setPhotoPreviewOriginDefImageName:(NSString *)photoPreviewOriginDefImageName {
_photoPreviewOriginDefImageName = photoPreviewOriginDefImageName;
_photoPreviewOriginDefImage = [UIImage imageNamedFromMyBundle:photoPreviewOriginDefImageName];
}
- (void)setPhotoOriginDefImageName:(NSString *)photoOriginDefImageName {
_photoOriginDefImageName = photoOriginDefImageName;
_photoOriginDefImage = [UIImage imageNamedFromMyBundle:photoOriginDefImageName];
}
- (void)setPhotoOriginSelImageName:(NSString *)photoOriginSelImageName {
_photoOriginSelImageName = photoOriginSelImageName;
_photoOriginSelImage = [UIImage imageNamedFromMyBundle:photoOriginSelImageName];
}
- (void)setIconThemeColor:(UIColor *)iconThemeColor {
_iconThemeColor = iconThemeColor;
[self configDefaultImageName];
}
- (void)configDefaultBtnTitle {
self.doneBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Done"];
self.cancelBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Cancel"];
self.previewBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Preview"];
self.fullImageBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Full image"];
self.settingBtnTitleStr = [NSBundle tz_localizedStringForKey:@"Setting"];
self.processHintStr = [NSBundle tz_localizedStringForKey:@"Processing..."];
}
- (void)setShowSelectedIndex:(BOOL)showSelectedIndex {
_showSelectedIndex = showSelectedIndex;
if (showSelectedIndex) {
self.photoSelImage = [self createImageWithColor:nil size:CGSizeMake(48, 48) radius:24];
}
[TZImagePickerConfig sharedInstance].showSelectedIndex = showSelectedIndex;
}
- (void)setShowPhotoCannotSelectLayer:(BOOL)showPhotoCannotSelectLayer {
_showPhotoCannotSelectLayer = showPhotoCannotSelectLayer;
[TZImagePickerConfig sharedInstance].showPhotoCannotSelectLayer = showPhotoCannotSelectLayer;
}
- (void)setNotScaleImage:(BOOL)notScaleImage {
_notScaleImage = notScaleImage;
[TZImagePickerConfig sharedInstance].notScaleImage = notScaleImage;
}
- (void)observeAuthrizationStatusChange {
[_timer invalidate];
_timer = nil;
if ([TZImageManager authorizationStatus] == 0) {
_timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(observeAuthrizationStatusChange) userInfo:nil repeats:NO];
}
if ([[TZImageManager manager] authorizationStatusAuthorized]) {
[_tipLabel removeFromSuperview];
[_settingBtn removeFromSuperview];
[self pushPhotoPickerVc];
TZAlbumPickerController *albumPickerVc = (TZAlbumPickerController *)self.visibleViewController;
if ([albumPickerVc isKindOfClass:[TZAlbumPickerController class]]) {
[albumPickerVc configTableView];
}
}
}
- (void)pushPhotoPickerVc {
_didPushPhotoPickerVc = NO;
// 1.6.8 push_pushPhotoPickerVcNO,push
if (!_didPushPhotoPickerVc && _pushPhotoPickerVc) {
TZPhotoPickerController *photoPickerVc = [[TZPhotoPickerController alloc] init];
photoPickerVc.isFirstAppear = YES;
photoPickerVc.columnNumber = self.columnNumber;
[[TZImageManager manager] getCameraRollAlbum:self.allowPickingVideo allowPickingImage:self.allowPickingImage needFetchAssets:NO completion:^(TZAlbumModel *model) {
photoPickerVc.model = model;
[self pushViewController:photoPickerVc animated:YES];
self->_didPushPhotoPickerVc = YES;
}];
}
}
- (id)showAlertWithTitle:(NSString *)title {
if (iOS8Later) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:[NSBundle tz_localizedStringForKey:@"OK"] style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
return alertController;
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:nil delegate:nil cancelButtonTitle:[NSBundle tz_localizedStringForKey:@"OK"] otherButtonTitles:nil, nil];
[alertView show];
return alertView;
}
}
- (void)hideAlertView:(id)alertView {
if ([alertView isKindOfClass:[UIAlertController class]]) {
UIAlertController *alertC = alertView;
[alertC dismissViewControllerAnimated:YES completion:nil];
} else if ([alertView isKindOfClass:[UIAlertView class]]) {
UIAlertView *alertV = alertView;
[alertV dismissWithClickedButtonIndex:0 animated:YES];
}
alertView = nil;
}
- (void)showProgressHUD {
if (!_progressHUD) {
_progressHUD = [UIButton buttonWithType:UIButtonTypeCustom];
[_progressHUD setBackgroundColor:[UIColor clearColor]];
_HUDContainer = [[UIView alloc] init];
_HUDContainer.layer.cornerRadius = 8;
_HUDContainer.clipsToBounds = YES;
_HUDContainer.backgroundColor = [UIColor darkGrayColor];
_HUDContainer.alpha = 0.7;
_HUDIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
_HUDLabel = [[UILabel alloc] init];
_HUDLabel.textAlignment = NSTextAlignmentCenter;
_HUDLabel.text = self.processHintStr;
_HUDLabel.font = [UIFont systemFontOfSize:15];
_HUDLabel.textColor = [UIColor whiteColor];
[_HUDContainer addSubview:_HUDLabel];
[_HUDContainer addSubview:_HUDIndicatorView];
[_progressHUD addSubview:_HUDContainer];
}
[_HUDIndicatorView startAnimating];
[[UIApplication sharedApplication].keyWindow addSubview:_progressHUD];
// if over time, dismiss HUD automatic
__weak typeof(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.timeout * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf hideProgressHUD];
});
}
- (void)hideProgressHUD {
if (_progressHUD) {
[_HUDIndicatorView stopAnimating];
[_progressHUD removeFromSuperview];
}
}
- (void)setMaxImagesCount:(NSInteger)maxImagesCount {
_maxImagesCount = maxImagesCount;
if (maxImagesCount > 1) {
_showSelectBtn = YES;
_allowCrop = NO;
}
}
- (void)setShowSelectBtn:(BOOL)showSelectBtn {
_showSelectBtn = showSelectBtn;
// showSelectBtnNO
if (!showSelectBtn && _maxImagesCount > 1) {
_showSelectBtn = YES;
}
}
- (void)setAllowCrop:(BOOL)allowCrop {
_allowCrop = _maxImagesCount > 1 ? NO : allowCrop;
if (allowCrop) { // GIF
self.allowPickingOriginalPhoto = NO;
self.allowPickingGif = NO;
}
}
- (void)setCircleCropRadius:(NSInteger)circleCropRadius {
_circleCropRadius = circleCropRadius;
self.cropRect = CGRectMake(self.view.tz_width / 2 - circleCropRadius, self.view.tz_height / 2 - _circleCropRadius, _circleCropRadius * 2, _circleCropRadius * 2);
}
- (void)setCropRect:(CGRect)cropRect {
_cropRect = cropRect;
_cropRectPortrait = cropRect;
CGFloat widthHeight = cropRect.size.width;
_cropRectLandscape = CGRectMake((self.view.tz_height - widthHeight) / 2, cropRect.origin.x, widthHeight, widthHeight);
}
- (void)setTimeout:(NSInteger)timeout {
_timeout = timeout;
if (timeout < 5) {
_timeout = 5;
} else if (_timeout > 60) {
_timeout = 60;
}
}
- (void)setPickerDelegate:(id<TZImagePickerControllerDelegate>)pickerDelegate {
_pickerDelegate = pickerDelegate;
[TZImageManager manager].pickerDelegate = pickerDelegate;
}
- (void)setColumnNumber:(NSInteger)columnNumber {
_columnNumber = columnNumber;
if (columnNumber <= 2) {
_columnNumber = 2;
} else if (columnNumber >= 6) {
_columnNumber = 6;
}
TZAlbumPickerController *albumPickerVc = [self.childViewControllers firstObject];
albumPickerVc.columnNumber = _columnNumber;
[TZImageManager manager].columnNumber = _columnNumber;
}
- (void)setMinPhotoWidthSelectable:(NSInteger)minPhotoWidthSelectable {
_minPhotoWidthSelectable = minPhotoWidthSelectable;
[TZImageManager manager].minPhotoWidthSelectable = minPhotoWidthSelectable;
}
- (void)setMinPhotoHeightSelectable:(NSInteger)minPhotoHeightSelectable {
_minPhotoHeightSelectable = minPhotoHeightSelectable;
[TZImageManager manager].minPhotoHeightSelectable = minPhotoHeightSelectable;
}
- (void)setHideWhenCanNotSelect:(BOOL)hideWhenCanNotSelect {
_hideWhenCanNotSelect = hideWhenCanNotSelect;
[TZImageManager manager].hideWhenCanNotSelect = hideWhenCanNotSelect;
}
- (void)setPhotoPreviewMaxWidth:(CGFloat)photoPreviewMaxWidth {
_photoPreviewMaxWidth = photoPreviewMaxWidth;
if (photoPreviewMaxWidth > 800) {
_photoPreviewMaxWidth = 800;
} else if (photoPreviewMaxWidth < 500) {
_photoPreviewMaxWidth = 500;
}
[TZImageManager manager].photoPreviewMaxWidth = _photoPreviewMaxWidth;
}
- (void)setPhotoWidth:(CGFloat)photoWidth {
_photoWidth = photoWidth;
[TZImageManager manager].photoWidth = photoWidth;
}
- (void)setSelectedAssets:(NSMutableArray *)selectedAssets {
_selectedAssets = selectedAssets;
_selectedModels = [NSMutableArray array];
_selectedAssetIds = [NSMutableArray array];
for (id asset in selectedAssets) {
TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:[[TZImageManager manager] getAssetType:asset]];
model.isSelected = YES;
[self addSelectedModel:model];
}
}
- (void)setAllowPickingImage:(BOOL)allowPickingImage {
_allowPickingImage = allowPickingImage;
[TZImagePickerConfig sharedInstance].allowPickingImage = allowPickingImage;
if (!allowPickingImage) {
_allowTakePicture = NO;
}
}
- (void)setAllowPickingVideo:(BOOL)allowPickingVideo {
_allowPickingVideo = allowPickingVideo;
[TZImagePickerConfig sharedInstance].allowPickingVideo = allowPickingVideo;
if (!allowPickingVideo) {
_allowTakeVideo = NO;
}
}
- (void)setPreferredLanguage:(NSString *)preferredLanguage {
_preferredLanguage = preferredLanguage;
[TZImagePickerConfig sharedInstance].preferredLanguage = preferredLanguage;
[self configDefaultBtnTitle];
}
- (void)setLanguageBundle:(NSBundle *)languageBundle {
_languageBundle = languageBundle;
[TZImagePickerConfig sharedInstance].languageBundle = languageBundle;
[self configDefaultBtnTitle];
}
- (void)setSortAscendingByModificationDate:(BOOL)sortAscendingByModificationDate {
_sortAscendingByModificationDate = sortAscendingByModificationDate;
[TZImageManager manager].sortAscendingByModificationDate = sortAscendingByModificationDate;
}
- (void)settingBtnClick {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (iOS7Later) {
viewController.automaticallyAdjustsScrollViewInsets = NO;
}
[super pushViewController:viewController animated:animated];
}
- (void)dealloc {
// NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}
- (void)addSelectedModel:(TZAssetModel *)model {
[_selectedModels addObject:model];
NSString *assetId = [[TZImageManager manager] getAssetIdentifier:model.asset];
[_selectedAssetIds addObject:assetId];
}
- (void)removeSelectedModel:(TZAssetModel *)model {
[_selectedModels removeObject:model];
NSString *assetId = [[TZImageManager manager] getAssetIdentifier:model.asset];
[_selectedAssetIds removeObject:assetId];
}
- (UIImage *)createImageWithColor:(UIColor *)color size:(CGSize)size radius:(CGFloat)radius {
if (!color) {
color = self.iconThemeColor;
}
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius];
CGContextAddPath(context, path.CGPath);
CGContextFillPath(context);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
#pragma mark - UIContentContainer
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[self willInterfaceOrientionChange];
if (size.width > size.height) {
_cropRect = _cropRectLandscape;
} else {
_cropRect = _cropRectPortrait;
}
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self willInterfaceOrientionChange];
if (toInterfaceOrientation >= 3) {
_cropRect = _cropRectLandscape;
} else {
_cropRect = _cropRectPortrait;
}
}
- (void)willInterfaceOrientionChange {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.02 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (![UIApplication sharedApplication].statusBarHidden) {
if (iOS7Later && self.needShowStatusBar) [UIApplication sharedApplication].statusBarHidden = NO;
}
});
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_HUDContainer.frame = CGRectMake((self.view.tz_width - 120) / 2, (self.view.tz_height - 90) / 2, 120, 90);
_HUDIndicatorView.frame = CGRectMake(45, 15, 30, 30);
_HUDLabel.frame = CGRectMake(0,40, 120, 50);
}
#pragma mark - Public
- (void)cancelButtonClick {
if (self.autoDismiss) {
[self dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod];
}];
} else {
[self callDelegateMethod];
}
}
- (void)callDelegateMethod {
if ([self.pickerDelegate respondsToSelector:@selector(tz_imagePickerControllerDidCancel:)]) {
[self.pickerDelegate tz_imagePickerControllerDidCancel:self];
}
if (self.imagePickerControllerDidCancelHandle) {
self.imagePickerControllerDidCancelHandle();
}
}
@end
@interface TZAlbumPickerController ()<UITableViewDataSource,UITableViewDelegate> {
UITableView *_tableView;
}
@property (nonatomic, strong) NSMutableArray *albumArr;
@end
@implementation TZAlbumPickerController
- (void)viewDidLoad {
[super viewDidLoad];
self.isFirstAppear = YES;
self.view.backgroundColor = [UIColor whiteColor];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:imagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:imagePickerVc action:@selector(cancelButtonClick)];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc hideProgressHUD];
if (imagePickerVc.allowPickingImage) {
self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Photos"];
} else if (imagePickerVc.allowPickingVideo) {
self.navigationItem.title = [NSBundle tz_localizedStringForKey:@"Videos"];
}
if (self.isFirstAppear && !imagePickerVc.navLeftBarButtonSettingBlock) {
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Back"] style:UIBarButtonItemStylePlain target:nil action:nil];
}
[self configTableView];
}
- (void)configTableView {
if (![[TZImageManager manager] authorizationStatusAuthorized]) {
return;
}
if (self.isFirstAppear) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showProgressHUD];
}
dispatch_async(dispatch_get_global_queue(0, 0), ^{
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[[TZImageManager manager] getAllAlbums:imagePickerVc.allowPickingVideo allowPickingImage:imagePickerVc.allowPickingImage needFetchAssets:!self.isFirstAppear completion:^(NSArray<TZAlbumModel *> *models) {
dispatch_async(dispatch_get_main_queue(), ^{
self->_albumArr = [NSMutableArray arrayWithArray:models];
for (TZAlbumModel *albumModel in self->_albumArr) {
albumModel.selectedModels = imagePickerVc.selectedModels;
}
[imagePickerVc hideProgressHUD];
if (self.isFirstAppear) {
self.isFirstAppear = NO;
[self configTableView];
}
if (!self->_tableView) {
self->_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self->_tableView.rowHeight = 70;
self->_tableView.tableFooterView = [[UIView alloc] init];
self->_tableView.dataSource = self;
self->_tableView.delegate = self;
[self->_tableView registerClass:[TZAlbumCell class] forCellReuseIdentifier:@"TZAlbumCell"];
[self.view addSubview:self->_tableView];
} else {
[self->_tableView reloadData];
}
});
}];
});
}
- (void)dealloc {
// NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGFloat top = 0;
CGFloat tableViewHeight = 0;
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
tableViewHeight = self.view.tz_height - top;
} else {
tableViewHeight = self.view.tz_height;
}
_tableView.frame = CGRectMake(0, top, self.view.tz_width, tableViewHeight);
}
#pragma mark - UITableViewDataSource && Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _albumArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TZAlbumCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TZAlbumCell"];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
cell.albumCellDidLayoutSubviewsBlock = imagePickerVc.albumCellDidLayoutSubviewsBlock;
cell.albumCellDidSetModelBlock = imagePickerVc.albumCellDidSetModelBlock;
cell.selectedCountButton.backgroundColor = imagePickerVc.iconThemeColor;
cell.model = _albumArr[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TZPhotoPickerController *photoPickerVc = [[TZPhotoPickerController alloc] init];
photoPickerVc.columnNumber = self.columnNumber;
TZAlbumModel *model = _albumArr[indexPath.row];
photoPickerVc.model = model;
[self.navigationController pushViewController:photoPickerVc animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
#pragma clang diagnostic pop
@end
@implementation UIImage (MyBundle)
+ (UIImage *)imageNamedFromMyBundle:(NSString *)name {
NSBundle *imageBundle = [NSBundle tz_imagePickerBundle];
name = [name stringByAppendingString:@"@2x"];
NSString *imagePath = [imageBundle pathForResource:name ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
if (!image) {
//
name = [name stringByReplacingOccurrencesOfString:@"@2x" withString:@""];
image = [UIImage imageNamed:name];
}
return image;
}
@end
@implementation NSString (TzExtension)
- (BOOL)tz_containsString:(NSString *)string {
if (iOS8Later) {
return [self containsString:string];
} else {
NSRange range = [self rangeOfString:string];
return range.location != NSNotFound;
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (CGSize)tz_calculateSizeWithAttributes:(NSDictionary *)attributes maxSize:(CGSize)maxSize {
CGSize size;
if (iOS7Later) {
size = [self boundingRectWithSize:maxSize options:NSStringDrawingUsesFontLeading attributes:attributes context:nil].size;
} else {
size = [self sizeWithFont:attributes[NSFontAttributeName] constrainedToSize:maxSize];
}
return size;
}
#pragma clang diagnostic pop
@end
@implementation TZCommonTools
+ (BOOL)tz_isIPhoneX {
struct utsname systemInfo;
uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
if ([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"]) {
//
return (CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812)) ||
CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(812, 375)));
}
// iPhone10,6iPhoneX hegelsupath_to_url
BOOL isIPhoneX = [platform isEqualToString:@"iPhone10,3"] || [platform isEqualToString:@"iPhone10,6"];
return isIPhoneX;
}
+ (CGFloat)tz_statusBarHeight {
return [self tz_isIPhoneX] ? 44 : 20;
}
// Info.plist
+ (NSDictionary *)tz_getInfoDictionary {
NSDictionary *infoDict = [NSBundle mainBundle].localizedInfoDictionary;
if (!infoDict || !infoDict.count) {
infoDict = [NSBundle mainBundle].infoDictionary;
}
if (!infoDict || !infoDict.count) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
infoDict = [NSDictionary dictionaryWithContentsOfFile:path];
}
return infoDict ? infoDict : @{};
}
@end
@implementation TZImagePickerConfig
+ (instancetype)sharedInstance {
static dispatch_once_t onceToken;
static TZImagePickerConfig *config = nil;
dispatch_once(&onceToken, ^{
if (config == nil) {
config = [[TZImagePickerConfig alloc] init];
config.preferredLanguage = nil;
config.gifPreviewMaxImagesCount = 200;
}
});
return config;
}
- (void)setPreferredLanguage:(NSString *)preferredLanguage {
_preferredLanguage = preferredLanguage;
if (!preferredLanguage || !preferredLanguage.length) {
preferredLanguage = [NSLocale preferredLanguages].firstObject;
}
if ([preferredLanguage rangeOfString:@"zh-Hans"].location != NSNotFound) {
preferredLanguage = @"zh-Hans";
} else if ([preferredLanguage rangeOfString:@"zh-Hant"].location != NSNotFound) {
preferredLanguage = @"zh-Hant";
} else if ([preferredLanguage rangeOfString:@"vi"].location != NSNotFound) {
preferredLanguage = @"vi";
} else {
preferredLanguage = @"en";
}
_languageBundle = [NSBundle bundleWithPath:[[NSBundle tz_imagePickerBundle] pathForResource:preferredLanguage ofType:@"lproj"]];
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImagePickerController.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 8,109 |
```objective-c
//
// NSBundle+TZImagePicker.h
// TZImagePickerController
//
// Created by on 16/08/18.
//
#import <UIKit/UIKit.h>
@interface NSBundle (TZImagePicker)
+ (NSBundle *)tz_imagePickerBundle;
+ (NSString *)tz_localizedStringForKey:(NSString *)key value:(NSString *)value;
+ (NSString *)tz_localizedStringForKey:(NSString *)key;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/NSBundle+TZImagePicker.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 91 |
```objective-c
//
// TZLocationManager.m
// TZImagePickerController
//
// Created by on 2017/06/03.
//
#import "TZLocationManager.h"
#import "TZImagePickerController.h"
@interface TZLocationManager ()<CLLocationManagerDelegate>
@property (nonatomic, strong) CLLocationManager *locationManager;
/// block
@property (nonatomic, copy) void (^successBlock)(NSArray<CLLocation *> *);
/// block
@property (nonatomic, copy) void (^geocodeBlock)(NSArray *geocodeArray);
/// block
@property (nonatomic, copy) void (^failureBlock)(NSError *error);
@end
@implementation TZLocationManager
+ (instancetype)manager {
static TZLocationManager *manager;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [[self alloc] init];
manager.locationManager = [[CLLocationManager alloc] init];
manager.locationManager.delegate = manager;
if (iOS8Later) {
[manager.locationManager requestWhenInUseAuthorization];
}
});
return manager;
}
- (void)startLocation {
[self startLocationWithSuccessBlock:nil failureBlock:nil geocoderBlock:nil];
}
- (void)startLocationWithSuccessBlock:(void (^)(NSArray<CLLocation *> *))successBlock failureBlock:(void (^)(NSError *error))failureBlock {
[self startLocationWithSuccessBlock:successBlock failureBlock:failureBlock geocoderBlock:nil];
}
- (void)startLocationWithGeocoderBlock:(void (^)(NSArray *geocoderArray))geocoderBlock {
[self startLocationWithSuccessBlock:nil failureBlock:nil geocoderBlock:geocoderBlock];
}
- (void)startLocationWithSuccessBlock:(void (^)(NSArray<CLLocation *> *))successBlock failureBlock:(void (^)(NSError *error))failureBlock geocoderBlock:(void (^)(NSArray *geocoderArray))geocoderBlock {
[self.locationManager startUpdatingLocation];
_successBlock = successBlock;
_geocodeBlock = geocoderBlock;
_failureBlock = failureBlock;
}
#pragma mark - CLLocationManagerDelegate
///
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
[manager stopUpdatingLocation];
if (_successBlock) {
_successBlock(locations);
}
if (_geocodeBlock && locations.count) {
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:[locations firstObject] completionHandler:^(NSArray *array, NSError *error) {
self->_geocodeBlock(array);
}];
}
}
///
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@", : %@",error);
switch([error code]) {
case kCLErrorDenied: { //
} break;
default: break;
}
if (_failureBlock) {
_failureBlock(error);
}
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZLocationManager.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 618 |
```objective-c
//
// TZVideoPlayerController.h
// TZImagePickerController
//
// Created by on 16/1/5.
//
#import <UIKit/UIKit.h>
@class TZAssetModel;
@interface TZVideoPlayerController : UIViewController
@property (nonatomic, strong) TZAssetModel *model;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZVideoPlayerController.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 63 |
```objective-c
//
// TZProgressView.m
// TZImagePickerController
//
// Created by ttouch on 2016/12/6.
//
#import "TZProgressView.h"
@interface TZProgressView ()
@property (nonatomic, strong) CAShapeLayer *progressLayer;
@end
@implementation TZProgressView
- (instancetype)init {
self = [super init];
if (self) {
self.backgroundColor = [UIColor clearColor];
_progressLayer = [CAShapeLayer layer];
_progressLayer.fillColor = [[UIColor clearColor] CGColor];
_progressLayer.strokeColor = [[UIColor whiteColor] CGColor];
_progressLayer.opacity = 1;
_progressLayer.lineCap = kCALineCapRound;
_progressLayer.lineWidth = 5;
[_progressLayer setShadowColor:[UIColor blackColor].CGColor];
[_progressLayer setShadowOffset:CGSizeMake(1, 1)];
[_progressLayer setShadowOpacity:0.5];
[_progressLayer setShadowRadius:2];
}
return self;
}
- (void)drawRect:(CGRect)rect {
CGPoint center = CGPointMake(rect.size.width / 2, rect.size.height / 2);
CGFloat radius = rect.size.width / 2;
CGFloat startA = - M_PI_2;
CGFloat endA = - M_PI_2 + M_PI * 2 * _progress;
_progressLayer.frame = self.bounds;
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startA endAngle:endA clockwise:YES];
_progressLayer.path =[path CGPath];
[_progressLayer removeFromSuperlayer];
[self.layer addSublayer:_progressLayer];
}
- (void)setProgress:(double)progress {
_progress = progress;
[self setNeedsDisplay];
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZProgressView.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 389 |
```objective-c
//
// TZPhotoPreviewController.h
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import <UIKit/UIKit.h>
@interface TZPhotoPreviewController : UIViewController
@property (nonatomic, strong) NSMutableArray *models; ///< All photo models /
@property (nonatomic, strong) NSMutableArray *photos; ///< All photos /
@property (nonatomic, assign) NSInteger currentIndex; ///< Index of the photo user click /
@property (nonatomic, assign) BOOL isSelectOriginalPhoto; ///< If YES,return original photo /
@property (nonatomic, assign) BOOL isCropImage;
/// Return the new selected photos /
@property (nonatomic, copy) void (^backButtonClickBlock)(BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^doneButtonClickBlock)(BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^doneButtonClickBlockCropMode)(UIImage *cropedImage,id asset);
@property (nonatomic, copy) void (^doneButtonClickBlockWithPreviewType)(NSArray<UIImage *> *photos,NSArray *assets,BOOL isSelectOriginalPhoto);
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 230 |
```objective-c
//
// TZAssetModel.h
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef enum : NSUInteger {
TZAssetModelMediaTypePhoto = 0,
TZAssetModelMediaTypeLivePhoto,
TZAssetModelMediaTypePhotoGif,
TZAssetModelMediaTypeVideo,
TZAssetModelMediaTypeAudio
} TZAssetModelMediaType;
@class PHAsset;
@interface TZAssetModel : NSObject
@property (nonatomic, strong) id asset; ///< PHAsset or ALAsset
@property (nonatomic, assign) BOOL isSelected; ///< The select status of a photo, default is No
@property (nonatomic, assign) TZAssetModelMediaType type;
@property (assign, nonatomic) BOOL needOscillatoryAnimation;
@property (nonatomic, copy) NSString *timeLength;
@property (strong, nonatomic) UIImage *cachedImage;
/// Init a photo dataModel With a asset
/// PHAsset/ALAsset
+ (instancetype)modelWithAsset:(id)asset type:(TZAssetModelMediaType)type;
+ (instancetype)modelWithAsset:(id)asset type:(TZAssetModelMediaType)type timeLength:(NSString *)timeLength;
@end
@class PHFetchResult;
@interface TZAlbumModel : NSObject
@property (nonatomic, strong) NSString *name; ///< The album name
@property (nonatomic, assign) NSInteger count; ///< Count of photos the album contain
@property (nonatomic, strong) id result; ///< PHFetchResult<PHAsset> or ALAssetsGroup<ALAsset>
@property (nonatomic, strong) NSArray *models;
@property (nonatomic, strong) NSArray *selectedModels;
@property (nonatomic, assign) NSUInteger selectedCount;
@property (nonatomic, assign) BOOL isCameraRoll;
- (void)setResult:(id)result needFetchAssets:(BOOL)needFetchAssets;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZAssetModel.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 393 |
```objective-c
//
// TZAssetCell.m
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import "TZAssetCell.h"
#import "TZAssetModel.h"
#import "UIView+Layout.h"
#import "TZImageManager.h"
#import "TZImagePickerController.h"
#import "TZProgressView.h"
@interface TZAssetCell ()
@property (weak, nonatomic) UIImageView *imageView; // The photo /
@property (weak, nonatomic) UIImageView *selectImageView;
@property (weak, nonatomic) UILabel *indexLabel;
@property (weak, nonatomic) UIView *bottomView;
@property (weak, nonatomic) UILabel *timeLength;
@property (nonatomic, weak) UIImageView *videoImgView;
@property (nonatomic, strong) TZProgressView *progressView;
@property (nonatomic, assign) int32_t bigImageRequestID;
@end
@implementation TZAssetCell
- (void)setModel:(TZAssetModel *)model {
_model = model;
if (iOS8Later) {
self.representedAssetIdentifier = [[TZImageManager manager] getAssetIdentifier:model.asset];
}
if (self.useCachedImage && model.cachedImage) {
self.imageView.image = model.cachedImage;
} else {
self.model.cachedImage = nil;
int32_t imageRequestID = [[TZImageManager manager] getPhotoWithAsset:model.asset photoWidth:self.tz_width completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
// Set the cell's thumbnail image if it's still showing the same asset.
if (!iOS8Later) {
self.imageView.image = photo;
self.model.cachedImage = photo;
[self hideProgressView];
return;
}
if ([self.representedAssetIdentifier isEqualToString:[[TZImageManager manager] getAssetIdentifier:model.asset]]) {
self.imageView.image = photo;
self.model.cachedImage = photo;
} else {
// NSLog(@"this cell is showing other asset");
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
}
if (!isDegraded) {
[self hideProgressView];
self.imageRequestID = 0;
}
} progressHandler:nil networkAccessAllowed:NO];
if (imageRequestID && self.imageRequestID && imageRequestID != self.imageRequestID) {
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
// NSLog(@"cancelImageRequest %d",self.imageRequestID);
}
self.imageRequestID = imageRequestID;
}
self.selectPhotoButton.selected = model.isSelected;
self.selectImageView.image = self.selectPhotoButton.isSelected ? self.photoSelImage : self.photoDefImage;
self.indexLabel.hidden = !self.selectPhotoButton.isSelected;
self.type = (NSInteger)model.type;
// /
if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) {
if (_selectImageView.hidden == NO) {
self.selectPhotoButton.hidden = YES;
_selectImageView.hidden = YES;
}
}
//
if (model.isSelected) {
[self requestBigImage];
} else {
[self cancelBigImageRequest];
}
if (model.needOscillatoryAnimation) {
[UIView showOscillatoryAnimationWithLayer:self.selectImageView.layer type:TZOscillatoryAnimationToBigger];
}
model.needOscillatoryAnimation = NO;
[self setNeedsLayout];
if (self.assetCellDidSetModelBlock) {
self.assetCellDidSetModelBlock(self, _imageView, _selectImageView, _indexLabel, _bottomView, _timeLength, _videoImgView);
}
}
- (void)setIndex:(NSInteger)index {
_index = index;
self.indexLabel.text = [NSString stringWithFormat:@"%zd", index];
[self.contentView bringSubviewToFront:self.indexLabel];
}
- (void)setShowSelectBtn:(BOOL)showSelectBtn {
_showSelectBtn = showSelectBtn;
BOOL selectable = [[TZImageManager manager] isPhotoSelectableWithAsset:self.model.asset];
if (!self.selectPhotoButton.hidden) {
self.selectPhotoButton.hidden = !showSelectBtn || !selectable;
}
if (!self.selectImageView.hidden) {
self.selectImageView.hidden = !showSelectBtn || !selectable;
}
}
- (void)setType:(TZAssetCellType)type {
_type = type;
if (type == TZAssetCellTypePhoto || type == TZAssetCellTypeLivePhoto || (type == TZAssetCellTypePhotoGif && !self.allowPickingGif) || self.allowPickingMultipleVideo) {
_selectImageView.hidden = NO;
_selectPhotoButton.hidden = NO;
_bottomView.hidden = YES;
} else { // Video of Gif
_selectImageView.hidden = YES;
_selectPhotoButton.hidden = YES;
}
if (type == TZAssetCellTypeVideo) {
self.bottomView.hidden = NO;
self.timeLength.text = _model.timeLength;
self.videoImgView.hidden = NO;
_timeLength.tz_left = self.videoImgView.tz_right;
_timeLength.textAlignment = NSTextAlignmentRight;
} else if (type == TZAssetCellTypePhotoGif && self.allowPickingGif) {
self.bottomView.hidden = NO;
self.timeLength.text = @"GIF";
self.videoImgView.hidden = YES;
_timeLength.tz_left = 5;
_timeLength.textAlignment = NSTextAlignmentLeft;
}
}
- (void)selectPhotoButtonClick:(UIButton *)sender {
if (self.didSelectPhotoBlock) {
self.didSelectPhotoBlock(sender.isSelected);
}
self.selectImageView.image = sender.isSelected ? self.photoSelImage : self.photoDefImage;
if (sender.isSelected) {
if (![TZImagePickerConfig sharedInstance].showSelectedIndex && ![TZImagePickerConfig sharedInstance].showPhotoCannotSelectLayer) {
[UIView showOscillatoryAnimationWithLayer:_selectImageView.layer type:TZOscillatoryAnimationToBigger];
}
//
[self requestBigImage];
} else { //
[self cancelBigImageRequest];
}
}
- (void)hideProgressView {
if (_progressView) {
self.progressView.hidden = YES;
self.imageView.alpha = 1.0;
}
}
- (void)requestBigImage {
if (_bigImageRequestID) {
[[PHImageManager defaultManager] cancelImageRequest:_bigImageRequestID];
}
_bigImageRequestID = [[TZImageManager manager] requestImageDataForAsset:_model.asset completion:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
[self hideProgressView];
} progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
if (self.model.isSelected) {
progress = progress > 0.02 ? progress : 0.02;;
self.progressView.progress = progress;
self.progressView.hidden = NO;
self.imageView.alpha = 0.4;
if (progress >= 1) {
[self hideProgressView];
}
} else {
*stop = YES;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[self cancelBigImageRequest];
}
}];
}
- (void)cancelBigImageRequest {
if (_bigImageRequestID) {
[[PHImageManager defaultManager] cancelImageRequest:_bigImageRequestID];
}
[self hideProgressView];
}
#pragma mark - Lazy load
- (UIButton *)selectPhotoButton {
if (_selectPhotoButton == nil) {
UIButton *selectPhotoButton = [[UIButton alloc] init];
[selectPhotoButton addTarget:self action:@selector(selectPhotoButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:selectPhotoButton];
_selectPhotoButton = selectPhotoButton;
}
return _selectPhotoButton;
}
- (UIImageView *)imageView {
if (_imageView == nil) {
UIImageView *imageView = [[UIImageView alloc] init];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
[self.contentView addSubview:imageView];
_imageView = imageView;
}
return _imageView;
}
- (UIImageView *)selectImageView {
if (_selectImageView == nil) {
UIImageView *selectImageView = [[UIImageView alloc] init];
selectImageView.contentMode = UIViewContentModeCenter;
selectImageView.clipsToBounds = YES;
[self.contentView addSubview:selectImageView];
_selectImageView = selectImageView;
}
return _selectImageView;
}
- (UIView *)bottomView {
if (_bottomView == nil) {
UIView *bottomView = [[UIView alloc] init];
static NSInteger rgb = 0;
bottomView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.8];
[self.contentView addSubview:bottomView];
_bottomView = bottomView;
}
return _bottomView;
}
- (UIButton *)cannotSelectLayerButton {
if (_cannotSelectLayerButton == nil) {
UIButton *cannotSelectLayerButton = [[UIButton alloc] init];
[self.contentView addSubview:cannotSelectLayerButton];
_cannotSelectLayerButton = cannotSelectLayerButton;
}
return _cannotSelectLayerButton;
}
- (UIImageView *)videoImgView {
if (_videoImgView == nil) {
UIImageView *videoImgView = [[UIImageView alloc] init];
[videoImgView setImage:[UIImage imageNamedFromMyBundle:@"VideoSendIcon"]];
[self.bottomView addSubview:videoImgView];
_videoImgView = videoImgView;
}
return _videoImgView;
}
- (UILabel *)timeLength {
if (_timeLength == nil) {
UILabel *timeLength = [[UILabel alloc] init];
timeLength.font = [UIFont boldSystemFontOfSize:11];
timeLength.textColor = [UIColor whiteColor];
timeLength.textAlignment = NSTextAlignmentRight;
[self.bottomView addSubview:timeLength];
_timeLength = timeLength;
}
return _timeLength;
}
- (UILabel *)indexLabel {
if (_indexLabel == nil) {
UILabel *indexLabel = [[UILabel alloc] init];
indexLabel.font = [UIFont systemFontOfSize:14];
indexLabel.textColor = [UIColor whiteColor];
indexLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:indexLabel];
_indexLabel = indexLabel;
}
return _indexLabel;
}
- (TZProgressView *)progressView {
if (_progressView == nil) {
_progressView = [[TZProgressView alloc] init];
_progressView.hidden = YES;
[self addSubview:_progressView];
}
return _progressView;
}
- (void)layoutSubviews {
[super layoutSubviews];
_cannotSelectLayerButton.frame = self.bounds;
if (self.allowPreview) {
_selectPhotoButton.frame = CGRectMake(self.tz_width - 44, 0, 44, 44);
} else {
_selectPhotoButton.frame = self.bounds;
}
_selectImageView.frame = CGRectMake(self.tz_width - 27, 3, 24, 24);
if (_selectImageView.image.size.width <= 27) {
_selectImageView.contentMode = UIViewContentModeCenter;
} else {
_selectImageView.contentMode = UIViewContentModeScaleAspectFit;
}
_indexLabel.frame = _selectImageView.frame;
_imageView.frame = CGRectMake(0, 0, self.tz_width, self.tz_height);
static CGFloat progressWH = 20;
CGFloat progressXY = (self.tz_width - progressWH) / 2;
_progressView.frame = CGRectMake(progressXY, progressXY, progressWH, progressWH);
_bottomView.frame = CGRectMake(0, self.tz_height - 17, self.tz_width, 17);
_videoImgView.frame = CGRectMake(8, 0, 17, 17);
_timeLength.frame = CGRectMake(self.videoImgView.tz_right, 0, self.tz_width - self.videoImgView.tz_right - 5, 17);
self.type = (NSInteger)self.model.type;
self.showSelectBtn = self.showSelectBtn;
[self.contentView bringSubviewToFront:_bottomView];
[self.contentView bringSubviewToFront:_cannotSelectLayerButton];
[self.contentView bringSubviewToFront:_selectPhotoButton];
[self.contentView bringSubviewToFront:_selectImageView];
[self.contentView bringSubviewToFront:_indexLabel];
if (self.assetCellDidLayoutSubviewsBlock) {
self.assetCellDidLayoutSubviewsBlock(self, _imageView, _selectImageView, _indexLabel, _bottomView, _timeLength, _videoImgView);
}
}
@end
@interface TZAlbumCell ()
@property (weak, nonatomic) UIImageView *posterImageView;
@property (weak, nonatomic) UILabel *titleLabel;
@end
@implementation TZAlbumCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return self;
}
- (void)setModel:(TZAlbumModel *)model {
_model = model;
NSMutableAttributedString *nameString = [[NSMutableAttributedString alloc] initWithString:model.name attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor]}];
NSAttributedString *countString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" (%zd)",model.count] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
[nameString appendAttributedString:countString];
self.titleLabel.attributedText = nameString;
[[TZImageManager manager] getPostImageWithAlbumModel:model completion:^(UIImage *postImage) {
self.posterImageView.image = postImage;
}];
if (model.selectedCount) {
self.selectedCountButton.hidden = NO;
[self.selectedCountButton setTitle:[NSString stringWithFormat:@"%zd",model.selectedCount] forState:UIControlStateNormal];
} else {
self.selectedCountButton.hidden = YES;
}
if (self.albumCellDidSetModelBlock) {
self.albumCellDidSetModelBlock(self, _posterImageView, _titleLabel);
}
}
/// For fitting iOS6
- (void)layoutSubviews {
if (iOS7Later) [super layoutSubviews];
_selectedCountButton.frame = CGRectMake(self.tz_width - 24 - 30, 23, 24, 24);
NSInteger titleHeight = ceil(self.titleLabel.font.lineHeight);
self.titleLabel.frame = CGRectMake(80, (self.tz_height - titleHeight) / 2, self.tz_width - 80 - 50, titleHeight);
self.posterImageView.frame = CGRectMake(0, 0, 70, 70);
if (self.albumCellDidLayoutSubviewsBlock) {
self.albumCellDidLayoutSubviewsBlock(self, _posterImageView, _titleLabel);
}
}
- (void)layoutSublayersOfLayer:(CALayer *)layer {
if (iOS7Later) [super layoutSublayersOfLayer:layer];
}
#pragma mark - Lazy load
- (UIImageView *)posterImageView {
if (_posterImageView == nil) {
UIImageView *posterImageView = [[UIImageView alloc] init];
posterImageView.contentMode = UIViewContentModeScaleAspectFill;
posterImageView.clipsToBounds = YES;
[self.contentView addSubview:posterImageView];
_posterImageView = posterImageView;
}
return _posterImageView;
}
- (UILabel *)titleLabel {
if (_titleLabel == nil) {
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.font = [UIFont boldSystemFontOfSize:17];
titleLabel.textColor = [UIColor blackColor];
titleLabel.textAlignment = NSTextAlignmentLeft;
[self.contentView addSubview:titleLabel];
_titleLabel = titleLabel;
}
return _titleLabel;
}
- (UIButton *)selectedCountButton {
if (_selectedCountButton == nil) {
UIButton *selectedCountButton = [[UIButton alloc] init];
selectedCountButton.layer.cornerRadius = 12;
selectedCountButton.clipsToBounds = YES;
selectedCountButton.backgroundColor = [UIColor redColor];
[selectedCountButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
selectedCountButton.titleLabel.font = [UIFont systemFontOfSize:15];
[self.contentView addSubview:selectedCountButton];
_selectedCountButton = selectedCountButton;
}
return _selectedCountButton;
}
@end
@implementation TZAssetCameraCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
_imageView = [[UIImageView alloc] init];
_imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.contentView addSubview:_imageView];
self.clipsToBounds = YES;
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
_imageView.frame = self.bounds;
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZAssetCell.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 3,619 |
```objective-c
//
// NSBundle+TZImagePicker.m
// TZImagePickerController
//
// Created by on 16/08/18.
//
#import "NSBundle+TZImagePicker.h"
#import "TZImagePickerController.h"
@implementation NSBundle (TZImagePicker)
+ (NSBundle *)tz_imagePickerBundle {
NSBundle *bundle = [NSBundle bundleForClass:[TZImagePickerController class]];
NSURL *url = [bundle URLForResource:@"TZImagePickerController" withExtension:@"bundle"];
bundle = [NSBundle bundleWithURL:url];
return bundle;
}
+ (NSString *)tz_localizedStringForKey:(NSString *)key {
return [self tz_localizedStringForKey:key value:@""];
}
+ (NSString *)tz_localizedStringForKey:(NSString *)key value:(NSString *)value {
NSBundle *bundle = [TZImagePickerConfig sharedInstance].languageBundle;
NSString *value1 = [bundle localizedStringForKey:key value:value table:nil];
return value1;
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/NSBundle+TZImagePicker.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 204 |
```objective-c
//
// TZPhotoPickerController.m
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import "TZPhotoPickerController.h"
#import "TZImagePickerController.h"
#import "TZPhotoPreviewController.h"
#import "TZAssetCell.h"
#import "TZAssetModel.h"
#import "UIView+Layout.h"
#import "TZImageManager.h"
#import "TZVideoPlayerController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import <MobileCoreServices/MobileCoreServices.h>
@interface TZPhotoPickerController ()<UICollectionViewDataSource,UICollectionViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIAlertViewDelegate> {
NSMutableArray *_models;
UIView *_bottomToolBar;
UIButton *_previewButton;
UIButton *_doneButton;
UIImageView *_numberImageView;
UILabel *_numberLabel;
UIButton *_originalPhotoButton;
UILabel *_originalPhotoLabel;
UIView *_divideLine;
BOOL _shouldScrollToBottom;
BOOL _showTakePhotoBtn;
CGFloat _offsetItemCount;
}
@property CGRect previousPreheatRect;
@property (nonatomic, assign) BOOL isSelectOriginalPhoto;
@property (nonatomic, strong) TZCollectionView *collectionView;
@property (strong, nonatomic) UICollectionViewFlowLayout *layout;
@property (nonatomic, strong) UIImagePickerController *imagePickerVc;
@property (strong, nonatomic) CLLocation *location;
@property (assign, nonatomic) BOOL useCachedImage;
@end
static CGSize AssetGridThumbnailSize;
static CGFloat itemMargin = 5;
@implementation TZPhotoPickerController
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (UIImagePickerController *)imagePickerVc {
if (_imagePickerVc == nil) {
_imagePickerVc = [[UIImagePickerController alloc] init];
_imagePickerVc.delegate = self;
// set appearance /
if (iOS7Later) {
_imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
}
_imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
UIBarButtonItem *tzBarItem, *BarItem;
if (@available(iOS 9, *)) {
tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
} else {
tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
}
NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
[BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
}
return _imagePickerVc;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.isFirstAppear = YES;
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_isSelectOriginalPhoto = tzImagePickerVc.isSelectOriginalPhoto;
_shouldScrollToBottom = YES;
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.title = _model.name;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:tzImagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:tzImagePickerVc action:@selector(cancelButtonClick)];
if (tzImagePickerVc.navLeftBarButtonSettingBlock) {
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
leftButton.frame = CGRectMake(0, 0, 44, 44);
[leftButton addTarget:self action:@selector(navLeftBarButtonClick) forControlEvents:UIControlEventTouchUpInside];
tzImagePickerVc.navLeftBarButtonSettingBlock(leftButton);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
}
_showTakePhotoBtn = _model.isCameraRoll && ((tzImagePickerVc.allowTakePicture && tzImagePickerVc.allowPickingImage) || (tzImagePickerVc.allowTakeVideo && tzImagePickerVc.allowPickingVideo));
// [self resetCachedAssets];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
- (void)fetchAssetModels {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_isFirstAppear && !_model.models.count) {
[tzImagePickerVc showProgressHUD];
}
dispatch_async(dispatch_get_global_queue(0, 0), ^{
if (!tzImagePickerVc.sortAscendingByModificationDate && self->_isFirstAppear && iOS8Later && self->_model.isCameraRoll) {
[[TZImageManager manager] getCameraRollAlbum:tzImagePickerVc.allowPickingVideo allowPickingImage:tzImagePickerVc.allowPickingImage needFetchAssets:YES completion:^(TZAlbumModel *model) {
self->_model = model;
self->_models = [NSMutableArray arrayWithArray:self->_model.models];
[self initSubviews];
}];
} else {
if (self->_showTakePhotoBtn || !iOS8Later || self->_isFirstAppear) {
[[TZImageManager manager] getAssetsFromFetchResult:self->_model.result completion:^(NSArray<TZAssetModel *> *models) {
self->_models = [NSMutableArray arrayWithArray:models];
[self initSubviews];
}];
} else {
self->_models = [NSMutableArray arrayWithArray:self->_model.models];
[self initSubviews];
}
}
});
}
- (void)initSubviews {
dispatch_async(dispatch_get_main_queue(), ^{
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
[tzImagePickerVc hideProgressHUD];
[self checkSelectedModels];
[self configCollectionView];
self->_collectionView.hidden = YES;
[self configBottomToolBar];
[self scrollCollectionViewToBottom];
});
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
tzImagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
}
- (BOOL)prefersStatusBarHidden {
return NO;
}
- (void)configCollectionView {
_layout = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[TZCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout];
_collectionView.backgroundColor = [UIColor whiteColor];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.alwaysBounceHorizontal = NO;
_collectionView.contentInset = UIEdgeInsetsMake(itemMargin, itemMargin, itemMargin, itemMargin);
if (_showTakePhotoBtn) {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber) / self.columnNumber) * self.view.tz_width);
} else {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber - 1) / self.columnNumber) * self.view.tz_width);
}
[self.view addSubview:_collectionView];
[_collectionView registerClass:[TZAssetCell class] forCellWithReuseIdentifier:@"TZAssetCell"];
[_collectionView registerClass:[TZAssetCameraCell class] forCellWithReuseIdentifier:@"TZAssetCameraCell"];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Determine the size of the thumbnails to request from the PHCachingImageManager
CGFloat scale = 2.0;
if ([UIScreen mainScreen].bounds.size.width > 600) {
scale = 1.0;
}
CGSize cellSize = ((UICollectionViewFlowLayout *)_collectionView.collectionViewLayout).itemSize;
AssetGridThumbnailSize = CGSizeMake(cellSize.width * scale, cellSize.height * scale);
if (!_models) {
[self fetchAssetModels];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (iOS8Later) {
// [self updateCachedAssets];
}
}
- (void)configBottomToolBar {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (!tzImagePickerVc.showSelectBtn) return;
_bottomToolBar = [[UIView alloc] initWithFrame:CGRectZero];
CGFloat rgb = 253 / 255.0;
_bottomToolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
_previewButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_previewButton addTarget:self action:@selector(previewButtonClick) forControlEvents:UIControlEventTouchUpInside];
_previewButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateNormal];
[_previewButton setTitle:tzImagePickerVc.previewBtnTitleStr forState:UIControlStateDisabled];
[_previewButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_previewButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
_previewButton.enabled = tzImagePickerVc.selectedModels.count;
if (tzImagePickerVc.allowPickingOriginalPhoto) {
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
[_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
_originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
[_originalPhotoButton setTitle:tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateSelected];
[_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[_originalPhotoButton setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
[_originalPhotoButton setImage:tzImagePickerVc.photoOriginDefImage forState:UIControlStateNormal];
[_originalPhotoButton setImage:tzImagePickerVc.photoOriginSelImage forState:UIControlStateSelected];
_originalPhotoButton.imageView.clipsToBounds = YES;
_originalPhotoButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
_originalPhotoButton.selected = _isSelectOriginalPhoto;
_originalPhotoButton.enabled = tzImagePickerVc.selectedModels.count > 0;
_originalPhotoLabel = [[UILabel alloc] init];
_originalPhotoLabel.textAlignment = NSTextAlignmentLeft;
_originalPhotoLabel.font = [UIFont systemFontOfSize:16];
_originalPhotoLabel.textColor = [UIColor blackColor];
if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes];
}
_doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
[_doneButton setTitle:tzImagePickerVc.doneBtnTitleStr forState:UIControlStateDisabled];
[_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
[_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled];
_doneButton.enabled = tzImagePickerVc.selectedModels.count || tzImagePickerVc.alwaysEnableDoneBtn;
_numberImageView = [[UIImageView alloc] initWithImage:tzImagePickerVc.photoNumberIconImage];
_numberImageView.hidden = tzImagePickerVc.selectedModels.count <= 0;
_numberImageView.clipsToBounds = YES;
_numberImageView.contentMode = UIViewContentModeScaleAspectFit;
_numberImageView.backgroundColor = [UIColor clearColor];
_numberLabel = [[UILabel alloc] init];
_numberLabel.font = [UIFont systemFontOfSize:15];
_numberLabel.textColor = [UIColor whiteColor];
_numberLabel.textAlignment = NSTextAlignmentCenter;
_numberLabel.text = [NSString stringWithFormat:@"%zd",tzImagePickerVc.selectedModels.count];
_numberLabel.hidden = tzImagePickerVc.selectedModels.count <= 0;
_numberLabel.backgroundColor = [UIColor clearColor];
_divideLine = [[UIView alloc] init];
CGFloat rgb2 = 222 / 255.0;
_divideLine.backgroundColor = [UIColor colorWithRed:rgb2 green:rgb2 blue:rgb2 alpha:1.0];
[_bottomToolBar addSubview:_divideLine];
[_bottomToolBar addSubview:_previewButton];
[_bottomToolBar addSubview:_doneButton];
[_bottomToolBar addSubview:_numberImageView];
[_bottomToolBar addSubview:_numberLabel];
[_bottomToolBar addSubview:_originalPhotoButton];
[self.view addSubview:_bottomToolBar];
[_originalPhotoButton addSubview:_originalPhotoLabel];
if (tzImagePickerVc.photoPickerPageUIConfigBlock) {
tzImagePickerVc.photoPickerPageUIConfigBlock(_collectionView, _bottomToolBar, _previewButton, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel, _divideLine);
}
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
CGFloat top = 0;
CGFloat collectionViewHeight = 0;
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 50 + (83 - 49) : 50;
if (self.navigationController.navigationBar.isTranslucent) {
top = naviBarHeight;
if (iOS7Later && !isStatusBarHidden) top += [TZCommonTools tz_statusBarHeight];
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight - top : self.view.tz_height - top;;
} else {
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height;
}
_collectionView.frame = CGRectMake(0, top, self.view.tz_width, collectionViewHeight);
CGFloat itemWH = (self.view.tz_width - (self.columnNumber + 1) * itemMargin) / self.columnNumber;
_layout.itemSize = CGSizeMake(itemWH, itemWH);
_layout.minimumInteritemSpacing = itemMargin;
_layout.minimumLineSpacing = itemMargin;
[_collectionView setCollectionViewLayout:_layout];
if (_offsetItemCount > 0) {
CGFloat offsetY = _offsetItemCount * (_layout.itemSize.height + _layout.minimumLineSpacing);
[_collectionView setContentOffset:CGPointMake(0, offsetY)];
}
CGFloat toolBarTop = 0;
if (!self.navigationController.navigationBar.isHidden) {
toolBarTop = self.view.tz_height - toolBarHeight;
} else {
CGFloat navigationHeight = naviBarHeight;
if (iOS7Later) navigationHeight += [TZCommonTools tz_statusBarHeight];
toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight;
}
_bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr tz_calculateSizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)].width + 2;
if (!tzImagePickerVc.allowPreview) {
previewWidth = 0.0;
}
_previewButton.frame = CGRectMake(10, 3, previewWidth, 44);
_previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth;
if (tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [tzImagePickerVc.fullImageBtnTitleStr tz_calculateSizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)].width;
_originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), 0, fullImageWidth + 56, 50);
_originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50);
}
[_doneButton sizeToFit];
_doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, _doneButton.tz_width, 50);
_numberImageView.frame = CGRectMake(_doneButton.tz_left - 24 - 5, 13, 24, 24);
_numberLabel.frame = _numberImageView.frame;
_divideLine.frame = CGRectMake(0, 0, self.view.tz_width, 1);
[TZImageManager manager].columnNumber = [TZImageManager manager].columnNumber;
[self.collectionView reloadData];
if (tzImagePickerVc.photoPickerPageDidLayoutSubviewsBlock) {
tzImagePickerVc.photoPickerPageDidLayoutSubviewsBlock(_collectionView, _bottomToolBar, _previewButton, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel, _divideLine);
}
}
#pragma mark - Notification
- (void)didChangeStatusBarOrientationNotification:(NSNotification *)noti {
_offsetItemCount = _collectionView.contentOffset.y / (_layout.itemSize.height + _layout.minimumLineSpacing);
}
#pragma mark - Click Event
- (void)navLeftBarButtonClick{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)previewButtonClick {
TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init];
[self pushPhotoPrevireViewController:photoPreviewVc needCheckSelectedModels:YES];
}
- (void)originalPhotoButtonClick {
_originalPhotoButton.selected = !_originalPhotoButton.isSelected;
_isSelectOriginalPhoto = _originalPhotoButton.isSelected;
_originalPhotoLabel.hidden = !_originalPhotoButton.isSelected;
if (_isSelectOriginalPhoto) {
[self getSelectedPhotoBytes];
}
}
- (void)doneButtonClick {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
// 1.6.8
if (tzImagePickerVc.minImagesCount && tzImagePickerVc.selectedModels.count < tzImagePickerVc.minImagesCount) {
NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a minimum of %zd photos"], tzImagePickerVc.minImagesCount];
[tzImagePickerVc showAlertWithTitle:title];
return;
}
[tzImagePickerVc showProgressHUD];
NSMutableArray *assets = [NSMutableArray array];
NSMutableArray *photos;
NSMutableArray *infoArr;
if (tzImagePickerVc.onlyReturnAsset) { // not fetch image
for (NSInteger i = 0; i < tzImagePickerVc.selectedModels.count; i++) {
TZAssetModel *model = tzImagePickerVc.selectedModels[i];
[assets addObject:model.asset];
}
} else { // fetch image
photos = [NSMutableArray array];
infoArr = [NSMutableArray array];
for (NSInteger i = 0; i < tzImagePickerVc.selectedModels.count; i++) { [photos addObject:@1];[assets addObject:@1];[infoArr addObject:@1]; }
__block BOOL havenotShowAlert = YES;
[TZImageManager manager].shouldFixOrientation = YES;
__block id alertView;
for (NSInteger i = 0; i < tzImagePickerVc.selectedModels.count; i++) {
TZAssetModel *model = tzImagePickerVc.selectedModels[i];
[[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (isDegraded) return;
if (photo) {
if (![TZImagePickerConfig sharedInstance].notScaleImage) {
photo = [[TZImageManager manager] scaleImage:photo toSize:CGSizeMake(tzImagePickerVc.photoWidth, (int)(tzImagePickerVc.photoWidth * photo.size.height / photo.size.width))];
}
[photos replaceObjectAtIndex:i withObject:photo];
}
if (info) [infoArr replaceObjectAtIndex:i withObject:info];
[assets replaceObjectAtIndex:i withObject:model.asset];
for (id item in photos) { if ([item isKindOfClass:[NSNumber class]]) return; }
if (havenotShowAlert) {
[tzImagePickerVc hideAlertView:alertView];
[self didGetAllPhotos:photos assets:assets infoArr:infoArr];
}
} progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
// iCloud,
if (progress < 1 && havenotShowAlert && !alertView) {
[tzImagePickerVc hideProgressHUD];
alertView = [tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Synchronizing photos from iCloud"]];
havenotShowAlert = NO;
return;
}
if (progress >= 1) {
havenotShowAlert = YES;
}
} networkAccessAllowed:YES];
}
}
if (tzImagePickerVc.selectedModels.count <= 0 || tzImagePickerVc.onlyReturnAsset) {
[self didGetAllPhotos:photos assets:assets infoArr:infoArr];
}
}
- (void)didGetAllPhotos:(NSArray *)photos assets:(NSArray *)assets infoArr:(NSArray *)infoArr {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
[tzImagePickerVc hideProgressHUD];
if (tzImagePickerVc.autoDismiss) {
[self.navigationController dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethodWithPhotos:photos assets:assets infoArr:infoArr];
}];
} else {
[self callDelegateMethodWithPhotos:photos assets:assets infoArr:infoArr];
}
}
- (void)callDelegateMethodWithPhotos:(NSArray *)photos assets:(NSArray *)assets infoArr:(NSArray *)infoArr {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (!tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowPickingVideo && tzImagePickerVc.maxImagesCount == 1) {
if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingVideo:sourceAssets:)]) {
[tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingVideo:[photos firstObject] sourceAssets:[assets firstObject]];
}
if (tzImagePickerVc.didFinishPickingVideoHandle) {
tzImagePickerVc.didFinishPickingVideoHandle([photos firstObject], [assets firstObject]);
}
return;
}
if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:)]) {
[tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto];
}
if ([tzImagePickerVc.pickerDelegate respondsToSelector:@selector(imagePickerController:didFinishPickingPhotos:sourceAssets:isSelectOriginalPhoto:infos:)]) {
[tzImagePickerVc.pickerDelegate imagePickerController:tzImagePickerVc didFinishPickingPhotos:photos sourceAssets:assets isSelectOriginalPhoto:_isSelectOriginalPhoto infos:infoArr];
}
if (tzImagePickerVc.didFinishPickingPhotosHandle) {
tzImagePickerVc.didFinishPickingPhotosHandle(photos,assets,_isSelectOriginalPhoto);
}
if (tzImagePickerVc.didFinishPickingPhotosWithInfosHandle) {
tzImagePickerVc.didFinishPickingPhotosWithInfosHandle(photos,assets,_isSelectOriginalPhoto,infoArr);
}
}
#pragma mark - UICollectionViewDataSource && Delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (_showTakePhotoBtn) {
return _models.count + 1;
}
return _models.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// the cell lead to take a picture / cell
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.item >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.item == 0)) && _showTakePhotoBtn) {
TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath];
cell.imageView.image = tzImagePickerVc.takePictureImage;
if ([tzImagePickerVc.takePictureImageName isEqualToString:@"takePicture80"]) {
cell.imageView.contentMode = UIViewContentModeCenter;
CGFloat rgb = 223 / 255.0;
cell.imageView.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
} else {
cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
}
return cell;
}
// the cell dipaly photo or video / cell
TZAssetCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCell" forIndexPath:indexPath];
cell.allowPickingMultipleVideo = tzImagePickerVc.allowPickingMultipleVideo;
cell.photoDefImage = tzImagePickerVc.photoDefImage;
cell.photoSelImage = tzImagePickerVc.photoSelImage;
cell.useCachedImage = self.useCachedImage;
cell.assetCellDidSetModelBlock = tzImagePickerVc.assetCellDidSetModelBlock;
cell.assetCellDidLayoutSubviewsBlock = tzImagePickerVc.assetCellDidLayoutSubviewsBlock;
TZAssetModel *model;
if (tzImagePickerVc.sortAscendingByModificationDate || !_showTakePhotoBtn) {
model = _models[indexPath.item];
} else {
model = _models[indexPath.item - 1];
}
cell.allowPickingGif = tzImagePickerVc.allowPickingGif;
cell.model = model;
if (model.isSelected && tzImagePickerVc.showSelectedIndex) {
NSString *assetId = [[TZImageManager manager] getAssetIdentifier:model.asset];
cell.index = [tzImagePickerVc.selectedAssetIds indexOfObject:assetId] + 1;
}
cell.showSelectBtn = tzImagePickerVc.showSelectBtn;
cell.allowPreview = tzImagePickerVc.allowPreview;
if (tzImagePickerVc.selectedModels.count >= tzImagePickerVc.maxImagesCount && tzImagePickerVc.showPhotoCannotSelectLayer && !model.isSelected) {
cell.cannotSelectLayerButton.backgroundColor = tzImagePickerVc.cannotSelectLayerColor;
cell.cannotSelectLayerButton.hidden = NO;
} else {
cell.cannotSelectLayerButton.hidden = YES;
}
__weak typeof(cell) weakCell = cell;
__weak typeof(self) weakSelf = self;
__weak typeof(_numberImageView.layer) weakLayer = _numberImageView.layer;
cell.didSelectPhotoBlock = ^(BOOL isSelected) {
__strong typeof(weakCell) strongCell = weakCell;
__strong typeof(weakSelf) strongSelf = weakSelf;
__strong typeof(weakLayer) strongLayer = weakLayer;
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)strongSelf.navigationController;
// 1. cancel select /
if (isSelected) {
strongCell.selectPhotoButton.selected = NO;
model.isSelected = NO;
NSArray *selectedModels = [NSArray arrayWithArray:tzImagePickerVc.selectedModels];
for (TZAssetModel *model_item in selectedModels) {
if ([[[TZImageManager manager] getAssetIdentifier:model.asset] isEqualToString:[[TZImageManager manager] getAssetIdentifier:model_item.asset]]) {
[tzImagePickerVc removeSelectedModel:model_item];
break;
}
}
[strongSelf refreshBottomToolBarStatus];
if (tzImagePickerVc.showSelectedIndex || tzImagePickerVc.showPhotoCannotSelectLayer) {
[strongSelf setUseCachedImageAndReloadData];
}
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
} else {
// 2. select:check if over the maxImagesCount / ,
if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) {
strongCell.selectPhotoButton.selected = YES;
model.isSelected = YES;
if (tzImagePickerVc.showSelectedIndex || tzImagePickerVc.showPhotoCannotSelectLayer) {
model.needOscillatoryAnimation = YES;
[strongSelf setUseCachedImageAndReloadData];
}
[tzImagePickerVc addSelectedModel:model];
[strongSelf refreshBottomToolBarStatus];
[UIView showOscillatoryAnimationWithLayer:strongLayer type:TZOscillatoryAnimationToSmaller];
} else {
NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a maximum of %zd photos"], tzImagePickerVc.maxImagesCount];
[tzImagePickerVc showAlertWithTitle:title];
}
}
};
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// take a photo /
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (((tzImagePickerVc.sortAscendingByModificationDate && indexPath.item >= _models.count) || (!tzImagePickerVc.sortAscendingByModificationDate && indexPath.item == 0)) && _showTakePhotoBtn) {
[self takePhoto]; return;
}
// preview phote or video /
NSInteger index = indexPath.item;
if (!tzImagePickerVc.sortAscendingByModificationDate && _showTakePhotoBtn) {
index = indexPath.item - 1;
}
TZAssetModel *model = _models[index];
if (model.type == TZAssetModelMediaTypeVideo && !tzImagePickerVc.allowPickingMultipleVideo) {
if (tzImagePickerVc.selectedModels.count > 0) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Can not choose both video and photo"]];
} else {
TZVideoPlayerController *videoPlayerVc = [[TZVideoPlayerController alloc] init];
videoPlayerVc.model = model;
[self.navigationController pushViewController:videoPlayerVc animated:YES];
}
} else if (model.type == TZAssetModelMediaTypePhotoGif && tzImagePickerVc.allowPickingGif && !tzImagePickerVc.allowPickingMultipleVideo) {
if (tzImagePickerVc.selectedModels.count > 0) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Can not choose both photo and GIF"]];
} else {
TZGifPhotoPreviewController *gifPreviewVc = [[TZGifPhotoPreviewController alloc] init];
gifPreviewVc.model = model;
[self.navigationController pushViewController:gifPreviewVc animated:YES];
}
} else {
TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init];
photoPreviewVc.currentIndex = index;
photoPreviewVc.models = _models;
[self pushPhotoPrevireViewController:photoPreviewVc];
}
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (iOS8Later) {
// [self updateCachedAssets];
}
}
#pragma mark - Private Method
- (void)setUseCachedImageAndReloadData {
self.useCachedImage = YES;
[self.collectionView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.useCachedImage = NO;
});
}
///
- (void)takePhoto {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS7Later) {
NSDictionary *infoDict = [TZCommonTools tz_getInfoDictionary];
//
NSString *appName = [infoDict valueForKey:@"CFBundleDisplayName"];
if (!appName) appName = [infoDict valueForKey:@"CFBundleName"];
NSString *message = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Please allow %@ to access your camera in \"Settings -> Privacy -> Camera\""],appName];
if (iOS8Later) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Can not use camera"] message:message delegate:self cancelButtonTitle:[NSBundle tz_localizedStringForKey:@"Cancel"] otherButtonTitles:[NSBundle tz_localizedStringForKey:@"Setting"], nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSBundle tz_localizedStringForKey:@"Can not use camera"] message:message delegate:self cancelButtonTitle:[NSBundle tz_localizedStringForKey:@"OK"] otherButtonTitles:nil];
[alert show];
}
} else if (authStatus == AVAuthorizationStatusNotDetermined) {
// fix issue 466,
if (iOS7Later) {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
[self pushImagePickerController];
});
}
}];
} else {
[self pushImagePickerController];
}
} else {
[self pushImagePickerController];
}
}
//
- (void)pushImagePickerController {
//
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowCameraLocation) {
__weak typeof(self) weakSelf = self;
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.location = [locations firstObject];
} failureBlock:^(NSError *error) {
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.location = nil;
}];
}
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: sourceType]) {
self.imagePickerVc.sourceType = sourceType;
NSMutableArray *mediaTypes = [NSMutableArray array];
if (tzImagePickerVc.allowTakePicture) {
[mediaTypes addObject:(NSString *)kUTTypeImage];
}
if (tzImagePickerVc.allowTakeVideo) {
[mediaTypes addObject:(NSString *)kUTTypeMovie];
self.imagePickerVc.videoMaximumDuration = tzImagePickerVc.videoMaximumDuration;
}
self.imagePickerVc.mediaTypes= mediaTypes;
if (iOS8Later) {
_imagePickerVc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}
if (tzImagePickerVc.uiImagePickerControllerSettingBlock) {
tzImagePickerVc.uiImagePickerControllerSettingBlock(_imagePickerVc);
}
[self presentViewController:_imagePickerVc animated:YES completion:nil];
} else {
NSLog(@",");
}
}
- (void)refreshBottomToolBarStatus {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_previewButton.enabled = tzImagePickerVc.selectedModels.count > 0;
_doneButton.enabled = tzImagePickerVc.selectedModels.count > 0 || tzImagePickerVc.alwaysEnableDoneBtn;
_numberImageView.hidden = tzImagePickerVc.selectedModels.count <= 0;
_numberLabel.hidden = tzImagePickerVc.selectedModels.count <= 0;
_numberLabel.text = [NSString stringWithFormat:@"%zd",tzImagePickerVc.selectedModels.count];
_originalPhotoButton.enabled = tzImagePickerVc.selectedModels.count > 0;
_originalPhotoButton.selected = (_isSelectOriginalPhoto && _originalPhotoButton.enabled);
_originalPhotoLabel.hidden = (!_originalPhotoButton.isSelected);
if (_isSelectOriginalPhoto) [self getSelectedPhotoBytes];
}
- (void)pushPhotoPrevireViewController:(TZPhotoPreviewController *)photoPreviewVc {
[self pushPhotoPrevireViewController:photoPreviewVc needCheckSelectedModels:NO];
}
- (void)pushPhotoPrevireViewController:(TZPhotoPreviewController *)photoPreviewVc needCheckSelectedModels:(BOOL)needCheckSelectedModels {
__weak typeof(self) weakSelf = self;
photoPreviewVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
[photoPreviewVc setBackButtonClickBlock:^(BOOL isSelectOriginalPhoto) {
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.isSelectOriginalPhoto = isSelectOriginalPhoto;
if (needCheckSelectedModels) {
[strongSelf checkSelectedModels];
}
[strongSelf.collectionView reloadData];
[strongSelf refreshBottomToolBarStatus];
}];
[photoPreviewVc setDoneButtonClickBlock:^(BOOL isSelectOriginalPhoto) {
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.isSelectOriginalPhoto = isSelectOriginalPhoto;
[strongSelf doneButtonClick];
}];
[photoPreviewVc setDoneButtonClickBlockCropMode:^(UIImage *cropedImage, id asset) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf didGetAllPhotos:@[cropedImage] assets:@[asset] infoArr:nil];
}];
[self.navigationController pushViewController:photoPreviewVc animated:YES];
}
- (void)getSelectedPhotoBytes {
// && 5
if ([[TZImagePickerConfig sharedInstance].preferredLanguage isEqualToString:@"vi"] && self.view.tz_width <= 320) {
return;
}
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[[TZImageManager manager] getPhotosBytesWithArray:imagePickerVc.selectedModels completion:^(NSString *totalBytes) {
self->_originalPhotoLabel.text = [NSString stringWithFormat:@"(%@)",totalBytes];
}];
}
- (void)scrollCollectionViewToBottom {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_shouldScrollToBottom && _models.count > 0) {
NSInteger item = 0;
if (tzImagePickerVc.sortAscendingByModificationDate) {
item = _models.count - 1;
if (_showTakePhotoBtn) {
item += 1;
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self->_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:NO];
self->_shouldScrollToBottom = NO;
self->_collectionView.hidden = NO;
});
} else {
_collectionView.hidden = NO;
}
}
- (void)checkSelectedModels {
NSMutableArray *selectedAssets = [NSMutableArray array];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
for (TZAssetModel *model in tzImagePickerVc.selectedModels) {
[selectedAssets addObject:model.asset];
}
for (TZAssetModel *model in _models) {
model.isSelected = NO;
if ([[TZImageManager manager] isAssetsArray:selectedAssets containAsset:model.asset]) {
model.isSelected = YES;
}
}
}
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) { //
if (iOS8Later) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
}
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
if ([type isEqualToString:@"public.image"]) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showProgressHUD];
UIImage *photo = [info objectForKey:UIImagePickerControllerOriginalImage];
if (photo) {
[[TZImageManager manager] savePhotoWithImage:photo location:self.location completion:^(NSError *error){
if (!error) {
[self reloadPhotoArrayWithMediaType:type];
}
}];
self.location = nil;
}
} else if ([type isEqualToString:@"public.movie"]) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showProgressHUD];
NSURL *videoUrl = [info objectForKey:UIImagePickerControllerMediaURL];
if (videoUrl) {
[[TZImageManager manager] saveVideoWithUrl:videoUrl location:self.location completion:^(NSError *error) {
if (!error) {
[self reloadPhotoArrayWithMediaType:type];
}
}];
self.location = nil;
}
}
}
- (void)reloadPhotoArrayWithMediaType:(NSString *)mediaType {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
[[TZImageManager manager] getCameraRollAlbum:tzImagePickerVc.allowPickingVideo allowPickingImage:tzImagePickerVc.allowPickingImage needFetchAssets:NO completion:^(TZAlbumModel *model) {
self->_model = model;
[[TZImageManager manager] getAssetsFromFetchResult:self->_model.result completion:^(NSArray<TZAssetModel *> *models) {
[tzImagePickerVc hideProgressHUD];
TZAssetModel *assetModel;
if (tzImagePickerVc.sortAscendingByModificationDate) {
assetModel = [models lastObject];
[self->_models addObject:assetModel];
} else {
assetModel = [models firstObject];
[self->_models insertObject:assetModel atIndex:0];
}
if (tzImagePickerVc.maxImagesCount <= 1) {
if (tzImagePickerVc.allowCrop) {
TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init];
if (tzImagePickerVc.sortAscendingByModificationDate) {
photoPreviewVc.currentIndex = self->_models.count - 1;
} else {
photoPreviewVc.currentIndex = 0;
}
photoPreviewVc.models = self->_models;
[self pushPhotoPrevireViewController:photoPreviewVc];
} else {
[tzImagePickerVc addSelectedModel:assetModel];
[self doneButtonClick];
}
return;
}
if (tzImagePickerVc.selectedModels.count < tzImagePickerVc.maxImagesCount) {
if ([mediaType isEqualToString:@"public.movie"] && !tzImagePickerVc.allowPickingMultipleVideo) {
//
} else {
assetModel.isSelected = YES;
[tzImagePickerVc addSelectedModel:assetModel];
[self refreshBottomToolBarStatus];
}
}
self->_collectionView.hidden = YES;
[self->_collectionView reloadData];
self->_shouldScrollToBottom = YES;
[self scrollCollectionViewToBottom];
}];
}];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:nil];
}
- (void)dealloc {
// NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}
#pragma mark - Asset Caching
- (void)resetCachedAssets {
[[TZImageManager manager].cachingImageManager stopCachingImagesForAllAssets];
self.previousPreheatRect = CGRectZero;
}
- (void)updateCachedAssets {
BOOL isViewVisible = [self isViewLoaded] && [[self view] window] != nil;
if (!isViewVisible) { return; }
// The preheat window is twice the height of the visible rect.
CGRect preheatRect = _collectionView.bounds;
preheatRect = CGRectInset(preheatRect, 0.0f, -0.5f * CGRectGetHeight(preheatRect));
/*
Check if the collection view is showing an area that is significantly
different to the last preheated area.
*/
CGFloat delta = ABS(CGRectGetMidY(preheatRect) - CGRectGetMidY(self.previousPreheatRect));
if (delta > CGRectGetHeight(_collectionView.bounds) / 3.0f) {
// Compute the assets to start caching and to stop caching.
NSMutableArray *addedIndexPaths = [NSMutableArray array];
NSMutableArray *removedIndexPaths = [NSMutableArray array];
[self computeDifferenceBetweenRect:self.previousPreheatRect andRect:preheatRect removedHandler:^(CGRect removedRect) {
NSArray *indexPaths = [self aapl_indexPathsForElementsInRect:removedRect];
[removedIndexPaths addObjectsFromArray:indexPaths];
} addedHandler:^(CGRect addedRect) {
NSArray *indexPaths = [self aapl_indexPathsForElementsInRect:addedRect];
[addedIndexPaths addObjectsFromArray:indexPaths];
}];
NSArray *assetsToStartCaching = [self assetsAtIndexPaths:addedIndexPaths];
NSArray *assetsToStopCaching = [self assetsAtIndexPaths:removedIndexPaths];
// Update the assets the PHCachingImageManager is caching.
[[TZImageManager manager].cachingImageManager startCachingImagesForAssets:assetsToStartCaching
targetSize:AssetGridThumbnailSize
contentMode:PHImageContentModeAspectFill
options:nil];
[[TZImageManager manager].cachingImageManager stopCachingImagesForAssets:assetsToStopCaching
targetSize:AssetGridThumbnailSize
contentMode:PHImageContentModeAspectFill
options:nil];
// Store the preheat rect to compare against in the future.
self.previousPreheatRect = preheatRect;
}
}
- (void)computeDifferenceBetweenRect:(CGRect)oldRect andRect:(CGRect)newRect removedHandler:(void (^)(CGRect removedRect))removedHandler addedHandler:(void (^)(CGRect addedRect))addedHandler {
if (CGRectIntersectsRect(newRect, oldRect)) {
CGFloat oldMaxY = CGRectGetMaxY(oldRect);
CGFloat oldMinY = CGRectGetMinY(oldRect);
CGFloat newMaxY = CGRectGetMaxY(newRect);
CGFloat newMinY = CGRectGetMinY(newRect);
if (newMaxY > oldMaxY) {
CGRect rectToAdd = CGRectMake(newRect.origin.x, oldMaxY, newRect.size.width, (newMaxY - oldMaxY));
addedHandler(rectToAdd);
}
if (oldMinY > newMinY) {
CGRect rectToAdd = CGRectMake(newRect.origin.x, newMinY, newRect.size.width, (oldMinY - newMinY));
addedHandler(rectToAdd);
}
if (newMaxY < oldMaxY) {
CGRect rectToRemove = CGRectMake(newRect.origin.x, newMaxY, newRect.size.width, (oldMaxY - newMaxY));
removedHandler(rectToRemove);
}
if (oldMinY < newMinY) {
CGRect rectToRemove = CGRectMake(newRect.origin.x, oldMinY, newRect.size.width, (newMinY - oldMinY));
removedHandler(rectToRemove);
}
} else {
addedHandler(newRect);
removedHandler(oldRect);
}
}
- (NSArray *)assetsAtIndexPaths:(NSArray *)indexPaths {
if (indexPaths.count == 0) { return nil; }
NSMutableArray *assets = [NSMutableArray arrayWithCapacity:indexPaths.count];
for (NSIndexPath *indexPath in indexPaths) {
if (indexPath.item < _models.count) {
TZAssetModel *model = _models[indexPath.item];
[assets addObject:model.asset];
}
}
return assets;
}
- (NSArray *)aapl_indexPathsForElementsInRect:(CGRect)rect {
NSArray *allLayoutAttributes = [_collectionView.collectionViewLayout layoutAttributesForElementsInRect:rect];
if (allLayoutAttributes.count == 0) { return nil; }
NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:allLayoutAttributes.count];
for (UICollectionViewLayoutAttributes *layoutAttributes in allLayoutAttributes) {
NSIndexPath *indexPath = layoutAttributes.indexPath;
[indexPaths addObject:indexPath];
}
return indexPaths;
}
#pragma clang diagnostic pop
@end
@implementation TZCollectionView
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ([view isKindOfClass:[UIControl class]]) {
return YES;
}
return [super touchesShouldCancelInContentView:view];
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 10,421 |
```objective-c
//
// TZImageCropManager.m
// TZImagePickerController
//
// Created by on 2016/12/5.
//
#import "TZImageCropManager.h"
#import "UIView+Layout.h"
#import <ImageIO/ImageIO.h>
#import "TZImageManager.h"
#import "TZImagePickerController.h"
@implementation TZImageCropManager
///
+ (void)overlayClippingWithView:(UIView *)view cropRect:(CGRect)cropRect containerView:(UIView *)containerView needCircleCrop:(BOOL)needCircleCrop {
UIBezierPath *path= [UIBezierPath bezierPathWithRect:[UIScreen mainScreen].bounds];
CAShapeLayer *layer = [CAShapeLayer layer];
if (needCircleCrop) { //
[path appendPath:[UIBezierPath bezierPathWithArcCenter:containerView.center radius:cropRect.size.width / 2 startAngle:0 endAngle: 2 * M_PI clockwise:NO]];
} else { //
[path appendPath:[UIBezierPath bezierPathWithRect:cropRect]];
}
layer.path = path.CGPath;
layer.fillRule = kCAFillRuleEvenOdd;
layer.fillColor = [[UIColor blackColor] CGColor];
layer.opacity = 0.5;
[view.layer addSublayer:layer];
}
///
+ (UIImage *)cropImageView:(UIImageView *)imageView toRect:(CGRect)rect zoomScale:(double)zoomScale containerView:(UIView *)containerView {
CGAffineTransform transform = CGAffineTransformIdentity;
//
CGRect imageViewRect = [imageView convertRect:imageView.bounds toView:containerView];
CGPoint point = CGPointMake(imageViewRect.origin.x + imageViewRect.size.width / 2, imageViewRect.origin.y + imageViewRect.size.height / 2);
CGFloat xMargin = containerView.tz_width - CGRectGetMaxX(rect) - rect.origin.x;
CGPoint zeroPoint = CGPointMake((CGRectGetWidth(containerView.frame) - xMargin) / 2, containerView.center.y);
CGPoint translation = CGPointMake(point.x - zeroPoint.x, point.y - zeroPoint.y);
transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
//
transform = CGAffineTransformScale(transform, zoomScale, zoomScale);
CGImageRef imageRef = [self newTransformedImage:transform
sourceImage:imageView.image.CGImage
sourceSize:imageView.image.size
outputWidth:rect.size.width * [UIScreen mainScreen].scale
cropSize:rect.size
imageViewSize:imageView.frame.size];
UIImage *cropedImage = [UIImage imageWithCGImage:imageRef];
cropedImage = [[TZImageManager manager] fixOrientation:cropedImage];
CGImageRelease(imageRef);
return cropedImage;
}
+ (CGImageRef)newTransformedImage:(CGAffineTransform)transform sourceImage:(CGImageRef)sourceImage sourceSize:(CGSize)sourceSize outputWidth:(CGFloat)outputWidth cropSize:(CGSize)cropSize imageViewSize:(CGSize)imageViewSize {
CGImageRef source = [self newScaledImage:sourceImage toSize:sourceSize];
CGFloat aspect = cropSize.height/cropSize.width;
CGSize outputSize = CGSizeMake(outputWidth, outputWidth*aspect);
CGContextRef context = CGBitmapContextCreate(NULL, outputSize.width, outputSize.height, CGImageGetBitsPerComponent(source), 0, CGImageGetColorSpace(source), CGImageGetBitmapInfo(source));
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, CGRectMake(0, 0, outputSize.width, outputSize.height));
CGAffineTransform uiCoords = CGAffineTransformMakeScale(outputSize.width / cropSize.width, outputSize.height / cropSize.height);
uiCoords = CGAffineTransformTranslate(uiCoords, cropSize.width/2.0, cropSize.height / 2.0);
uiCoords = CGAffineTransformScale(uiCoords, 1.0, -1.0);
CGContextConcatCTM(context, uiCoords);
CGContextConcatCTM(context, transform);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, CGRectMake(-imageViewSize.width/2, -imageViewSize.height/2.0, imageViewSize.width, imageViewSize.height), source);
CGImageRef resultRef = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGImageRelease(source);
return resultRef;
}
+ (CGImageRef)newScaledImage:(CGImageRef)source toSize:(CGSize)size {
CGSize srcSize = size;
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, rgbColorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(rgbColorSpace);
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
CGContextTranslateCTM(context, size.width/2, size.height/2);
CGContextDrawImage(context, CGRectMake(-srcSize.width/2, -srcSize.height/2, srcSize.width, srcSize.height), source);
CGImageRef resultRef = CGBitmapContextCreateImage(context);
CGContextRelease(context);
return resultRef;
}
///
+ (UIImage *)circularClipImage:(UIImage *)image {
UIGraphicsBeginImageContextWithOptions(image.size, NO, [UIScreen mainScreen].scale);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
CGContextAddEllipseInRect(ctx, rect);
CGContextClip(ctx);
[image drawInRect:rect];
UIImage *circleImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return circleImage;
}
@end
@implementation UIImage (TZGif)
+ (UIImage *)sd_tz_animatedGIFWithData:(NSData *)data {
if (!data) {
return nil;
}
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
size_t count = CGImageSourceGetCount(source);
UIImage *animatedImage;
if (count <= 1) {
animatedImage = [[UIImage alloc] initWithData:data];
}
else {
// imagescount
NSInteger maxCount = [TZImagePickerConfig sharedInstance].gifPreviewMaxImagesCount ?: 200;
NSInteger interval = MAX((count + maxCount / 2) / maxCount, 1);
NSMutableArray *images = [NSMutableArray array];
NSTimeInterval duration = 0.0f;
for (size_t i = 0; i < count; i+=interval) {
CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL);
if (!image) {
continue;
}
duration += [self sd_frameDurationAtIndex:i source:source] * MIN(interval, 3);
[images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
CGImageRelease(image);
}
if (!duration) {
duration = (1.0f / 10.0f) * count;
}
animatedImage = [UIImage animatedImageWithImages:images duration:duration];
}
CFRelease(source);
return animatedImage;
}
+ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
float frameDuration = 0.1f;
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary];
NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime];
if (delayTimeUnclampedProp) {
frameDuration = [delayTimeUnclampedProp floatValue];
}
else {
NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime];
if (delayTimeProp) {
frameDuration = [delayTimeProp floatValue];
}
}
// Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
// We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
// a duration of <= 10 ms. See <rdar://problem/7689300> and <path_to_url
// for more information.
if (frameDuration < 0.011f) {
frameDuration = 0.100f;
}
CFRelease(cfFrameProperties);
return frameDuration;
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImageCropManager.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,861 |
```objective-c
//
// TZProgressView.h
// TZImagePickerController
//
// Created by ttouch on 2016/12/6.
//
#import <UIKit/UIKit.h>
@interface TZProgressView : UIView
@property (nonatomic, assign) double progress;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZProgressView.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 56 |
```objective-c
//
// TZImagePickerController.h
// TZImagePickerController
//
// Created by on 15/12/24.
// version 2.1.9 - 2018.07.12
// githubpath_to_url
/*
xibTZAssetCell10
@: path_to_url
~
xib......
*/
#import <UIKit/UIKit.h>
#import "TZAssetModel.h"
#import "NSBundle+TZImagePicker.h"
#import "TZImageManager.h"
#import "TZVideoPlayerController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import "TZPhotoPreviewController.h"
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
@class TZAlbumCell, TZAssetCell;
@protocol TZImagePickerControllerDelegate;
@interface TZImagePickerController : UINavigationController
#pragma mark -
/// Use this init method /
- (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount delegate:(id<TZImagePickerControllerDelegate>)delegate;
- (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount columnNumber:(NSInteger)columnNumber delegate:(id<TZImagePickerControllerDelegate>)delegate;
- (instancetype)initWithMaxImagesCount:(NSInteger)maxImagesCount columnNumber:(NSInteger)columnNumber delegate:(id<TZImagePickerControllerDelegate>)delegate pushPhotoPickerVc:(BOOL)pushPhotoPickerVc;
/// This init method just for previewing photos /
- (instancetype)initWithSelectedAssets:(NSMutableArray *)selectedAssets selectedPhotos:(NSMutableArray *)selectedPhotos index:(NSInteger)index;
/// This init method for crop photo /
- (instancetype)initCropTypeWithAsset:(id)asset photo:(UIImage *)photo completion:(void (^)(UIImage *cropImage,id asset))completion;
#pragma mark -
/// Default is 9 / 9
@property (nonatomic, assign) NSInteger maxImagesCount;
/// The minimum count photos user must pick, Default is 0
/// ,0
@property (nonatomic, assign) NSInteger minImagesCount;
/// Always enale the done button, not require minimum 1 photo be picked
///
@property (nonatomic, assign) BOOL alwaysEnableDoneBtn;
/// Sort photos ascending by modificationDateDefault is YES
/// YESNO,
@property (nonatomic, assign) BOOL sortAscendingByModificationDate;
/// The pixel width of output image, Default is 828px / 828
@property (nonatomic, assign) CGFloat photoWidth;
/// Default is 600px / 600
@property (nonatomic, assign) CGFloat photoPreviewMaxWidth;
/// Default is 15, While fetching photo, HUD will dismiss automatic if timeout;
/// 1515dismiss HUD
@property (nonatomic, assign) NSInteger timeout;
/// Default is YES, if set NO, the original photo button will hide. user can't picking original photo.
/// YESNO,
@property (nonatomic, assign) BOOL allowPickingOriginalPhoto;
/// Default is YES, if set NO, user can't picking video.
/// YESNO,
@property (nonatomic, assign) BOOL allowPickingVideo;
/// Default is NO / NOYES/gifmaxImagesCount
@property (nonatomic, assign) BOOL allowPickingMultipleVideo;
/// Default is NO, if set YES, user can picking gif image.
/// NOYES,gif
@property (nonatomic, assign) BOOL allowPickingGif;
/// Default is YES, if set NO, user can't picking image.
/// YESNO,
@property (nonatomic, assign) BOOL allowPickingImage;
/// Default is YES, if set NO, user can't take picture.
/// YESNO,
@property (nonatomic, assign) BOOL allowTakePicture;
@property (nonatomic, assign) BOOL allowCameraLocation;
/// Default is YES, if set NO, user can't take video.
/// YESNO,
@property(nonatomic, assign) BOOL allowTakeVideo;
/// Default value is 10 minutes / 10
@property (assign, nonatomic) NSTimeInterval videoMaximumDuration;
/// Customizing UIImagePickerController's other properties, such as videoQuality / UIImagePickerControllervideoQuality
@property (nonatomic, copy) void(^uiImagePickerControllerSettingBlock)(UIImagePickerController *imagePickerController);
///
/// zh-Hanszh-Hantenvi
@property (copy, nonatomic) NSString *preferredLanguage;
/// bundlepreferredLanguagelanguageBundle
/// bundlepreferredLanguagelanguageBundlePR~
@property (strong, nonatomic) NSBundle *languageBundle;
/// Default is YES, if set NO, user can't preview photo.
/// YESNO,,
@property (nonatomic, assign) BOOL allowPreview;
/// Default is YES, if set NO, the picker don't dismiss itself.
/// YESNO, dismiss
@property(nonatomic, assign) BOOL autoDismiss;
/// Default is NO, if set YES, in the delegate method the photos and infos will be nil, only assets hava value.
/// NOYESphotosinfosnilassets
@property (assign, nonatomic) BOOL onlyReturnAsset;
/// Default is NO, if set YES, will show the image's selected index.
/// NOYES
@property (assign, nonatomic) BOOL showSelectedIndex;
/// Default is NO, if set YES, when selected photos's count up to maxImagesCount, other photo will show float layer what's color is cannotSelectLayerColor.
/// NOYESmaxImagesCountcannotSelectLayerColor
@property (assign, nonatomic) BOOL showPhotoCannotSelectLayer;
/// Default is white color with 0.8 alpha;
@property (strong, nonatomic) UIColor *cannotSelectLayerColor;
/// Default is No, if set YES, the result photo will not be scaled to photoWidth pixel width. The photoWidth default is 828px
/// NOYESphotoWidth
@property (assign, nonatomic) BOOL notScaleImage;
/// The photos user have selected
///
@property (nonatomic, strong) NSMutableArray *selectedAssets;
@property (nonatomic, strong) NSMutableArray<TZAssetModel *> *selectedModels;
@property (nonatomic, strong) NSMutableArray *selectedAssetIds;
- (void)addSelectedModel:(TZAssetModel *)model;
- (void)removeSelectedModel:(TZAssetModel *)model;
/// Minimum selectable photo width, Default is 0
/// 0
@property (nonatomic, assign) NSInteger minPhotoWidthSelectable;
@property (nonatomic, assign) NSInteger minPhotoHeightSelectable;
/// Hide the photo what can not be selected, Default is NO
/// NOYES
@property (nonatomic, assign) BOOL hideWhenCanNotSelect;
/// Deprecated, Use statusBarStyle (statusBar NO)
@property (nonatomic, assign) BOOL isStatusBarDefault __attribute__((deprecated("Use -statusBarStyle.")));
/// statusBarUIStatusBarStyleLightContent
@property (assign, nonatomic) UIStatusBarStyle statusBarStyle;
#pragma mark -
/// Single selection mode, valid when maxImagesCount = 1
/// ,maxImagesCount1
@property (nonatomic, assign) BOOL showSelectBtn; ///< ,NO
@property (nonatomic, assign) BOOL allowCrop; ///< ,YESshowSelectBtnNO
@property (nonatomic, assign) CGRect cropRect; ///<
@property (nonatomic, assign) CGRect cropRectPortrait; ///< ()
@property (nonatomic, assign) CGRect cropRectLandscape; ///< ()
@property (nonatomic, assign) BOOL needCircleCrop; ///<
@property (nonatomic, assign) NSInteger circleCropRadius; ///<
@property (nonatomic, copy) void (^cropViewSettingBlock)(UIView *cropView); ///<
@property (nonatomic, copy) void (^navLeftBarButtonSettingBlock)(UIButton *leftButton); ///<
/// //setModel
@property (nonatomic, copy) void (^photoPickerPageUIConfigBlock)(UICollectionView *collectionView, UIView *bottomToolBar, UIButton *previewButton, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel, UIView *divideLine);
@property (nonatomic, copy) void (^photoPreviewPageUIConfigBlock)(UICollectionView *collectionView, UIView *naviBar, UIButton *backButton, UIButton *selectButton, UILabel *indexLabel, UIView *toolBar, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel);
@property (nonatomic, copy) void (^videoPreviewPageUIConfigBlock)(UIButton *playButton, UIView *toolBar, UIButton *doneButton);
@property (nonatomic, copy) void (^gifPreviewPageUIConfigBlock)(UIView *toolBar, UIButton *doneButton);
@property (nonatomic, copy) void (^assetCellDidSetModelBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@property (nonatomic, copy) void (^albumCellDidSetModelBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel);
/// /frameviewDidLayoutSubviews/layoutSubviewsframe
@property (nonatomic, copy) void (^photoPickerPageDidLayoutSubviewsBlock)(UICollectionView *collectionView, UIView *bottomToolBar, UIButton *previewButton, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel, UIView *divideLine);
@property (nonatomic, copy) void (^photoPreviewPageDidLayoutSubviewsBlock)(UICollectionView *collectionView, UIView *naviBar, UIButton *backButton, UIButton *selectButton, UILabel *indexLabel, UIView *toolBar, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel);
@property (nonatomic, copy) void (^videoPreviewPageDidLayoutSubviewsBlock)(UIButton *playButton, UIView *toolBar, UIButton *doneButton);
@property (nonatomic, copy) void (^gifPreviewPageDidLayoutSubviewsBlock)(UIView *toolBar, UIButton *doneButton);
@property (nonatomic, copy) void (^assetCellDidLayoutSubviewsBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@property (nonatomic, copy) void (^albumCellDidLayoutSubviewsBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel);
#pragma mark -
- (id)showAlertWithTitle:(NSString *)title;
- (void)hideAlertView:(id)alertView;
- (void)showProgressHUD;
- (void)hideProgressHUD;
@property (nonatomic, assign) BOOL isSelectOriginalPhoto;
@property (assign, nonatomic) BOOL needShowStatusBar;
#pragma mark -
@property (nonatomic, copy) NSString *takePictureImageName __attribute__((deprecated("Use -takePictureImage.")));
@property (nonatomic, copy) NSString *photoSelImageName __attribute__((deprecated("Use -photoSelImage.")));
@property (nonatomic, copy) NSString *photoDefImageName __attribute__((deprecated("Use -photoDefImage.")));
@property (nonatomic, copy) NSString *photoOriginSelImageName __attribute__((deprecated("Use -photoOriginSelImage.")));
@property (nonatomic, copy) NSString *photoOriginDefImageName __attribute__((deprecated("Use -photoOriginDefImage.")));
@property (nonatomic, copy) NSString *photoPreviewOriginDefImageName __attribute__((deprecated("Use -photoPreviewOriginDefImage.")));
@property (nonatomic, copy) NSString *photoNumberIconImageName __attribute__((deprecated("Use -photoNumberIconImage.")));
@property (nonatomic, strong) UIImage *takePictureImage;
@property (nonatomic, strong) UIImage *photoSelImage;
@property (nonatomic, strong) UIImage *photoDefImage;
@property (nonatomic, strong) UIImage *photoOriginSelImage;
@property (nonatomic, strong) UIImage *photoOriginDefImage;
@property (nonatomic, strong) UIImage *photoPreviewOriginDefImage;
@property (nonatomic, strong) UIImage *photoNumberIconImage;
#pragma mark -
/// Appearance / +
@property (nonatomic, strong) UIColor *oKButtonTitleColorNormal;
@property (nonatomic, strong) UIColor *oKButtonTitleColorDisabled;
@property (nonatomic, strong) UIColor *naviBgColor;
@property (nonatomic, strong) UIColor *naviTitleColor;
@property (nonatomic, strong) UIFont *naviTitleFont;
@property (nonatomic, strong) UIColor *barItemTextColor;
@property (nonatomic, strong) UIFont *barItemTextFont;
@property (nonatomic, copy) NSString *doneBtnTitleStr;
@property (nonatomic, copy) NSString *cancelBtnTitleStr;
@property (nonatomic, copy) NSString *previewBtnTitleStr;
@property (nonatomic, copy) NSString *fullImageBtnTitleStr;
@property (nonatomic, copy) NSString *settingBtnTitleStr;
@property (nonatomic, copy) NSString *processHintStr;
/// Icon theme color, default is green color like wechat, the value is r:31 g:185 b:34. Currently only support image selection icon when showSelectedIndex is YES. If you need it, please set it as soon as possible
/// iconr:31 g:185 b:34showSelectedIndexYESicon
@property (strong, nonatomic) UIColor *iconThemeColor;
#pragma mark -
- (void)cancelButtonClick;
// The picker should dismiss itself; when it dismissed these handle will be called.
// You can also set autoDismiss to NO, then the picker don't dismiss itself.
// If isOriginalPhoto is YES, user picked the original photo.
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// dismissdismisshandle
// autoDismissNOdismis
// isSelectOriginalPhotoYES
// asset[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// photosUIImage828photoWidth
@property (nonatomic, copy) void (^didFinishPickingPhotosHandle)(NSArray<UIImage *> *photos,NSArray *assets,BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^didFinishPickingPhotosWithInfosHandle)(NSArray<UIImage *> *photos,NSArray *assets,BOOL isSelectOriginalPhoto,NSArray<NSDictionary *> *infos);
@property (nonatomic, copy) void (^imagePickerControllerDidCancelHandle)(void);
// If user picking a video, this handle will be called.
// If system version > iOS8,asset is kind of PHAsset class, else is ALAsset class.
// handle
// iOS8assetPHAssetALAsset
@property (nonatomic, copy) void (^didFinishPickingVideoHandle)(UIImage *coverImage,id asset);
// If user picking a gif image, this callback will be called.
// gifhandle
@property (nonatomic, copy) void (^didFinishPickingGifImageHandle)(UIImage *animatedImage,id sourceAssets);
@property (nonatomic, weak) id<TZImagePickerControllerDelegate> pickerDelegate;
@end
@protocol TZImagePickerControllerDelegate <NSObject>
@optional
// The picker should dismiss itself; when it dismissed these handle will be called.
// You can also set autoDismiss to NO, then the picker don't dismiss itself.
// If isOriginalPhoto is YES, user picked the original photo.
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// dismissdismisshandle
// autoDismissNOdismis
// isSelectOriginalPhotoYES
// asset[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// photosUIImage828photoWidth
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto;
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos;
//- (void)imagePickerControllerDidCancel:(TZImagePickerController *)picker __attribute__((deprecated("Use -tz_imagePickerControllerDidCancel:.")));
- (void)tz_imagePickerControllerDidCancel:(TZImagePickerController *)picker;
// If user picking a video, this callback will be called.
// If system version > iOS8,asset is kind of PHAsset class, else is ALAsset class.
// handle
// iOS8assetPHAssetALAsset
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingVideo:(UIImage *)coverImage sourceAssets:(id)asset;
// If user picking a gif image, this callback will be called.
// gifhandle
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingGifImage:(UIImage *)animatedImage sourceAssets:(id)asset;
// Decide album show or not't
// albumName: result:
- (BOOL)isAlbumCanSelect:(NSString *)albumName result:(id)result;
// Decide asset show or not't
//
- (BOOL)isAssetCanSelect:(id)asset;
@end
@interface TZAlbumPickerController : UIViewController
@property (nonatomic, assign) NSInteger columnNumber;
@property (assign, nonatomic) BOOL isFirstAppear;
- (void)configTableView;
@end
@interface UIImage (MyBundle)
+ (UIImage *)imageNamedFromMyBundle:(NSString *)name;
@end
@interface NSString (TzExtension)
- (BOOL)tz_containsString:(NSString *)string;
- (CGSize)tz_calculateSizeWithAttributes:(NSDictionary *)attributes maxSize:(CGSize)maxSize;
@end
@interface TZCommonTools : NSObject
+ (BOOL)tz_isIPhoneX;
+ (CGFloat)tz_statusBarHeight;
// Info.plist
+ (NSDictionary *)tz_getInfoDictionary;
@end
@interface TZImagePickerConfig : NSObject
+ (instancetype)sharedInstance;
@property (copy, nonatomic) NSString *preferredLanguage;
@property(nonatomic, assign) BOOL allowPickingImage;
@property (nonatomic, assign) BOOL allowPickingVideo;
@property (strong, nonatomic) NSBundle *languageBundle;
/// 200GIF1000
@property (assign, nonatomic) NSInteger gifPreviewMaxImagesCount;
@property (assign, nonatomic) BOOL showSelectedIndex;
@property (assign, nonatomic) BOOL showPhotoCannotSelectLayer;
@property (assign, nonatomic) BOOL notScaleImage;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImagePickerController.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 3,827 |
```objective-c
//
// TZAssetCell.h
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
typedef enum : NSUInteger {
TZAssetCellTypePhoto = 0,
TZAssetCellTypeLivePhoto,
TZAssetCellTypePhotoGif,
TZAssetCellTypeVideo,
TZAssetCellTypeAudio,
} TZAssetCellType;
@class TZAssetModel;
@interface TZAssetCell : UICollectionViewCell
@property (weak, nonatomic) UIButton *selectPhotoButton;
@property (weak, nonatomic) UIButton *cannotSelectLayerButton;
@property (nonatomic, strong) TZAssetModel *model;
@property (assign, nonatomic) NSInteger index;
@property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL);
@property (nonatomic, assign) TZAssetCellType type;
@property (nonatomic, assign) BOOL allowPickingGif;
@property (nonatomic, assign) BOOL allowPickingMultipleVideo;
@property (nonatomic, copy) NSString *representedAssetIdentifier;
@property (nonatomic, assign) int32_t imageRequestID;
@property (nonatomic, strong) UIImage *photoSelImage;
@property (nonatomic, strong) UIImage *photoDefImage;
@property (nonatomic, assign) BOOL showSelectBtn;
@property (assign, nonatomic) BOOL allowPreview;
@property (assign, nonatomic) BOOL useCachedImage;
@property (nonatomic, copy) void (^assetCellDidSetModelBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@property (nonatomic, copy) void (^assetCellDidLayoutSubviewsBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@end
@class TZAlbumModel;
@interface TZAlbumCell : UITableViewCell
@property (nonatomic, strong) TZAlbumModel *model;
@property (weak, nonatomic) UIButton *selectedCountButton;
@property (nonatomic, copy) void (^albumCellDidSetModelBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel);
@property (nonatomic, copy) void (^albumCellDidLayoutSubviewsBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel);
@end
@interface TZAssetCameraCell : UICollectionViewCell
@property (nonatomic, strong) UIImageView *imageView;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZAssetCell.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 509 |
```objective-c
//
// TZPhotoPickerController.h
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import <UIKit/UIKit.h>
@class TZAlbumModel;
@interface TZPhotoPickerController : UIViewController
@property (nonatomic, assign) BOOL isFirstAppear;
@property (nonatomic, assign) NSInteger columnNumber;
@property (nonatomic, strong) TZAlbumModel *model;
@end
@interface TZCollectionView : UICollectionView
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZPhotoPickerController.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 90 |
```objective-c
//
// TZImageManager.m
// TZImagePickerController
//
// Created by on 16/1/4.
//
#import "TZImageManager.h"
#import <AssetsLibrary/AssetsLibrary.h>
#import "TZAssetModel.h"
#import "TZImagePickerController.h"
@interface TZImageManager ()
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (nonatomic, strong) ALAssetsLibrary *assetLibrary;
@end
@implementation TZImageManager
CGSize AssetGridThumbnailSize;
CGFloat TZScreenWidth;
CGFloat TZScreenScale;
static TZImageManager *manager;
static dispatch_once_t onceToken;
+ (instancetype)manager {
dispatch_once(&onceToken, ^{
manager = [[self alloc] init];
if (iOS8Later) {
// manager.cachingImageManager = [[PHCachingImageManager alloc] init];
// manager.cachingImageManager.allowsCachingHighQualityImages = YES;
}
[manager configTZScreenWidth];
});
return manager;
}
+ (void)deallocManager {
onceToken = 0;
manager = nil;
}
- (void)setPhotoWidth:(CGFloat)photoWidth {
_photoWidth = photoWidth;
TZScreenWidth = photoWidth / 2;
}
- (void)setColumnNumber:(NSInteger)columnNumber {
[self configTZScreenWidth];
_columnNumber = columnNumber;
CGFloat margin = 4;
CGFloat itemWH = (TZScreenWidth - 2 * margin - 4) / columnNumber - margin;
AssetGridThumbnailSize = CGSizeMake(itemWH * TZScreenScale, itemWH * TZScreenScale);
}
- (void)configTZScreenWidth {
TZScreenWidth = [UIScreen mainScreen].bounds.size.width;
// scaleplus3.02.0
TZScreenScale = 2.0;
if (TZScreenWidth > 700) {
TZScreenScale = 1.5;
}
}
- (ALAssetsLibrary *)assetLibrary {
if (_assetLibrary == nil) _assetLibrary = [[ALAssetsLibrary alloc] init];
return _assetLibrary;
}
/// Return YES if Authorized YES
- (BOOL)authorizationStatusAuthorized {
NSInteger status = [self.class authorizationStatus];
if (status == 0) {
/**
* AuthorizationStatus == AuthorizationStatusNotDeterminedalertViewalertView
*/
[self requestAuthorizationWithCompletion:nil];
}
return status == 3;
}
+ (NSInteger)authorizationStatus {
if (iOS8Later) {
return [PHPhotoLibrary authorizationStatus];
} else {
return [ALAssetsLibrary authorizationStatus];
}
return NO;
}
- (void)requestAuthorizationWithCompletion:(void (^)(void))completion {
void (^callCompletionBlock)(void) = ^(){
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) {
completion();
}
});
};
if (iOS8Later) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
callCompletionBlock();
}];
});
} else {
[self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
callCompletionBlock();
} failureBlock:^(NSError *error) {
callCompletionBlock();
}];
}
}
#pragma mark - Get Album
/// Get Album /
- (void)getCameraRollAlbum:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage needFetchAssets:(BOOL)needFetchAssets completion:(void (^)(TZAlbumModel *model))completion {
__block TZAlbumModel *model;
if (iOS8Later) {
PHFetchOptions *option = [[PHFetchOptions alloc] init];
if (!allowPickingVideo) option.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld", PHAssetMediaTypeImage];
if (!allowPickingImage) option.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld",
PHAssetMediaTypeVideo];
// option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"modificationDate" ascending:self.sortAscendingByModificationDate]];
if (!self.sortAscendingByModificationDate) {
option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:self.sortAscendingByModificationDate]];
}
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
for (PHAssetCollection *collection in smartAlbums) {
// PHCollectionList
if (![collection isKindOfClass:[PHAssetCollection class]]) continue;
//
if (collection.estimatedAssetCount <= 0) continue;
if ([self isCameraRollAlbum:collection]) {
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
model = [self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES needFetchAssets:needFetchAssets];
if (completion) completion(model);
break;
}
}
} else {
[self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if ([group numberOfAssets] < 1) return;
if ([self isCameraRollAlbum:group]) {
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
model = [self modelWithResult:group name:name isCameraRoll:YES needFetchAssets:needFetchAssets];
if (completion) completion(model);
*stop = YES;
}
} failureBlock:nil];
}
}
- (void)getAllAlbums:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage needFetchAssets:(BOOL)needFetchAssets completion:(void (^)(NSArray<TZAlbumModel *> *))completion{
NSMutableArray *albumArr = [NSMutableArray array];
if (iOS8Later) {
PHFetchOptions *option = [[PHFetchOptions alloc] init];
if (!allowPickingVideo) option.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld", PHAssetMediaTypeImage];
if (!allowPickingImage) option.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld",
PHAssetMediaTypeVideo];
// option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"modificationDate" ascending:self.sortAscendingByModificationDate]];
if (!self.sortAscendingByModificationDate) {
option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:self.sortAscendingByModificationDate]];
}
// 1.6.10..
PHFetchResult *myPhotoStreamAlbum = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumMyPhotoStream options:nil];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
PHFetchResult *topLevelUserCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
PHFetchResult *syncedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumSyncedAlbum options:nil];
PHFetchResult *sharedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumCloudShared options:nil];
NSArray *allAlbums = @[myPhotoStreamAlbum,smartAlbums,topLevelUserCollections,syncedAlbums,sharedAlbums];
for (PHFetchResult *fetchResult in allAlbums) {
for (PHAssetCollection *collection in fetchResult) {
// PHCollectionList
if (![collection isKindOfClass:[PHAssetCollection class]]) continue;
//
if (collection.estimatedAssetCount <= 0) continue;
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
if (fetchResult.count < 1) continue;
if ([self.pickerDelegate respondsToSelector:@selector(isAlbumCanSelect:result:)]) {
if (![self.pickerDelegate isAlbumCanSelect:collection.localizedTitle result:fetchResult]) {
continue;
}
}
if (collection.assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumAllHidden) continue;
if (collection.assetCollectionSubtype == 1000000201) continue; //
if ([self isCameraRollAlbum:collection]) {
[albumArr insertObject:[self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES needFetchAssets:needFetchAssets] atIndex:0];
} else {
[albumArr addObject:[self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:NO needFetchAssets:needFetchAssets]];
}
}
}
if (completion && albumArr.count > 0) completion(albumArr);
} else {
[self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group == nil) {
if (completion && albumArr.count > 0) completion(albumArr);
}
if ([group numberOfAssets] < 1) return;
NSString *name = [group valueForProperty:ALAssetsGroupPropertyName];
if ([self.pickerDelegate respondsToSelector:@selector(isAlbumCanSelect:result:)]) {
if (![self.pickerDelegate isAlbumCanSelect:name result:group]) {
return;
}
}
if ([self isCameraRollAlbum:group]) {
[albumArr insertObject:[self modelWithResult:group name:name isCameraRoll:YES needFetchAssets:needFetchAssets] atIndex:0];
} else if ([[group valueForProperty:ALAssetsGroupPropertyType] intValue] == ALAssetsGroupPhotoStream) {
if (albumArr.count) {
[albumArr insertObject:[self modelWithResult:group name:name isCameraRoll:NO needFetchAssets:needFetchAssets] atIndex:1];
} else {
[albumArr addObject:[self modelWithResult:group name:name isCameraRoll:NO needFetchAssets:needFetchAssets]];
}
} else {
[albumArr addObject:[self modelWithResult:group name:name isCameraRoll:NO needFetchAssets:needFetchAssets]];
}
} failureBlock:nil];
}
}
#pragma mark - Get Assets
/// Get Assets
- (void)getAssetsFromFetchResult:(id)result completion:(void (^)(NSArray<TZAssetModel *> *))completion {
TZImagePickerConfig *config = [TZImagePickerConfig sharedInstance];
return [self getAssetsFromFetchResult:result allowPickingVideo:config.allowPickingVideo allowPickingImage:config.allowPickingImage completion:completion];
}
- (void)getAssetsFromFetchResult:(id)result allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(NSArray<TZAssetModel *> *))completion {
NSMutableArray *photoArr = [NSMutableArray array];
if ([result isKindOfClass:[PHFetchResult class]]) {
PHFetchResult *fetchResult = (PHFetchResult *)result;
[fetchResult enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
TZAssetModel *model = [self assetModelWithAsset:obj allowPickingVideo:allowPickingVideo allowPickingImage:allowPickingImage];
if (model) {
[photoArr addObject:model];
}
}];
if (completion) completion(photoArr);
} else if ([result isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = (ALAssetsGroup *)result;
if (allowPickingImage && allowPickingVideo) {
[group setAssetsFilter:[ALAssetsFilter allAssets]];
} else if (allowPickingVideo) {
[group setAssetsFilter:[ALAssetsFilter allVideos]];
} else if (allowPickingImage) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
}
ALAssetsGroupEnumerationResultsBlock resultBlock = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (result == nil) {
if (completion) completion(photoArr);
}
TZAssetModel *model = [self assetModelWithAsset:result allowPickingVideo:allowPickingVideo allowPickingImage:allowPickingImage];
if (model) {
[photoArr addObject:model];
}
};
if (self.sortAscendingByModificationDate) {
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (resultBlock) { resultBlock(result,index,stop); }
}];
} else {
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (resultBlock) { resultBlock(result,index,stop); }
}];
}
}
}
/// Get asset at index index
/// if index beyond bounds, return nil in callback , nil
- (void)getAssetFromFetchResult:(id)result atIndex:(NSInteger)index allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(TZAssetModel *))completion {
if ([result isKindOfClass:[PHFetchResult class]]) {
PHFetchResult *fetchResult = (PHFetchResult *)result;
PHAsset *asset;
@try {
asset = fetchResult[index];
}
@catch (NSException* e) {
if (completion) completion(nil);
return;
}
TZAssetModel *model = [self assetModelWithAsset:asset allowPickingVideo:allowPickingVideo allowPickingImage:allowPickingImage];
if (completion) completion(model);
} else if ([result isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = (ALAssetsGroup *)result;
if (allowPickingImage && allowPickingVideo) {
[group setAssetsFilter:[ALAssetsFilter allAssets]];
} else if (allowPickingVideo) {
[group setAssetsFilter:[ALAssetsFilter allVideos]];
} else if (allowPickingImage) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
}
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:index];
@try {
[group enumerateAssetsAtIndexes:indexSet options:NSEnumerationConcurrent usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (!result) return;
TZAssetModel *model = [self assetModelWithAsset:result allowPickingVideo:allowPickingVideo allowPickingImage:allowPickingImage];
if (completion) completion(model);
}];
}
@catch (NSException* e) {
if (completion) completion(nil);
}
}
}
- (TZAssetModel *)assetModelWithAsset:(id)asset allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage {
BOOL canSelect = YES;
if ([self.pickerDelegate respondsToSelector:@selector(isAssetCanSelect:)]) {
canSelect = [self.pickerDelegate isAssetCanSelect:asset];
}
if (!canSelect) return nil;
TZAssetModel *model;
TZAssetModelMediaType type = [self getAssetType:asset];
if ([asset isKindOfClass:[PHAsset class]]) {
if (!allowPickingVideo && type == TZAssetModelMediaTypeVideo) return nil;
if (!allowPickingImage && type == TZAssetModelMediaTypePhoto) return nil;
if (!allowPickingImage && type == TZAssetModelMediaTypePhotoGif) return nil;
PHAsset *phAsset = (PHAsset *)asset;
if (self.hideWhenCanNotSelect) {
//
if (![self isPhotoSelectableWithAsset:phAsset]) {
return nil;
}
}
NSString *timeLength = type == TZAssetModelMediaTypeVideo ? [NSString stringWithFormat:@"%0.0f",phAsset.duration] : @"";
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
model = [TZAssetModel modelWithAsset:asset type:type timeLength:timeLength];
} else {
if (!allowPickingVideo){
model = [TZAssetModel modelWithAsset:asset type:type];
return model;
}
/// Allow picking video
if (type == TZAssetModelMediaTypeVideo) {
NSTimeInterval duration = [[asset valueForProperty:ALAssetPropertyDuration] doubleValue];
NSString *timeLength = [NSString stringWithFormat:@"%0.0f",duration];
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
model = [TZAssetModel modelWithAsset:asset type:type timeLength:timeLength];
} else {
if (self.hideWhenCanNotSelect) {
//
if (![self isPhotoSelectableWithAsset:asset]) {
return nil;
}
}
model = [TZAssetModel modelWithAsset:asset type:type];
}
}
return model;
}
- (TZAssetModelMediaType)getAssetType:(id)asset {
TZAssetModelMediaType type = TZAssetModelMediaTypePhoto;
if ([asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = (PHAsset *)asset;
if (phAsset.mediaType == PHAssetMediaTypeVideo) type = TZAssetModelMediaTypeVideo;
else if (phAsset.mediaType == PHAssetMediaTypeAudio) type = TZAssetModelMediaTypeAudio;
else if (phAsset.mediaType == PHAssetMediaTypeImage) {
if (@available(iOS 9.1, *)) {
// if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) type = TZAssetModelMediaTypeLivePhoto;
}
// Gif
if ([[phAsset valueForKey:@"filename"] hasSuffix:@"GIF"]) {
type = TZAssetModelMediaTypePhotoGif;
}
}
} else {
if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
type = TZAssetModelMediaTypeVideo;
}
}
return type;
}
- (NSString *)getNewTimeFromDurationSecond:(NSInteger)duration {
NSString *newTime;
if (duration < 10) {
newTime = [NSString stringWithFormat:@"0:0%zd",duration];
} else if (duration < 60) {
newTime = [NSString stringWithFormat:@"0:%zd",duration];
} else {
NSInteger min = duration / 60;
NSInteger sec = duration - (min * 60);
if (sec < 10) {
newTime = [NSString stringWithFormat:@"%zd:0%zd",min,sec];
} else {
newTime = [NSString stringWithFormat:@"%zd:%zd",min,sec];
}
}
return newTime;
}
/// Get photo bytes
- (void)getPhotosBytesWithArray:(NSArray *)photos completion:(void (^)(NSString *totalBytes))completion {
if (!photos || !photos.count) {
if (completion) completion(@"0B");
return;
}
__block NSInteger dataLength = 0;
__block NSInteger assetCount = 0;
for (NSInteger i = 0; i < photos.count; i++) {
TZAssetModel *model = photos[i];
if ([model.asset isKindOfClass:[PHAsset class]]) {
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.resizeMode = PHImageRequestOptionsResizeModeFast;
options.networkAccessAllowed = YES;
if ([[model.asset valueForKey:@"filename"] hasSuffix:@"GIF"]) {
options.version = PHImageRequestOptionsVersionOriginal;
}
[[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
if (model.type != TZAssetModelMediaTypeVideo) dataLength += imageData.length;
assetCount ++;
if (assetCount >= photos.count) {
NSString *bytes = [self getBytesFromDataLength:dataLength];
if (completion) completion(bytes);
}
}];
} else if ([model.asset isKindOfClass:[ALAsset class]]) {
ALAssetRepresentation *representation = [model.asset defaultRepresentation];
if (model.type != TZAssetModelMediaTypeVideo) dataLength += (NSInteger)representation.size;
if (i >= photos.count - 1) {
NSString *bytes = [self getBytesFromDataLength:dataLength];
if (completion) completion(bytes);
}
}
}
}
- (NSString *)getBytesFromDataLength:(NSInteger)dataLength {
NSString *bytes;
if (dataLength >= 0.1 * (1024 * 1024)) {
bytes = [NSString stringWithFormat:@"%0.1fM",dataLength/1024/1024.0];
} else if (dataLength >= 1024) {
bytes = [NSString stringWithFormat:@"%0.0fK",dataLength/1024.0];
} else {
bytes = [NSString stringWithFormat:@"%zdB",dataLength];
}
return bytes;
}
#pragma mark - Get Photo
/// Get photo
- (int32_t)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *, NSDictionary *, BOOL isDegraded))completion {
CGFloat fullScreenWidth = TZScreenWidth;
if (fullScreenWidth > _photoPreviewMaxWidth) {
fullScreenWidth = _photoPreviewMaxWidth;
}
return [self getPhotoWithAsset:asset photoWidth:fullScreenWidth completion:completion progressHandler:nil networkAccessAllowed:YES];
}
- (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion {
return [self getPhotoWithAsset:asset photoWidth:photoWidth completion:completion progressHandler:nil networkAccessAllowed:YES];
}
- (int32_t)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed {
CGFloat fullScreenWidth = TZScreenWidth;
if (fullScreenWidth > _photoPreviewMaxWidth) {
fullScreenWidth = _photoPreviewMaxWidth;
}
return [self getPhotoWithAsset:asset photoWidth:fullScreenWidth completion:completion progressHandler:progressHandler networkAccessAllowed:networkAccessAllowed];
}
- (int32_t)requestImageDataForAsset:(id)asset completion:(void (^)(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler {
if ([asset isKindOfClass:[PHAsset class]]) {
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
if (progressHandler) {
progressHandler(progress, error, stop, info);
}
});
};
options.networkAccessAllowed = YES;
options.resizeMode = PHImageRequestOptionsResizeModeFast;
int32_t imageRequestID = [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
if (completion) completion(imageData,dataUTI,orientation,info);
}];
return imageRequestID;
} else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset;
dispatch_async(dispatch_get_global_queue(0,0), ^{
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
CGImageRef fullScrennImageRef = [assetRep fullScreenImage];
UIImage *fullScrennImage = [UIImage imageWithCGImage:fullScrennImageRef scale:2.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(UIImageJPEGRepresentation(fullScrennImage, 0.83), nil, UIImageOrientationUp, nil);
});
});
}
return 0;
}
- (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed {
if ([asset isKindOfClass:[PHAsset class]]) {
CGSize imageSize;
if (photoWidth < TZScreenWidth && photoWidth < _photoPreviewMaxWidth) {
imageSize = AssetGridThumbnailSize;
} else {
PHAsset *phAsset = (PHAsset *)asset;
CGFloat aspectRatio = phAsset.pixelWidth / (CGFloat)phAsset.pixelHeight;
CGFloat pixelWidth = photoWidth * TZScreenScale * 1.5;
//
if (aspectRatio > 1.8) {
pixelWidth = pixelWidth * aspectRatio;
}
//
if (aspectRatio < 0.2) {
pixelWidth = pixelWidth * 0.5;
}
CGFloat pixelHeight = pixelWidth / aspectRatio;
imageSize = CGSizeMake(pixelWidth, pixelHeight);
}
__block UIImage *image;
//
// hsjcomgithubpath_to_url
PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.resizeMode = PHImageRequestOptionsResizeModeFast;
int32_t imageRequestID = [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:imageSize contentMode:PHImageContentModeAspectFill options:option resultHandler:^(UIImage *result, NSDictionary *info) {
if (result) {
image = result;
}
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]);
if (downloadFinined && result) {
result = [self fixOrientation:result];
if (completion) completion(result,info,[[info objectForKey:PHImageResultIsDegradedKey] boolValue]);
}
// Download image from iCloud / iCloud
if ([info objectForKey:PHImageResultIsInCloudKey] && !result && networkAccessAllowed) {
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
if (progressHandler) {
progressHandler(progress, error, stop, info);
}
});
};
options.networkAccessAllowed = YES;
options.resizeMode = PHImageRequestOptionsResizeModeFast;
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
UIImage *resultImage = [UIImage imageWithData:imageData scale:0.1];
if (![TZImagePickerConfig sharedInstance].notScaleImage) {
resultImage = [self scaleImage:resultImage toSize:imageSize];
}
if (!resultImage) {
resultImage = image;
}
resultImage = [self fixOrientation:resultImage];
if (completion) completion(resultImage,info,NO);
}];
}
}];
return imageRequestID;
} else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset;
dispatch_async(dispatch_get_global_queue(0,0), ^{
CGImageRef thumbnailImageRef = alAsset.thumbnail;
UIImage *thumbnailImage = [UIImage imageWithCGImage:thumbnailImageRef scale:2.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(thumbnailImage,nil,YES);
if (photoWidth == TZScreenWidth || photoWidth == self->_photoPreviewMaxWidth) {
dispatch_async(dispatch_get_global_queue(0,0), ^{
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
CGImageRef fullScrennImageRef = [assetRep fullScreenImage];
UIImage *fullScrennImage = [UIImage imageWithCGImage:fullScrennImageRef scale:2.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(fullScrennImage,nil,NO);
});
});
}
});
});
}
return 0;
}
/// Get postImage /
- (void)getPostImageWithAlbumModel:(TZAlbumModel *)model completion:(void (^)(UIImage *))completion {
if (iOS8Later) {
id asset = [model.result lastObject];
if (!self.sortAscendingByModificationDate) {
asset = [model.result firstObject];
}
[[TZImageManager manager] getPhotoWithAsset:asset photoWidth:80 completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (completion) completion(photo);
}];
} else {
ALAssetsGroup *group = model.result;
UIImage *postImage = [UIImage imageWithCGImage:group.posterImage];
if (completion) completion(postImage);
}
}
/// Get Original Photo /
- (void)getOriginalPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info))completion {
[self getOriginalPhotoWithAsset:asset newCompletion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (completion) {
completion(photo,info);
}
}];
}
- (void)getOriginalPhotoWithAsset:(id)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion {
if ([asset isKindOfClass:[PHAsset class]]) {
PHImageRequestOptions *option = [[PHImageRequestOptions alloc]init];
option.networkAccessAllowed = YES;
option.resizeMode = PHImageRequestOptionsResizeModeFast;
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage *result, NSDictionary *info) {
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]);
if (downloadFinined && result) {
result = [self fixOrientation:result];
BOOL isDegraded = [[info objectForKey:PHImageResultIsDegradedKey] boolValue];
if (completion) completion(result,info,isDegraded);
}
}];
} else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset;
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
dispatch_async(dispatch_get_global_queue(0,0), ^{
CGImageRef originalImageRef = [assetRep fullResolutionImage];
UIImage *originalImage = [UIImage imageWithCGImage:originalImageRef scale:1.0 orientation:UIImageOrientationUp];
dispatch_async(dispatch_get_main_queue(), ^{
if (completion) completion(originalImage,nil,NO);
});
});
}
}
- (void)getOriginalPhotoDataWithAsset:(id)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion {
[self getOriginalPhotoDataWithAsset:asset progressHandler:nil completion:completion];
}
- (void)getOriginalPhotoDataWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion {
if ([asset isKindOfClass:[PHAsset class]]) {
PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.networkAccessAllowed = YES;
if ([[asset valueForKey:@"filename"] hasSuffix:@"GIF"]) {
// if version isn't PHImageRequestOptionsVersionOriginal, the gif may cann't play
option.version = PHImageRequestOptionsVersionOriginal;
}
[option setProgressHandler:progressHandler];
option.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:option resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey]);
if (downloadFinined && imageData) {
if (completion) completion(imageData,info,NO);
}
}];
} else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset;
ALAssetRepresentation *assetRep = [alAsset defaultRepresentation];
Byte *imageBuffer = (Byte *)malloc(assetRep.size);
NSUInteger bufferSize = [assetRep getBytes:imageBuffer fromOffset:0.0 length:assetRep.size error:nil];
NSData *imageData = [NSData dataWithBytesNoCopy:imageBuffer length:bufferSize freeWhenDone:YES];
if (completion) completion(imageData,nil,NO);
}
}
#pragma mark - Save photo
- (void)savePhotoWithImage:(UIImage *)image completion:(void (^)(NSError *error))completion {
[self savePhotoWithImage:image location:nil completion:completion];
}
- (void)savePhotoWithImage:(UIImage *)image location:(CLLocation *)location completion:(void (^)(NSError *error))completion {
if (iOS8Later) {
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
if (@available(iOS 9, *)) {
NSData *data = UIImageJPEGRepresentation(image, 0.9);
PHAssetResourceCreationOptions *options = [[PHAssetResourceCreationOptions alloc] init];
options.shouldMoveFile = YES;
PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAsset];
[request addResourceWithType:PHAssetResourceTypePhoto data:data options:options];
if (location) {
request.location = location;
}
request.creationDate = [NSDate date];
} else {
PHAssetChangeRequest *request = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
if (location) {
request.location = location;
}
request.creationDate = [NSDate date];
}
} completionHandler:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success && completion) {
completion(nil);
} else if (error) {
NSLog(@":%@",error.localizedDescription);
if (completion) {
completion(error);
}
}
});
}];
} else {
[self.assetLibrary writeImageToSavedPhotosAlbum:image.CGImage orientation:[self orientationFromImage:image] completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@":%@",error.localizedDescription);
if (completion) {
completion(error);
}
} else {
// 0.5
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (completion) {
completion(nil);
}
});
}
}];
}
}
#pragma mark - Save video
- (void)saveVideoWithUrl:(NSURL *)url completion:(void (^)(NSError *error))completion {
[self saveVideoWithUrl:url location:nil completion:completion];
}
- (void)saveVideoWithUrl:(NSURL *)url location:(CLLocation *)location completion:(void (^)(NSError *error))completion {
if (iOS8Later) {
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
if (@available(iOS 9, *)) {
PHAssetResourceCreationOptions *options = [[PHAssetResourceCreationOptions alloc] init];
options.shouldMoveFile = YES;
PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAsset];
[request addResourceWithType:PHAssetResourceTypeVideo fileURL:url options:options];
if (location) {
request.location = location;
}
request.creationDate = [NSDate date];
} else {
PHAssetChangeRequest *request = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:url];
if (location) {
request.location = location;
}
request.creationDate = [NSDate date];
}
} completionHandler:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success && completion) {
completion(nil);
} else if (error) {
NSLog(@":%@",error.localizedDescription);
if (completion) {
completion(error);
}
}
});
}];
} else {
[self.assetLibrary writeVideoAtPathToSavedPhotosAlbum:url completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@":%@",error.localizedDescription);
if (completion) {
completion(error);
}
} else {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (completion) {
completion(nil);
}
});
}
}];
}
}
#pragma mark - Get Video
/// Get Video /
- (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem *, NSDictionary *))completion {
[self getVideoWithAsset:asset progressHandler:nil completion:completion];
}
- (void)getVideoWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(AVPlayerItem *, NSDictionary *))completion {
if ([asset isKindOfClass:[PHAsset class]]) {
PHVideoRequestOptions *option = [[PHVideoRequestOptions alloc] init];
option.networkAccessAllowed = YES;
option.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
if (progressHandler) {
progressHandler(progress, error, stop, info);
}
});
};
[[PHImageManager defaultManager] requestPlayerItemForVideo:asset options:option resultHandler:^(AVPlayerItem *playerItem, NSDictionary *info) {
if (completion) completion(playerItem,info);
}];
} else if ([asset isKindOfClass:[ALAsset class]]) {
ALAsset *alAsset = (ALAsset *)asset;
ALAssetRepresentation *defaultRepresentation = [alAsset defaultRepresentation];
NSString *uti = [defaultRepresentation UTI];
NSURL *videoURL = [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:uti];
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:videoURL];
if (completion && playerItem) completion(playerItem,nil);
}
}
#pragma mark - Export video
/// Export Video /
- (void)getVideoOutputPathWithAsset:(id)asset success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure {
[self getVideoOutputPathWithAsset:asset presetName:AVAssetExportPreset640x480 success:success failure:failure];
}
- (void)getVideoOutputPathWithAsset:(id)asset presetName:(NSString *)presetName success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure {
if ([asset isKindOfClass:[PHAsset class]]) {
PHVideoRequestOptions* options = [[PHVideoRequestOptions alloc] init];
options.version = PHVideoRequestOptionsVersionOriginal;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
options.networkAccessAllowed = YES;
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset* avasset, AVAudioMix* audioMix, NSDictionary* info){
// NSLog(@"Info:\n%@",info);
AVURLAsset *videoAsset = (AVURLAsset*)avasset;
// NSLog(@"AVAsset URL: %@",myAsset.URL);
[self startExportVideoWithVideoAsset:videoAsset presetName:presetName success:success failure:failure];
}];
} else if ([asset isKindOfClass:[ALAsset class]]) {
NSURL *videoURL =[asset valueForProperty:ALAssetPropertyAssetURL]; // ALAssetPropertyURLs
AVURLAsset *videoAsset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
[self startExportVideoWithVideoAsset:videoAsset presetName:presetName success:success failure:failure];
}
}
/// Deprecated, Use -getVideoOutputPathWithAsset:failure:success:
- (void)getVideoOutputPathWithAsset:(id)asset completion:(void (^)(NSString *outputPath))completion {
[self getVideoOutputPathWithAsset:asset success:completion failure:nil];
}
- (void)startExportVideoWithVideoAsset:(AVURLAsset *)videoAsset presetName:(NSString *)presetName success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure {
// Find compatible presets by video asset.
NSArray *presets = [AVAssetExportSession exportPresetsCompatibleWithAsset:videoAsset];
// Begin to compress video
// Now we just compress to low resolution if it supports
// If you need to upload to the server, but server does't support to upload by streaming,
// You can compress the resolution to lower. Or you can support more higher resolution.
if ([presets containsObject:presetName]) {
AVAssetExportSession *session = [[AVAssetExportSession alloc] initWithAsset:videoAsset presetName:presetName];
NSDateFormatter *formater = [[NSDateFormatter alloc] init];
[formater setDateFormat:@"yyyy-MM-dd-HH:mm:ss-SSS"];
NSString *outputPath = [NSHomeDirectory() stringByAppendingFormat:@"/tmp/output-%@.mp4", [formater stringFromDate:[NSDate date]]];
// NSLog(@"video outputPath = %@",outputPath);
session.outputURL = [NSURL fileURLWithPath:outputPath];
// Optimize for network use.
session.shouldOptimizeForNetworkUse = true;
NSArray *supportedTypeArray = session.supportedFileTypes;
if ([supportedTypeArray containsObject:AVFileTypeMPEG4]) {
session.outputFileType = AVFileTypeMPEG4;
} else if (supportedTypeArray.count == 0) {
if (failure) {
failure(@"", nil);
}
NSLog(@"No supported file types ");
return;
} else {
session.outputFileType = [supportedTypeArray objectAtIndex:0];
}
if (![[NSFileManager defaultManager] fileExistsAtPath:[NSHomeDirectory() stringByAppendingFormat:@"/tmp"]]) {
[[NSFileManager defaultManager] createDirectoryAtPath:[NSHomeDirectory() stringByAppendingFormat:@"/tmp"] withIntermediateDirectories:YES attributes:nil error:nil];
}
AVMutableVideoComposition *videoComposition = [self fixedCompositionWithAsset:videoAsset];
if (videoComposition.renderSize.width) {
//
session.videoComposition = videoComposition;
}
// Begin to export video to the output path asynchronously.
[session exportAsynchronouslyWithCompletionHandler:^(void) {
dispatch_async(dispatch_get_main_queue(), ^{
switch (session.status) {
case AVAssetExportSessionStatusUnknown: {
NSLog(@"AVAssetExportSessionStatusUnknown");
} break;
case AVAssetExportSessionStatusWaiting: {
NSLog(@"AVAssetExportSessionStatusWaiting");
} break;
case AVAssetExportSessionStatusExporting: {
NSLog(@"AVAssetExportSessionStatusExporting");
} break;
case AVAssetExportSessionStatusCompleted: {
NSLog(@"AVAssetExportSessionStatusCompleted");
if (success) {
success(outputPath);
}
} break;
case AVAssetExportSessionStatusFailed: {
NSLog(@"AVAssetExportSessionStatusFailed");
if (failure) {
failure(@"", session.error);
}
} break;
case AVAssetExportSessionStatusCancelled: {
NSLog(@"AVAssetExportSessionStatusCancelled");
if (failure) {
failure(@"", nil);
}
} break;
default: break;
}
});
}];
} else {
if (failure) {
NSString *errorMessage = [NSString stringWithFormat:@":%@", presetName];
failure(errorMessage, nil);
}
}
}
/// Judge is a assets array contain the asset assetsasset
- (BOOL)isAssetsArray:(NSArray *)assets containAsset:(id)asset {
if (iOS8Later) {
return [assets containsObject:asset];
} else {
NSMutableArray *selectedAssetUrls = [NSMutableArray array];
for (ALAsset *asset_item in assets) {
[selectedAssetUrls addObject:[asset_item valueForProperty:ALAssetPropertyURLs]];
}
return [selectedAssetUrls containsObject:[asset valueForProperty:ALAssetPropertyURLs]];
}
}
- (BOOL)isCameraRollAlbum:(id)metadata {
if ([metadata isKindOfClass:[PHAssetCollection class]]) {
NSString *versionStr = [[UIDevice currentDevice].systemVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
if (versionStr.length <= 1) {
versionStr = [versionStr stringByAppendingString:@"00"];
} else if (versionStr.length <= 2) {
versionStr = [versionStr stringByAppendingString:@"0"];
}
CGFloat version = versionStr.floatValue;
// 8.0.0 ~ 8.0.2
if (version >= 800 && version <= 802) {
return ((PHAssetCollection *)metadata).assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumRecentlyAdded;
} else {
return ((PHAssetCollection *)metadata).assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumUserLibrary;
}
}
if ([metadata isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = metadata;
return ([[group valueForProperty:ALAssetsGroupPropertyType] intValue] == ALAssetsGroupSavedPhotos);
}
return NO;
}
- (NSString *)getAssetIdentifier:(id)asset {
if (iOS8Later) {
PHAsset *phAsset = (PHAsset *)asset;
return phAsset.localIdentifier;
} else {
ALAsset *alAsset = (ALAsset *)asset;
NSURL *assetUrl = [alAsset valueForProperty:ALAssetPropertyAssetURL];
return assetUrl.absoluteString;
}
}
///
- (BOOL)isPhotoSelectableWithAsset:(id)asset {
CGSize photoSize = [self photoSizeWithAsset:asset];
if (self.minPhotoWidthSelectable > photoSize.width || self.minPhotoHeightSelectable > photoSize.height) {
return NO;
}
return YES;
}
- (CGSize)photoSizeWithAsset:(id)asset {
if (iOS8Later) {
PHAsset *phAsset = (PHAsset *)asset;
return CGSizeMake(phAsset.pixelWidth, phAsset.pixelHeight);
} else {
ALAsset *alAsset = (ALAsset *)asset;
return alAsset.defaultRepresentation.dimensions;
}
}
#pragma mark - Private Method
- (TZAlbumModel *)modelWithResult:(id)result name:(NSString *)name isCameraRoll:(BOOL)isCameraRoll needFetchAssets:(BOOL)needFetchAssets {
TZAlbumModel *model = [[TZAlbumModel alloc] init];
[model setResult:result needFetchAssets:needFetchAssets];
model.name = name;
model.isCameraRoll = isCameraRoll;
if ([result isKindOfClass:[PHFetchResult class]]) {
PHFetchResult *fetchResult = (PHFetchResult *)result;
model.count = fetchResult.count;
} else if ([result isKindOfClass:[ALAssetsGroup class]]) {
ALAssetsGroup *group = (ALAssetsGroup *)result;
model.count = [group numberOfAssets];
}
return model;
}
///
- (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size {
if (image.size.width > size.width) {
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
/* path_to_url
CGFloat maxPixelSize = MAX(size.width, size.height);
CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)UIImageJPEGRepresentation(image, 0.9), nil);
NSDictionary *options = @{(__bridge id)kCGImageSourceCreateThumbnailFromImageAlways:(__bridge id)kCFBooleanTrue,
(__bridge id)kCGImageSourceThumbnailMaxPixelSize:[NSNumber numberWithFloat:maxPixelSize]
};
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(sourceRef, 0, (__bridge CFDictionaryRef)options);
UIImage *newImage = [UIImage imageWithCGImage:imageRef scale:2 orientation:image.imageOrientation];
CGImageRelease(imageRef);
CFRelease(sourceRef);
return newImage;
*/
} else {
return image;
}
}
- (ALAssetOrientation)orientationFromImage:(UIImage *)image {
NSInteger orientation = image.imageOrientation;
return orientation;
}
///
- (AVMutableVideoComposition *)fixedCompositionWithAsset:(AVAsset *)videoAsset {
AVMutableVideoComposition *videoComposition = [AVMutableVideoComposition videoComposition];
//
int degrees = [self degressFromVideoFileWithAsset:videoAsset];
if (degrees != 0) {
CGAffineTransform translateToCenter;
CGAffineTransform mixedTransform;
videoComposition.frameDuration = CMTimeMake(1, 30);
NSArray *tracks = [videoAsset tracksWithMediaType:AVMediaTypeVideo];
AVAssetTrack *videoTrack = [tracks objectAtIndex:0];
AVMutableVideoCompositionInstruction *roateInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
roateInstruction.timeRange = CMTimeRangeMake(kCMTimeZero, [videoAsset duration]);
AVMutableVideoCompositionLayerInstruction *roateLayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
if (degrees == 90) {
// 90
translateToCenter = CGAffineTransformMakeTranslation(videoTrack.naturalSize.height, 0.0);
mixedTransform = CGAffineTransformRotate(translateToCenter,M_PI_2);
videoComposition.renderSize = CGSizeMake(videoTrack.naturalSize.height,videoTrack.naturalSize.width);
[roateLayerInstruction setTransform:mixedTransform atTime:kCMTimeZero];
} else if(degrees == 180){
// 180
translateToCenter = CGAffineTransformMakeTranslation(videoTrack.naturalSize.width, videoTrack.naturalSize.height);
mixedTransform = CGAffineTransformRotate(translateToCenter,M_PI);
videoComposition.renderSize = CGSizeMake(videoTrack.naturalSize.width,videoTrack.naturalSize.height);
[roateLayerInstruction setTransform:mixedTransform atTime:kCMTimeZero];
} else if(degrees == 270){
// 270
translateToCenter = CGAffineTransformMakeTranslation(0.0, videoTrack.naturalSize.width);
mixedTransform = CGAffineTransformRotate(translateToCenter,M_PI_2*3.0);
videoComposition.renderSize = CGSizeMake(videoTrack.naturalSize.height,videoTrack.naturalSize.width);
[roateLayerInstruction setTransform:mixedTransform atTime:kCMTimeZero];
}
roateInstruction.layerInstructions = @[roateLayerInstruction];
//
videoComposition.instructions = @[roateInstruction];
}
return videoComposition;
}
///
- (int)degressFromVideoFileWithAsset:(AVAsset *)asset {
int degress = 0;
NSArray *tracks = [asset tracksWithMediaType:AVMediaTypeVideo];
if([tracks count] > 0) {
AVAssetTrack *videoTrack = [tracks objectAtIndex:0];
CGAffineTransform t = videoTrack.preferredTransform;
if(t.a == 0 && t.b == 1.0 && t.c == -1.0 && t.d == 0){
// Portrait
degress = 90;
} else if(t.a == 0 && t.b == -1.0 && t.c == 1.0 && t.d == 0){
// PortraitUpsideDown
degress = 270;
} else if(t.a == 1.0 && t.b == 0 && t.c == 0 && t.d == 1.0){
// LandscapeRight
degress = 0;
} else if(t.a == -1.0 && t.b == 0 && t.c == 0 && t.d == -1.0){
// LandscapeLeft
degress = 180;
}
}
return degress;
}
///
- (UIImage *)fixOrientation:(UIImage *)aImage {
if (!self.shouldFixOrientation) return aImage;
// No-op if the orientation is already correct
if (aImage.imageOrientation == UIImageOrientationUp)
return aImage;
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
CGAffineTransform transform = CGAffineTransformIdentity;
switch (aImage.imageOrientation) {
case UIImageOrientationDown:
case UIImageOrientationDownMirrored:
transform = CGAffineTransformTranslate(transform, aImage.size.width, aImage.size.height);
transform = CGAffineTransformRotate(transform, M_PI);
break;
case UIImageOrientationLeft:
case UIImageOrientationLeftMirrored:
transform = CGAffineTransformTranslate(transform, aImage.size.width, 0);
transform = CGAffineTransformRotate(transform, M_PI_2);
break;
case UIImageOrientationRight:
case UIImageOrientationRightMirrored:
transform = CGAffineTransformTranslate(transform, 0, aImage.size.height);
transform = CGAffineTransformRotate(transform, -M_PI_2);
break;
default:
break;
}
switch (aImage.imageOrientation) {
case UIImageOrientationUpMirrored:
case UIImageOrientationDownMirrored:
transform = CGAffineTransformTranslate(transform, aImage.size.width, 0);
transform = CGAffineTransformScale(transform, -1, 1);
break;
case UIImageOrientationLeftMirrored:
case UIImageOrientationRightMirrored:
transform = CGAffineTransformTranslate(transform, aImage.size.height, 0);
transform = CGAffineTransformScale(transform, -1, 1);
break;
default:
break;
}
// Now we draw the underlying CGImage into a new context, applying the transform
// calculated above.
CGContextRef ctx = CGBitmapContextCreate(NULL, aImage.size.width, aImage.size.height,
CGImageGetBitsPerComponent(aImage.CGImage), 0,
CGImageGetColorSpace(aImage.CGImage),
CGImageGetBitmapInfo(aImage.CGImage));
CGContextConcatCTM(ctx, transform);
switch (aImage.imageOrientation) {
case UIImageOrientationLeft:
case UIImageOrientationLeftMirrored:
case UIImageOrientationRight:
case UIImageOrientationRightMirrored:
// Grr...
CGContextDrawImage(ctx, CGRectMake(0,0,aImage.size.height,aImage.size.width), aImage.CGImage);
break;
default:
CGContextDrawImage(ctx, CGRectMake(0,0,aImage.size.width,aImage.size.height), aImage.CGImage);
break;
}
// And now we just create a new UIImage from the drawing context
CGImageRef cgimg = CGBitmapContextCreateImage(ctx);
UIImage *img = [UIImage imageWithCGImage:cgimg];
CGContextRelease(ctx);
CGImageRelease(cgimg);
return img;
}
#pragma clang diagnostic pop
@end
//@implementation TZSortDescriptor
//
//- (id)reversedSortDescriptor {
// return [NSNumber numberWithBool:![TZImageManager manager].sortAscendingByModificationDate];
//}
//
//@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImageManager.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 12,058 |
```objective-c
//
// TZImageCropManager.h
// TZImagePickerController
//
// Created by on 2016/12/5.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TZImageCropManager : NSObject
///
+ (void)overlayClippingWithView:(UIView *)view cropRect:(CGRect)cropRect containerView:(UIView *)containerView needCircleCrop:(BOOL)needCircleCrop;
/*
1.7.2
tuyouPhotoTweaks
tuyouPhotoTweaks
tuyougithubPhotoTweaks
PhotoTweaksgithubpath_to_url
*/
///
+ (UIImage *)cropImageView:(UIImageView *)imageView toRect:(CGRect)rect zoomScale:(double)zoomScale containerView:(UIView *)containerView;
///
+ (UIImage *)circularClipImage:(UIImage *)image;
@end
/// SDWebImage:path_to_url
///
@interface UIImage (TZGif)
+ (UIImage *)sd_tz_animatedGIFWithData:(NSData *)data;
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImageCropManager.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 216 |
```objective-c
//
// TZAssetModel.m
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import "TZAssetModel.h"
#import "TZImageManager.h"
@implementation TZAssetModel
+ (instancetype)modelWithAsset:(id)asset type:(TZAssetModelMediaType)type{
TZAssetModel *model = [[TZAssetModel alloc] init];
model.asset = asset;
model.isSelected = NO;
model.type = type;
return model;
}
+ (instancetype)modelWithAsset:(id)asset type:(TZAssetModelMediaType)type timeLength:(NSString *)timeLength {
TZAssetModel *model = [self modelWithAsset:asset type:type];
model.timeLength = timeLength;
return model;
}
@end
@implementation TZAlbumModel
- (void)setResult:(id)result needFetchAssets:(BOOL)needFetchAssets {
_result = result;
if (needFetchAssets) {
[[TZImageManager manager] getAssetsFromFetchResult:result completion:^(NSArray<TZAssetModel *> *models) {
self->_models = models;
if (self->_selectedModels) {
[self checkSelectedModels];
}
}];
}
}
- (void)setSelectedModels:(NSArray *)selectedModels {
_selectedModels = selectedModels;
if (_models) {
[self checkSelectedModels];
}
}
- (void)checkSelectedModels {
self.selectedCount = 0;
NSMutableArray *selectedAssets = [NSMutableArray array];
for (TZAssetModel *model in _selectedModels) {
[selectedAssets addObject:model.asset];
}
for (TZAssetModel *model in _models) {
if ([[TZImageManager manager] isAssetsArray:selectedAssets containAsset:model.asset]) {
self.selectedCount ++;
}
}
}
- (NSString *)name {
if (_name) {
return _name;
}
return @"";
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZAssetModel.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 412 |
```objective-c
//
// TZPhotoPreviewCell.m
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import "TZPhotoPreviewCell.h"
#import "TZAssetModel.h"
#import "UIView+Layout.h"
#import "TZImageManager.h"
#import "TZProgressView.h"
#import "TZImageCropManager.h"
#import <MediaPlayer/MediaPlayer.h>
#import "TZImagePickerController.h"
@implementation TZAssetPreviewCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor blackColor];
[self configSubviews];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(photoPreviewCollectionViewDidScroll) name:@"photoPreviewCollectionViewDidScroll" object:nil];
}
return self;
}
- (void)configSubviews {
}
#pragma mark - Notification
- (void)photoPreviewCollectionViewDidScroll {
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
@implementation TZPhotoPreviewCell
- (void)configSubviews {
self.previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
__weak typeof(self) weakSelf = self;
[self.previewView setSingleTapGestureBlock:^{
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf.singleTapGestureBlock) {
strongSelf.singleTapGestureBlock();
}
}];
[self.previewView setImageProgressUpdateBlock:^(double progress) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf.imageProgressUpdateBlock) {
strongSelf.imageProgressUpdateBlock(progress);
}
}];
[self addSubview:self.previewView];
}
- (void)setModel:(TZAssetModel *)model {
[super setModel:model];
_previewView.asset = model.asset;
}
- (void)recoverSubviews {
[_previewView recoverSubviews];
}
- (void)setAllowCrop:(BOOL)allowCrop {
_allowCrop = allowCrop;
_previewView.allowCrop = allowCrop;
}
- (void)setCropRect:(CGRect)cropRect {
_cropRect = cropRect;
_previewView.cropRect = cropRect;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.previewView.frame = self.bounds;
}
@end
@interface TZPhotoPreviewView ()<UIScrollViewDelegate>
@property (assign, nonatomic) BOOL isRequestingGIF;
@end
@implementation TZPhotoPreviewView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.bouncesZoom = YES;
_scrollView.maximumZoomScale = 2.5;
_scrollView.minimumZoomScale = 1.0;
_scrollView.multipleTouchEnabled = YES;
_scrollView.delegate = self;
_scrollView.scrollsToTop = NO;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = YES;
_scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_scrollView.delaysContentTouches = NO;
_scrollView.canCancelContentTouches = YES;
_scrollView.alwaysBounceVertical = NO;
if (@available(iOS 11, *)) {
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[self addSubview:_scrollView];
_imageContainerView = [[UIView alloc] init];
_imageContainerView.clipsToBounds = YES;
_imageContainerView.contentMode = UIViewContentModeScaleAspectFill;
[_scrollView addSubview:_imageContainerView];
_imageView = [[UIImageView alloc] init];
_imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
_imageView.clipsToBounds = YES;
[_imageContainerView addSubview:_imageView];
UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
[self addGestureRecognizer:tap1];
UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
tap2.numberOfTapsRequired = 2;
[tap1 requireGestureRecognizerToFail:tap2];
[self addGestureRecognizer:tap2];
[self configProgressView];
}
return self;
}
- (void)configProgressView {
_progressView = [[TZProgressView alloc] init];
_progressView.hidden = YES;
[self addSubview:_progressView];
}
- (void)setModel:(TZAssetModel *)model {
_model = model;
self.isRequestingGIF = NO;
[_scrollView setZoomScale:1.0 animated:NO];
if (model.type == TZAssetModelMediaTypePhotoGif) {
//
[[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
self.imageView.image = photo;
[self resizeSubviews];
if (self.isRequestingGIF) {
return;
}
// gif
self.isRequestingGIF = YES;
[[TZImageManager manager] getOriginalPhotoDataWithAsset:model.asset progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
progress = progress > 0.02 ? progress : 0.02;
dispatch_async(dispatch_get_main_queue(), ^{
self.progressView.progress = progress;
if (progress >= 1) {
self.progressView.hidden = YES;
} else {
self.progressView.hidden = NO;
}
});
#ifdef DEBUG
NSLog(@"[TZImagePickerController] getOriginalPhotoDataWithAsset:%f error:%@", progress, error);
#endif
} completion:^(NSData *data, NSDictionary *info, BOOL isDegraded) {
if (!isDegraded) {
self.isRequestingGIF = NO;
self.progressView.hidden = YES;
self.imageView.image = [UIImage sd_tz_animatedGIFWithData:data];
[self resizeSubviews];
}
}];
} progressHandler:nil networkAccessAllowed:NO];
} else {
self.asset = model.asset;
}
}
- (void)setAsset:(id)asset {
if (_asset && self.imageRequestID) {
[[PHImageManager defaultManager] cancelImageRequest:self.imageRequestID];
}
_asset = asset;
self.imageRequestID = [[TZImageManager manager] getPhotoWithAsset:asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (![asset isEqual:self->_asset]) return;
self.imageView.image = photo;
[self resizeSubviews];
self->_progressView.hidden = YES;
if (self.imageProgressUpdateBlock) {
self.imageProgressUpdateBlock(1);
}
if (!isDegraded) {
self.imageRequestID = 0;
}
} progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
if (![asset isEqual:self->_asset]) return;
self->_progressView.hidden = NO;
[self bringSubviewToFront:self->_progressView];
progress = progress > 0.02 ? progress : 0.02;
self->_progressView.progress = progress;
if (self.imageProgressUpdateBlock && progress < 1) {
self.imageProgressUpdateBlock(progress);
}
if (progress >= 1) {
self->_progressView.hidden = YES;
self.imageRequestID = 0;
}
} networkAccessAllowed:YES];
}
- (void)recoverSubviews {
[_scrollView setZoomScale:1.0 animated:NO];
[self resizeSubviews];
}
- (void)resizeSubviews {
_imageContainerView.tz_origin = CGPointZero;
_imageContainerView.tz_width = self.scrollView.tz_width;
UIImage *image = _imageView.image;
if (image.size.height / image.size.width > self.tz_height / self.scrollView.tz_width) {
_imageContainerView.tz_height = floor(image.size.height / (image.size.width / self.scrollView.tz_width));
} else {
CGFloat height = image.size.height / image.size.width * self.scrollView.tz_width;
if (height < 1 || isnan(height)) height = self.tz_height;
height = floor(height);
_imageContainerView.tz_height = height;
_imageContainerView.tz_centerY = self.tz_height / 2;
}
if (_imageContainerView.tz_height > self.tz_height && _imageContainerView.tz_height - self.tz_height <= 1) {
_imageContainerView.tz_height = self.tz_height;
}
CGFloat contentSizeH = MAX(_imageContainerView.tz_height, self.tz_height);
_scrollView.contentSize = CGSizeMake(self.scrollView.tz_width, contentSizeH);
[_scrollView scrollRectToVisible:self.bounds animated:NO];
_scrollView.alwaysBounceVertical = _imageContainerView.tz_height <= self.tz_height ? NO : YES;
_imageView.frame = _imageContainerView.bounds;
[self refreshScrollViewContentSize];
}
- (void)setAllowCrop:(BOOL)allowCrop {
_allowCrop = allowCrop;
_scrollView.maximumZoomScale = allowCrop ? 4.0 : 2.5;
if ([self.asset isKindOfClass:[PHAsset class]]) {
PHAsset *phAsset = (PHAsset *)self.asset;
CGFloat aspectRatio = phAsset.pixelWidth / (CGFloat)phAsset.pixelHeight;
//
if (aspectRatio > 1.5) {
self.scrollView.maximumZoomScale *= aspectRatio / 1.5;
}
}
}
- (void)refreshScrollViewContentSize {
if (_allowCrop) {
// 1.7.2 ,_scrollView
// 1.contentSize()
CGFloat contentWidthAdd = self.scrollView.tz_width - CGRectGetMaxX(_cropRect);
CGFloat contentHeightAdd = (MIN(_imageContainerView.tz_height, self.tz_height) - self.cropRect.size.height) / 2;
CGFloat newSizeW = self.scrollView.contentSize.width + contentWidthAdd;
CGFloat newSizeH = MAX(self.scrollView.contentSize.height, self.tz_height) + contentHeightAdd;
_scrollView.contentSize = CGSizeMake(newSizeW, newSizeH);
_scrollView.alwaysBounceVertical = YES;
// 2.scrollView
if (contentHeightAdd > 0 || contentWidthAdd > 0) {
_scrollView.contentInset = UIEdgeInsetsMake(contentHeightAdd, _cropRect.origin.x, 0, 0);
} else {
_scrollView.contentInset = UIEdgeInsetsZero;
}
}
}
- (void)layoutSubviews {
[super layoutSubviews];
_scrollView.frame = CGRectMake(10, 0, self.tz_width - 20, self.tz_height);
static CGFloat progressWH = 40;
CGFloat progressX = (self.tz_width - progressWH) / 2;
CGFloat progressY = (self.tz_height - progressWH) / 2;
_progressView.frame = CGRectMake(progressX, progressY, progressWH, progressWH);
[self recoverSubviews];
}
#pragma mark - UITapGestureRecognizer Event
- (void)doubleTap:(UITapGestureRecognizer *)tap {
if (_scrollView.zoomScale > 1.0) {
_scrollView.contentInset = UIEdgeInsetsZero;
[_scrollView setZoomScale:1.0 animated:YES];
} else {
CGPoint touchPoint = [tap locationInView:self.imageView];
CGFloat newZoomScale = _scrollView.maximumZoomScale;
CGFloat xsize = self.frame.size.width / newZoomScale;
CGFloat ysize = self.frame.size.height / newZoomScale;
[_scrollView zoomToRect:CGRectMake(touchPoint.x - xsize/2, touchPoint.y - ysize/2, xsize, ysize) animated:YES];
}
}
- (void)singleTap:(UITapGestureRecognizer *)tap {
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
}
#pragma mark - UIScrollViewDelegate
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return _imageContainerView;
}
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view {
scrollView.contentInset = UIEdgeInsetsZero;
}
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
[self refreshImageContainerViewCenter];
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale {
[self refreshScrollViewContentSize];
}
#pragma mark - Private
- (void)refreshImageContainerViewCenter {
CGFloat offsetX = (_scrollView.tz_width > _scrollView.contentSize.width) ? ((_scrollView.tz_width - _scrollView.contentSize.width) * 0.5) : 0.0;
CGFloat offsetY = (_scrollView.tz_height > _scrollView.contentSize.height) ? ((_scrollView.tz_height - _scrollView.contentSize.height) * 0.5) : 0.0;
self.imageContainerView.center = CGPointMake(_scrollView.contentSize.width * 0.5 + offsetX, _scrollView.contentSize.height * 0.5 + offsetY);
}
@end
@implementation TZVideoPreviewCell
- (void)configSubviews {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:UIApplicationWillResignActiveNotification object:nil];
}
- (void)configPlayButton {
if (_playButton) {
[_playButton removeFromSuperview];
}
_playButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay"] forState:UIControlStateNormal];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlayHL"] forState:UIControlStateHighlighted];
[_playButton addTarget:self action:@selector(playButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_playButton];
}
- (void)setModel:(TZAssetModel *)model {
[super setModel:model];
[self configMoviePlayer];
}
- (void)configMoviePlayer {
if (_player) {
[_playerLayer removeFromSuperlayer];
_playerLayer = nil;
[_player pause];
_player = nil;
}
[[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
self->_cover = photo;
}];
[[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{
self->_player = [AVPlayer playerWithPlayerItem:playerItem];
self->_playerLayer = [AVPlayerLayer playerLayerWithPlayer:self->_player];
self->_playerLayer.backgroundColor = [UIColor blackColor].CGColor;
self->_playerLayer.frame = self.bounds;
[self.layer addSublayer:self->_playerLayer];
[self configPlayButton];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:self->_player.currentItem];
});
}];
}
- (void)layoutSubviews {
[super layoutSubviews];
_playerLayer.frame = self.bounds;
_playButton.frame = CGRectMake(0, 64, self.tz_width, self.tz_height - 64 - 44);
}
- (void)photoPreviewCollectionViewDidScroll {
[self pausePlayerAndShowNaviBar];
}
#pragma mark - Click Event
- (void)playButtonClick {
CMTime currentTime = _player.currentItem.currentTime;
CMTime durationTime = _player.currentItem.duration;
if (_player.rate == 0.0f) {
if (currentTime.value == durationTime.value) [_player.currentItem seekToTime:CMTimeMake(0, 1)];
[_player play];
[_playButton setImage:nil forState:UIControlStateNormal];
if (iOS7Later) [UIApplication sharedApplication].statusBarHidden = YES;
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
} else {
[self pausePlayerAndShowNaviBar];
}
}
- (void)pausePlayerAndShowNaviBar {
if (_player.rate != 0.0) {
[_player pause];
[_playButton setImage:[UIImage imageNamedFromMyBundle:@"MMVideoPreviewPlay"] forState:UIControlStateNormal];
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
}
}
@end
@implementation TZGifPreviewCell
- (void)configSubviews {
[self configPreviewView];
}
- (void)configPreviewView {
_previewView = [[TZPhotoPreviewView alloc] initWithFrame:CGRectZero];
__weak typeof(self) weakSelf = self;
[_previewView setSingleTapGestureBlock:^{
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf signleTapAction];
}];
[self addSubview:_previewView];
}
- (void)setModel:(TZAssetModel *)model {
[super setModel:model];
_previewView.model = self.model;
}
- (void)layoutSubviews {
[super layoutSubviews];
_previewView.frame = self.bounds;
}
#pragma mark - Click Event
- (void)signleTapAction {
if (self.singleTapGestureBlock) {
self.singleTapGestureBlock();
}
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 3,683 |
```objective-c
//
// TZPhotoPreviewController.m
// TZImagePickerController
//
// Created by on 15/12/24.
//
#import "TZPhotoPreviewController.h"
#import "TZPhotoPreviewCell.h"
#import "TZAssetModel.h"
#import "UIView+Layout.h"
#import "TZImagePickerController.h"
#import "TZImageManager.h"
#import "TZImageCropManager.h"
@interface TZPhotoPreviewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UIScrollViewDelegate> {
UICollectionView *_collectionView;
UICollectionViewFlowLayout *_layout;
NSArray *_photosTemp;
NSArray *_assetsTemp;
UIView *_naviBar;
UIButton *_backButton;
UIButton *_selectButton;
UILabel *_indexLabel;
UIView *_toolBar;
UIButton *_doneButton;
UIImageView *_numberImageView;
UILabel *_numberLabel;
UIButton *_originalPhotoButton;
UILabel *_originalPhotoLabel;
CGFloat _offsetItemCount;
}
@property (nonatomic, assign) BOOL isHideNaviBar;
@property (nonatomic, strong) UIView *cropBgView;
@property (nonatomic, strong) UIView *cropView;
@property (nonatomic, assign) double progress;
@property (strong, nonatomic) id alertView;
@end
@implementation TZPhotoPreviewController
- (void)viewDidLoad {
[super viewDidLoad];
[TZImageManager manager].shouldFixOrientation = YES;
__weak typeof(self) weakSelf = self;
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)weakSelf.navigationController;
if (!self.models.count) {
self.models = [NSMutableArray arrayWithArray:_tzImagePickerVc.selectedModels];
_assetsTemp = [NSMutableArray arrayWithArray:_tzImagePickerVc.selectedAssets];
}
[self configCollectionView];
[self configCustomNaviBar];
[self configBottomToolBar];
self.view.clipsToBounds = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
- (void)setPhotos:(NSMutableArray *)photos {
_photos = photos;
_photosTemp = [NSArray arrayWithArray:photos];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
if (iOS7Later) [UIApplication sharedApplication].statusBarHidden = YES;
if (_currentIndex) [_collectionView setContentOffset:CGPointMake((self.view.tz_width + 20) * _currentIndex, 0) animated:NO];
[self refreshNaviBarAndBottomBarState];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.needShowStatusBar && iOS7Later) {
[UIApplication sharedApplication].statusBarHidden = NO;
}
[TZImageManager manager].shouldFixOrientation = NO;
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
- (void)configCustomNaviBar {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
_naviBar = [[UIView alloc] initWithFrame:CGRectZero];
_naviBar.backgroundColor = [UIColor colorWithRed:(34/255.0) green:(34/255.0) blue:(34/255.0) alpha:0.7];
_backButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_backButton setImage:[UIImage imageNamedFromMyBundle:@"navi_back"] forState:UIControlStateNormal];
[_backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
_selectButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_selectButton setImage:tzImagePickerVc.photoDefImage forState:UIControlStateNormal];
[_selectButton setImage:tzImagePickerVc.photoSelImage forState:UIControlStateSelected];
_selectButton.imageView.clipsToBounds = YES;
_selectButton.imageEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 0);
_selectButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
[_selectButton addTarget:self action:@selector(select:) forControlEvents:UIControlEventTouchUpInside];
_selectButton.hidden = !tzImagePickerVc.showSelectBtn;
_indexLabel = [[UILabel alloc] init];
_indexLabel.font = [UIFont systemFontOfSize:14];
_indexLabel.textColor = [UIColor whiteColor];
_indexLabel.textAlignment = NSTextAlignmentCenter;
[_naviBar addSubview:_selectButton];
[_naviBar addSubview:_indexLabel];
[_naviBar addSubview:_backButton];
[self.view addSubview:_naviBar];
}
- (void)configBottomToolBar {
_toolBar = [[UIView alloc] initWithFrame:CGRectZero];
static CGFloat rgb = 34 / 255.0;
_toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.7];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_tzImagePickerVc.allowPickingOriginalPhoto) {
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
_originalPhotoButton.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addTarget:self action:@selector(originalPhotoButtonClick) forControlEvents:UIControlEventTouchUpInside];
_originalPhotoButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_originalPhotoButton setTitle:_tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateNormal];
[_originalPhotoButton setTitle:_tzImagePickerVc.fullImageBtnTitleStr forState:UIControlStateSelected];
[_originalPhotoButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[_originalPhotoButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[_originalPhotoButton setImage:_tzImagePickerVc.photoPreviewOriginDefImage forState:UIControlStateNormal];
[_originalPhotoButton setImage:_tzImagePickerVc.photoOriginSelImage forState:UIControlStateSelected];
_originalPhotoLabel = [[UILabel alloc] init];
_originalPhotoLabel.textAlignment = NSTextAlignmentLeft;
_originalPhotoLabel.font = [UIFont systemFontOfSize:13];
_originalPhotoLabel.textColor = [UIColor whiteColor];
_originalPhotoLabel.backgroundColor = [UIColor clearColor];
if (_isSelectOriginalPhoto) [self showPhotoBytes];
}
_doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
_doneButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_doneButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_doneButton setTitle:_tzImagePickerVc.doneBtnTitleStr forState:UIControlStateNormal];
[_doneButton setTitleColor:_tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
_numberImageView = [[UIImageView alloc] initWithImage:_tzImagePickerVc.photoNumberIconImage];
_numberImageView.backgroundColor = [UIColor clearColor];
_numberImageView.clipsToBounds = YES;
_numberImageView.contentMode = UIViewContentModeScaleAspectFit;
_numberImageView.hidden = _tzImagePickerVc.selectedModels.count <= 0;
_numberLabel = [[UILabel alloc] init];
_numberLabel.font = [UIFont systemFontOfSize:15];
_numberLabel.textColor = [UIColor whiteColor];
_numberLabel.textAlignment = NSTextAlignmentCenter;
_numberLabel.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
_numberLabel.hidden = _tzImagePickerVc.selectedModels.count <= 0;
_numberLabel.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addSubview:_originalPhotoLabel];
[_toolBar addSubview:_doneButton];
[_toolBar addSubview:_originalPhotoButton];
[_toolBar addSubview:_numberImageView];
[_toolBar addSubview:_numberLabel];
[self.view addSubview:_toolBar];
if (_tzImagePickerVc.photoPreviewPageUIConfigBlock) {
_tzImagePickerVc.photoPreviewPageUIConfigBlock(_collectionView, _naviBar, _backButton, _selectButton, _indexLabel, _toolBar, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel);
}
}
- (void)configCollectionView {
_layout = [[UICollectionViewFlowLayout alloc] init];
_layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout];
_collectionView.backgroundColor = [UIColor blackColor];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.pagingEnabled = YES;
_collectionView.scrollsToTop = NO;
_collectionView.showsHorizontalScrollIndicator = NO;
_collectionView.contentOffset = CGPointMake(0, 0);
_collectionView.contentSize = CGSizeMake(self.models.count * (self.view.tz_width + 20), 0);
[self.view addSubview:_collectionView];
[_collectionView registerClass:[TZPhotoPreviewCell class] forCellWithReuseIdentifier:@"TZPhotoPreviewCell"];
[_collectionView registerClass:[TZVideoPreviewCell class] forCellWithReuseIdentifier:@"TZVideoPreviewCell"];
[_collectionView registerClass:[TZGifPreviewCell class] forCellWithReuseIdentifier:@"TZGifPreviewCell"];
}
- (void)configCropView {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_tzImagePickerVc.maxImagesCount <= 1 && _tzImagePickerVc.allowCrop) {
[_cropView removeFromSuperview];
[_cropBgView removeFromSuperview];
_cropBgView = [UIView new];
_cropBgView.userInteractionEnabled = NO;
_cropBgView.frame = self.view.bounds;
_cropBgView.backgroundColor = [UIColor clearColor];
[self.view addSubview:_cropBgView];
[TZImageCropManager overlayClippingWithView:_cropBgView cropRect:_tzImagePickerVc.cropRect containerView:self.view needCircleCrop:_tzImagePickerVc.needCircleCrop];
_cropView = [UIView new];
_cropView.userInteractionEnabled = NO;
_cropView.frame = _tzImagePickerVc.cropRect;
_cropView.backgroundColor = [UIColor clearColor];
_cropView.layer.borderColor = [UIColor whiteColor].CGColor;
_cropView.layer.borderWidth = 1.0;
if (_tzImagePickerVc.needCircleCrop) {
_cropView.layer.cornerRadius = _tzImagePickerVc.cropRect.size.width / 2;
_cropView.clipsToBounds = YES;
}
[self.view addSubview:_cropView];
if (_tzImagePickerVc.cropViewSettingBlock) {
_tzImagePickerVc.cropViewSettingBlock(_cropView);
}
[self.view bringSubviewToFront:_naviBar];
[self.view bringSubviewToFront:_toolBar];
}
}
#pragma mark - Layout
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
CGFloat statusBarHeight = [TZCommonTools tz_statusBarHeight];
CGFloat statusBarHeightInterval = statusBarHeight - 20;
CGFloat naviBarHeight = statusBarHeight + _tzImagePickerVc.navigationBar.tz_height;
_naviBar.frame = CGRectMake(0, 0, self.view.tz_width, naviBarHeight);
_backButton.frame = CGRectMake(10, 10 + statusBarHeightInterval, 44, 44);
_selectButton.frame = CGRectMake(self.view.tz_width - 56, 10 + statusBarHeightInterval, 44, 44);
_indexLabel.frame = _selectButton.frame;
_layout.itemSize = CGSizeMake(self.view.tz_width + 20, self.view.tz_height);
_layout.minimumInteritemSpacing = 0;
_layout.minimumLineSpacing = 0;
_collectionView.frame = CGRectMake(-10, 0, self.view.tz_width + 20, self.view.tz_height);
[_collectionView setCollectionViewLayout:_layout];
if (_offsetItemCount > 0) {
CGFloat offsetX = _offsetItemCount * _layout.itemSize.width;
[_collectionView setContentOffset:CGPointMake(offsetX, 0)];
}
if (_tzImagePickerVc.allowCrop) {
[_collectionView reloadData];
}
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44;
CGFloat toolBarTop = self.view.tz_height - toolBarHeight;
_toolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
if (_tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr tz_calculateSizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)].width;
_originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44);
_originalPhotoLabel.frame = CGRectMake(fullImageWidth + 42, 0, 80, 44);
}
[_doneButton sizeToFit];
_doneButton.frame = CGRectMake(self.view.tz_width - _doneButton.tz_width - 12, 0, _doneButton.tz_width, 44);
_numberImageView.frame = CGRectMake(_doneButton.tz_left - 24 - 5, 10, 24, 24);
_numberLabel.frame = _numberImageView.frame;
[self configCropView];
if (_tzImagePickerVc.photoPreviewPageDidLayoutSubviewsBlock) {
_tzImagePickerVc.photoPreviewPageDidLayoutSubviewsBlock(_collectionView, _naviBar, _backButton, _selectButton, _indexLabel, _toolBar, _originalPhotoButton, _originalPhotoLabel, _doneButton, _numberImageView, _numberLabel);
}
}
#pragma mark - Notification
- (void)didChangeStatusBarOrientationNotification:(NSNotification *)noti {
_offsetItemCount = _collectionView.contentOffset.x / _layout.itemSize.width;
}
#pragma mark - Click Event
- (void)select:(UIButton *)selectButton {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[_currentIndex];
if (!selectButton.isSelected) {
// 1. select:check if over the maxImagesCount / ,
if (_tzImagePickerVc.selectedModels.count >= _tzImagePickerVc.maxImagesCount) {
NSString *title = [NSString stringWithFormat:[NSBundle tz_localizedStringForKey:@"Select a maximum of %zd photos"], _tzImagePickerVc.maxImagesCount];
[_tzImagePickerVc showAlertWithTitle:title];
return;
// 2. if not over the maxImagesCount /
} else {
[_tzImagePickerVc addSelectedModel:model];
if (self.photos) {
[_tzImagePickerVc.selectedAssets addObject:_assetsTemp[_currentIndex]];
[self.photos addObject:_photosTemp[_currentIndex]];
}
if (model.type == TZAssetModelMediaTypeVideo && !_tzImagePickerVc.allowPickingMultipleVideo) {
[_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Select the video when in multi state, we will handle the video as a photo"]];
}
}
} else {
NSArray *selectedModels = [NSArray arrayWithArray:_tzImagePickerVc.selectedModels];
for (TZAssetModel *model_item in selectedModels) {
if ([[[TZImageManager manager] getAssetIdentifier:model.asset] isEqualToString:[[TZImageManager manager] getAssetIdentifier:model_item.asset]]) {
// 1.6.7:model,
NSArray *selectedModelsTmp = [NSArray arrayWithArray:_tzImagePickerVc.selectedModels];
for (NSInteger i = 0; i < selectedModelsTmp.count; i++) {
TZAssetModel *model = selectedModelsTmp[i];
if ([model isEqual:model_item]) {
[_tzImagePickerVc removeSelectedModel:model];
// [_tzImagePickerVc.selectedModels removeObjectAtIndex:i];
break;
}
}
if (self.photos) {
// 1.6.7:asset,
NSArray *selectedAssetsTmp = [NSArray arrayWithArray:_tzImagePickerVc.selectedAssets];
for (NSInteger i = 0; i < selectedAssetsTmp.count; i++) {
id asset = selectedAssetsTmp[i];
if ([asset isEqual:_assetsTemp[_currentIndex]]) {
[_tzImagePickerVc.selectedAssets removeObjectAtIndex:i];
break;
}
}
// [_tzImagePickerVc.selectedAssets removeObject:_assetsTemp[_currentIndex]];
[self.photos removeObject:_photosTemp[_currentIndex]];
}
break;
}
}
}
model.isSelected = !selectButton.isSelected;
[self refreshNaviBarAndBottomBarState];
if (model.isSelected) {
[UIView showOscillatoryAnimationWithLayer:selectButton.imageView.layer type:TZOscillatoryAnimationToBigger];
}
[UIView showOscillatoryAnimationWithLayer:_numberImageView.layer type:TZOscillatoryAnimationToSmaller];
}
- (void)backButtonClick {
if (self.navigationController.childViewControllers.count < 2) {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
if ([self.navigationController isKindOfClass: [TZImagePickerController class]]) {
TZImagePickerController *nav = (TZImagePickerController *)self.navigationController;
if (nav.imagePickerControllerDidCancelHandle) {
nav.imagePickerControllerDidCancelHandle();
}
}
return;
}
[self.navigationController popViewControllerAnimated:YES];
if (self.backButtonClickBlock) {
self.backButtonClickBlock(_isSelectOriginalPhoto);
}
}
- (void)doneButtonClick {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
// iCloud,
if (_progress > 0 && _progress < 1 && (_selectButton.isSelected || !_tzImagePickerVc.selectedModels.count )) {
_alertView = [_tzImagePickerVc showAlertWithTitle:[NSBundle tz_localizedStringForKey:@"Synchronizing photos from iCloud"]];
return;
}
//
if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0) {
TZAssetModel *model = _models[_currentIndex];
[_tzImagePickerVc addSelectedModel:model];
}
if (_tzImagePickerVc.allowCrop) { //
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_currentIndex inSection:0];
TZPhotoPreviewCell *cell = (TZPhotoPreviewCell *)[_collectionView cellForItemAtIndexPath:indexPath];
UIImage *cropedImage = [TZImageCropManager cropImageView:cell.previewView.imageView toRect:_tzImagePickerVc.cropRect zoomScale:cell.previewView.scrollView.zoomScale containerView:self.view];
if (_tzImagePickerVc.needCircleCrop) {
cropedImage = [TZImageCropManager circularClipImage:cropedImage];
}
if (self.doneButtonClickBlockCropMode) {
TZAssetModel *model = _models[_currentIndex];
self.doneButtonClickBlockCropMode(cropedImage,model.asset);
}
} else if (self.doneButtonClickBlock) { //
self.doneButtonClickBlock(_isSelectOriginalPhoto);
}
if (self.doneButtonClickBlockWithPreviewType) {
self.doneButtonClickBlockWithPreviewType(self.photos,_tzImagePickerVc.selectedAssets,self.isSelectOriginalPhoto);
}
}
- (void)originalPhotoButtonClick {
_originalPhotoButton.selected = !_originalPhotoButton.isSelected;
_isSelectOriginalPhoto = _originalPhotoButton.isSelected;
_originalPhotoLabel.hidden = !_originalPhotoButton.isSelected;
if (_isSelectOriginalPhoto) {
[self showPhotoBytes];
if (!_selectButton.isSelected) {
// < && 1
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (_tzImagePickerVc.selectedModels.count < _tzImagePickerVc.maxImagesCount && _tzImagePickerVc.showSelectBtn) {
[self select:_selectButton];
}
}
}
}
- (void)didTapPreviewCell {
self.isHideNaviBar = !self.isHideNaviBar;
_naviBar.hidden = self.isHideNaviBar;
_toolBar.hidden = self.isHideNaviBar;
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat offSetWidth = scrollView.contentOffset.x;
offSetWidth = offSetWidth + ((self.view.tz_width + 20) * 0.5);
NSInteger currentIndex = offSetWidth / (self.view.tz_width + 20);
if (currentIndex < _models.count && _currentIndex != currentIndex) {
_currentIndex = currentIndex;
[self refreshNaviBarAndBottomBarState];
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"photoPreviewCollectionViewDidScroll" object:nil];
}
#pragma mark - UICollectionViewDataSource && Delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return _models.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[indexPath.item];
TZAssetPreviewCell *cell;
__weak typeof(self) weakSelf = self;
if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypeVideo) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZVideoPreviewCell" forIndexPath:indexPath];
} else if (_tzImagePickerVc.allowPickingMultipleVideo && model.type == TZAssetModelMediaTypePhotoGif && _tzImagePickerVc.allowPickingGif) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZGifPreviewCell" forIndexPath:indexPath];
} else {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZPhotoPreviewCell" forIndexPath:indexPath];
TZPhotoPreviewCell *photoPreviewCell = (TZPhotoPreviewCell *)cell;
photoPreviewCell.cropRect = _tzImagePickerVc.cropRect;
photoPreviewCell.allowCrop = _tzImagePickerVc.allowCrop;
__weak typeof(_tzImagePickerVc) weakTzImagePickerVc = _tzImagePickerVc;
__weak typeof(_collectionView) weakCollectionView = _collectionView;
__weak typeof(photoPreviewCell) weakCell = photoPreviewCell;
[photoPreviewCell setImageProgressUpdateBlock:^(double progress) {
__strong typeof(weakSelf) strongSelf = weakSelf;
__strong typeof(weakTzImagePickerVc) strongTzImagePickerVc = weakTzImagePickerVc;
__strong typeof(weakCollectionView) strongCollectionView = weakCollectionView;
__strong typeof(weakCell) strongCell = weakCell;
strongSelf.progress = progress;
if (progress >= 1) {
if (strongSelf.isSelectOriginalPhoto) [strongSelf showPhotoBytes];
if (strongSelf.alertView && [strongCollectionView.visibleCells containsObject:strongCell]) {
[strongTzImagePickerVc hideAlertView:strongSelf.alertView];
strongSelf.alertView = nil;
[strongSelf doneButtonClick];
}
}
}];
}
cell.model = model;
[cell setSingleTapGestureBlock:^{
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf didTapPreviewCell];
}];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) {
[(TZPhotoPreviewCell *)cell recoverSubviews];
}
}
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
if ([cell isKindOfClass:[TZPhotoPreviewCell class]]) {
[(TZPhotoPreviewCell *)cell recoverSubviews];
} else if ([cell isKindOfClass:[TZVideoPreviewCell class]]) {
[(TZVideoPreviewCell *)cell pausePlayerAndShowNaviBar];
}
}
#pragma mark - Private Method
- (void)dealloc {
// NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}
- (void)refreshNaviBarAndBottomBarState {
TZImagePickerController *_tzImagePickerVc = (TZImagePickerController *)self.navigationController;
TZAssetModel *model = _models[_currentIndex];
_selectButton.selected = model.isSelected;
[self refreshSelectButtonImageViewContentMode];
if (_selectButton.isSelected && _tzImagePickerVc.showSelectedIndex) {
NSString *assetId = [[TZImageManager manager] getAssetIdentifier:model.asset];
NSString *index = [NSString stringWithFormat:@"%zd", [_tzImagePickerVc.selectedAssetIds indexOfObject:assetId] + 1];
_indexLabel.text = index;
_indexLabel.hidden = NO;
} else {
_indexLabel.hidden = YES;
}
_numberLabel.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
_numberImageView.hidden = (_tzImagePickerVc.selectedModels.count <= 0 || _isHideNaviBar || _isCropImage);
_numberLabel.hidden = (_tzImagePickerVc.selectedModels.count <= 0 || _isHideNaviBar || _isCropImage);
_originalPhotoButton.selected = _isSelectOriginalPhoto;
_originalPhotoLabel.hidden = !_originalPhotoButton.isSelected;
if (_isSelectOriginalPhoto) [self showPhotoBytes];
// If is previewing video, hide original photo button
//
if (!_isHideNaviBar) {
if (model.type == TZAssetModelMediaTypeVideo) {
_originalPhotoButton.hidden = YES;
_originalPhotoLabel.hidden = YES;
} else {
_originalPhotoButton.hidden = NO;
if (_isSelectOriginalPhoto) _originalPhotoLabel.hidden = NO;
}
}
_doneButton.hidden = NO;
_selectButton.hidden = !_tzImagePickerVc.showSelectBtn;
// /
if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) {
_numberLabel.hidden = YES;
_numberImageView.hidden = YES;
_selectButton.hidden = YES;
_originalPhotoButton.hidden = YES;
_originalPhotoLabel.hidden = YES;
_doneButton.hidden = YES;
}
}
- (void)refreshSelectButtonImageViewContentMode {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self->_selectButton.imageView.image.size.width <= 27) {
self->_selectButton.imageView.contentMode = UIViewContentModeCenter;
} else {
self->_selectButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
}
});
}
- (void)showPhotoBytes {
[[TZImageManager manager] getPhotosBytesWithArray:@[_models[_currentIndex]] completion:^(NSString *totalBytes) {
self->_originalPhotoLabel.text = [NSString stringWithFormat:@"(%@)",totalBytes];
}];
}
@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 5,786 |
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Group</string>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Name</string>
<key>Key</key>
<string>name_preference</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Enabled</string>
<key>Key</key>
<string>enabled_preference</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSSliderSpecifier</string>
<key>Key</key>
<string>slider_preference</string>
<key>DefaultValue</key>
<real>0.5</real>
<key>MinimumValue</key>
<integer>0</integer>
<key>MaximumValue</key>
<integer>1</integer>
<key>MinimumValueImage</key>
<string></string>
<key>MaximumValueImage</key>
<string></string>
</dict>
</array>
</dict>
</plist>
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/Root.plist | xml | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 499 |
```unknown
"OK" = "Xc nhn";
"Back" = "Quay li";
"Done" = "Hon thnh";
"Sorry" = "Xin li";
"Cancel" = "Hy";
"Setting" = "Ci t";
"Photos" = "Hnh";
"Videos" = "Clip";
"Preview" = "Xem trc";
"Full image" = "Hnh gc";
"Processing..." = "ang x l...";
"Can not use camera" = "My chp hnh khng kh dng";
"Synchronizing photos from iCloud" = "ang ng b hnh nh t ICloud";
"Can not choose both video and photo" = "Trong lc chn hnh nh khng cng lc chn video";
"Can not choose both photo and GIF" = "Trong lc chn hnh nh khng cng lc chn hnh GIF";
"Select the video when in multi state, we will handle the video as a photo" = "Chn hnh nh cng video, video s b mc nhn thnh hnh nh v gi i.";
"Can not jump to the privacy settings page, please go to the settings page by self, thank you" = "Khng th chuyn t ng qua trang ci t ring t, bn hy thot ra c iu chnh li, cm n bn.";
"Select a maximum of %zd photos" = "Bn ch c chn nhiu nht %zd tm hnh";
"Select a minimum of %zd photos" = "Chn t nht %zd tm hnh";
"Allow %@ to access your album in \"Settings -> Privacy -> Photos\"" = "Vui lng ti mc iPhone \" Ci t quyn ring t - nh\" m quyn cho php %@ truy cp nh.";
"Please allow %@ to access your camera in \"Settings -> Privacy -> Camera\"" = "Vui lng ti mc iPhone \" Ci t quyn ring t - nh\" m quyn cho php %@ truy cp my nh";
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImagePickerController.bundle/vi.lproj/Localizable.strings | unknown | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 428 |
```objective-c
#import "GPUImageTwoInputFilter.h"
@interface GPUImageExclusionBlendFilter : GPUImageTwoInputFilter
{
}
@end
``` | /content/code_sandbox/Pods/GPUImage/framework/Source/GPUImageExclusionBlendFilter.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 28 |
```objective-c
#import "GPUImageDarkenBlendFilter.h"
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImageDarkenBlendFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;
varying highp vec2 textureCoordinate2;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
void main()
{
lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);
lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);
gl_FragColor = vec4(min(overlayer.rgb * base.a, base.rgb * overlayer.a) + overlayer.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlayer.a), 1.0);
}
);
#else
NSString *const kGPUImageDarkenBlendFragmentShaderString = SHADER_STRING
(
varying vec2 textureCoordinate;
varying vec2 textureCoordinate2;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
void main()
{
vec4 base = texture2D(inputImageTexture, textureCoordinate);
vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);
gl_FragColor = vec4(min(overlayer.rgb * base.a, base.rgb * overlayer.a) + overlayer.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlayer.a), 1.0);
}
);
#endif
@implementation GPUImageDarkenBlendFilter
- (id)init;
{
if (!(self = [super initWithFragmentShaderFromString:kGPUImageDarkenBlendFragmentShaderString]))
{
return nil;
}
return self;
}
@end
``` | /content/code_sandbox/Pods/GPUImage/framework/Source/GPUImageDarkenBlendFilter.m | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 375 |
```objective-c
//
// TZImageManager.h
// TZImagePickerController
//
// Created by on 16/1/4.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <Photos/Photos.h>
#import "TZAssetModel.h"
@class TZAlbumModel,TZAssetModel;
@protocol TZImagePickerControllerDelegate;
@interface TZImageManager : NSObject
@property (nonatomic, strong) PHCachingImageManager *cachingImageManager;
+ (instancetype)manager NS_SWIFT_NAME(default());
+ (void)deallocManager;
@property (weak, nonatomic) id<TZImagePickerControllerDelegate> pickerDelegate;
@property (nonatomic, assign) BOOL shouldFixOrientation;
/// Default is 600px / 600
@property (nonatomic, assign) CGFloat photoPreviewMaxWidth;
/// The pixel width of output image, Default is 828px / 828
@property (nonatomic, assign) CGFloat photoWidth;
/// Default is 4, Use in photos collectionView in TZPhotoPickerController
/// 4, TZPhotoPickerControllercollectionView
@property (nonatomic, assign) NSInteger columnNumber;
/// Sort photos ascending by modificationDateDefault is YES
/// YESNO,
@property (nonatomic, assign) BOOL sortAscendingByModificationDate;
/// Minimum selectable photo width, Default is 0
/// 0
@property (nonatomic, assign) NSInteger minPhotoWidthSelectable;
@property (nonatomic, assign) NSInteger minPhotoHeightSelectable;
@property (nonatomic, assign) BOOL hideWhenCanNotSelect;
/// Return YES if Authorized YES
- (BOOL)authorizationStatusAuthorized;
+ (NSInteger)authorizationStatus;
- (void)requestAuthorizationWithCompletion:(void (^)(void))completion;
/// Get Album /
- (void)getCameraRollAlbum:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage needFetchAssets:(BOOL)needFetchAssets completion:(void (^)(TZAlbumModel *model))completion;
- (void)getAllAlbums:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage needFetchAssets:(BOOL)needFetchAssets completion:(void (^)(NSArray<TZAlbumModel *> *models))completion;
/// Get Assets Asset
- (void)getAssetsFromFetchResult:(id)result completion:(void (^)(NSArray<TZAssetModel *> *models))completion;
- (void)getAssetsFromFetchResult:(id)result allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(NSArray<TZAssetModel *> *models))completion;
- (void)getAssetFromFetchResult:(id)result atIndex:(NSInteger)index allowPickingVideo:(BOOL)allowPickingVideo allowPickingImage:(BOOL)allowPickingImage completion:(void (^)(TZAssetModel *model))completion;
/// Get photo
- (void)getPostImageWithAlbumModel:(TZAlbumModel *)model completion:(void (^)(UIImage *postImage))completion;
- (int32_t)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
- (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
- (int32_t)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed;
- (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed;
- (int32_t)requestImageDataForAsset:(id)asset completion:(void (^)(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler;
/// Get full Image
/// completion(API)info[PHImageResultIsDegradedKey] YES
- (void)getOriginalPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info))completion;
- (void)getOriginalPhotoWithAsset:(id)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
// completion
- (void)getOriginalPhotoDataWithAsset:(id)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;
- (void)getOriginalPhotoDataWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;
/// Save photo
- (void)savePhotoWithImage:(UIImage *)image completion:(void (^)(NSError *error))completion;
- (void)savePhotoWithImage:(UIImage *)image location:(CLLocation *)location completion:(void (^)(NSError *error))completion;
/// Save video
- (void)saveVideoWithUrl:(NSURL *)url completion:(void (^)(NSError *error))completion;
- (void)saveVideoWithUrl:(NSURL *)url location:(CLLocation *)location completion:(void (^)(NSError *error))completion;
/// Get video
- (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * playerItem, NSDictionary * info))completion;
- (void)getVideoWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(AVPlayerItem *, NSDictionary *))completion;
/// Export video presetName: AVAssetExportPreset640x480
- (void)getVideoOutputPathWithAsset:(id)asset success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure;
- (void)getVideoOutputPathWithAsset:(id)asset presetName:(NSString *)presetName success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure;
/// Deprecated, Use -getVideoOutputPathWithAsset:failure:success:
- (void)getVideoOutputPathWithAsset:(id)asset completion:(void (^)(NSString *outputPath))completion __attribute__((deprecated("Use -getVideoOutputPathWithAsset:failure:success:")));
/// Get photo bytes
- (void)getPhotosBytesWithArray:(NSArray *)photos completion:(void (^)(NSString *totalBytes))completion;
/// Judge is a assets array contain the asset assetsasset
- (BOOL)isAssetsArray:(NSArray *)assets containAsset:(id)asset;
- (NSString *)getAssetIdentifier:(id)asset;
- (BOOL)isCameraRollAlbum:(id)metadata;
///
- (BOOL)isPhotoSelectableWithAsset:(id)asset;
- (CGSize)photoSizeWithAsset:(id)asset;
///
- (UIImage *)fixOrientation:(UIImage *)aImage;
/// asset
- (TZAssetModelMediaType)getAssetType:(id)asset;
///
- (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size;
@end
//@interface TZSortDescriptor : NSSortDescriptor
//
//@end
``` | /content/code_sandbox/Pods/TZImagePickerController/TZImagePickerController/TZImagePickerController/TZImageManager.h | objective-c | 2016-02-02T02:51:55 | 2024-08-09T08:55:27 | WMPlayer | zhengwenming/WMPlayer | 3,272 | 1,566 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.