mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Follow up to animated GIF PR
This commit is contained in:
@@ -251,9 +251,7 @@
|
||||
509E68661B3AEDD7009B9150 /* CGRect+ASConvenience.m in Sources */ = {isa = PBXBuildFile; fileRef = 205F0E201B376416007741D0 /* CGRect+ASConvenience.m */; };
|
||||
636EA1A41C7FF4EC00EE152F /* NSArray+Diffing.m in Sources */ = {isa = PBXBuildFile; fileRef = DBC452DA1C5BF64600B16017 /* NSArray+Diffing.m */; };
|
||||
636EA1A51C7FF4EF00EE152F /* ASDefaultPlayButton.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB7B0191C5962EA00662EF4 /* ASDefaultPlayButton.m */; };
|
||||
68355B301CB5799E001D4E68 /* ASImageNode+AnimatedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 68355B2D1CB5799E001D4E68 /* ASImageNode+AnimatedImage.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
68355B311CB5799E001D4E68 /* ASImageNode+AnimatedImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 68355B2E1CB5799E001D4E68 /* ASImageNode+AnimatedImage.mm */; };
|
||||
68355B331CB579AD001D4E68 /* ASImageNode+AnimatedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 68355B2D1CB5799E001D4E68 /* ASImageNode+AnimatedImage.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
68355B341CB579B9001D4E68 /* ASImageNode+AnimatedImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 68355B2E1CB5799E001D4E68 /* ASImageNode+AnimatedImage.mm */; };
|
||||
68355B3A1CB57A5A001D4E68 /* ASPINRemoteImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 68355B361CB57A5A001D4E68 /* ASPINRemoteImageDownloader.m */; };
|
||||
68355B3B1CB57A5A001D4E68 /* ASImageContainerProtocolCategories.h in Headers */ = {isa = PBXBuildFile; fileRef = 68355B371CB57A5A001D4E68 /* ASImageContainerProtocolCategories.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -759,7 +757,6 @@
|
||||
4640521B1A3F83C40061C0BA /* ASFlowLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASFlowLayoutController.h; sourceTree = "<group>"; };
|
||||
4640521C1A3F83C40061C0BA /* ASFlowLayoutController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASFlowLayoutController.mm; sourceTree = "<group>"; };
|
||||
4640521D1A3F83C40061C0BA /* ASLayoutController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutController.h; sourceTree = "<group>"; };
|
||||
68355B2D1CB5799E001D4E68 /* ASImageNode+AnimatedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASImageNode+AnimatedImage.h"; sourceTree = "<group>"; };
|
||||
68355B2E1CB5799E001D4E68 /* ASImageNode+AnimatedImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "ASImageNode+AnimatedImage.mm"; sourceTree = "<group>"; };
|
||||
68355B361CB57A5A001D4E68 /* ASPINRemoteImageDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPINRemoteImageDownloader.m; sourceTree = "<group>"; };
|
||||
68355B371CB57A5A001D4E68 /* ASImageContainerProtocolCategories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASImageContainerProtocolCategories.h; sourceTree = "<group>"; };
|
||||
@@ -1048,7 +1045,6 @@
|
||||
0587F9BC1A7309ED00AFF0BA /* ASEditableTextNode.mm */,
|
||||
058D09DD195D050800B7D73C /* ASImageNode.h */,
|
||||
058D09DE195D050800B7D73C /* ASImageNode.mm */,
|
||||
68355B2D1CB5799E001D4E68 /* ASImageNode+AnimatedImage.h */,
|
||||
68355B2E1CB5799E001D4E68 /* ASImageNode+AnimatedImage.mm */,
|
||||
0516FA3E1A1563D200B4EBED /* ASMultiplexImageNode.h */,
|
||||
0516FA3F1A1563D200B4EBED /* ASMultiplexImageNode.mm */,
|
||||
@@ -1536,7 +1532,6 @@
|
||||
257754C31BEE458E00737CA5 /* ASTextNodeTypes.h in Headers */,
|
||||
9C49C36F1B853957000B0DD5 /* ASStackLayoutable.h in Headers */,
|
||||
69E1006D1CA89CB600D88C1B /* ASEnvironmentInternal.h in Headers */,
|
||||
68355B301CB5799E001D4E68 /* ASImageNode+AnimatedImage.h in Headers */,
|
||||
AC21EC101B3D0BF600C8B19A /* ASStackLayoutDefines.h in Headers */,
|
||||
CC7FD9DE1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */,
|
||||
ACF6ED2F1B17843500DA7C62 /* ASStackLayoutSpec.h in Headers */,
|
||||
@@ -1649,7 +1644,6 @@
|
||||
34EFC75F1B701C8600AD841F /* ASInsetLayoutSpec.h in Headers */,
|
||||
34EFC75D1B701BE900AD841F /* ASInternalHelpers.h in Headers */,
|
||||
34EFC7671B701CD900AD841F /* ASLayout.h in Headers */,
|
||||
68355B331CB579AD001D4E68 /* ASImageNode+AnimatedImage.h in Headers */,
|
||||
DEC146B71C37A16A004A0EE7 /* ASCollectionInternal.h in Headers */,
|
||||
DBDB83951C6E879900D0098C /* ASPagerFlowLayout.h in Headers */,
|
||||
34EFC7691B701CE100AD841F /* ASLayoutable.h in Headers */,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// ASImageNode+AnimatedImage.h
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Garrett Moon on 3/22/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ASImageNode.h"
|
||||
#import "ASImageProtocols.h"
|
||||
|
||||
@interface ASImageNode (AnimatedImage)
|
||||
@property (atomic, assign) BOOL animatedImagePaused;
|
||||
@property (nullable, atomic, strong) id <ASAnimatedImageProtocol> animatedImage;
|
||||
@end
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ASImageNode+AnimatedImage.h"
|
||||
#import "ASImageNode.h"
|
||||
|
||||
#import "ASAssert.h"
|
||||
#import "ASImageProtocols.h"
|
||||
@@ -25,9 +25,12 @@
|
||||
- (void)setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage
|
||||
{
|
||||
ASDN::MutexLocker l(_animatedImageLock);
|
||||
if (!ASObjectIsEqual(_animatedImage, animatedImage)) {
|
||||
_animatedImage = animatedImage;
|
||||
if (ASObjectIsEqual(_animatedImage, animatedImage)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_animatedImage = animatedImage;
|
||||
|
||||
if (animatedImage != nil) {
|
||||
__weak ASImageNode *weakSelf = self;
|
||||
if ([animatedImage respondsToSelector:@selector(setCoverImageReadyCallback:)]) {
|
||||
@@ -50,7 +53,7 @@
|
||||
|
||||
- (void)setAnimatedImagePaused:(BOOL)animatedImagePaused
|
||||
{
|
||||
ASDN::MutexLocker l(_animatedImagePausedLock);
|
||||
ASDN::MutexLocker l(_animatedImageLock);
|
||||
_animatedImagePaused = animatedImagePaused;
|
||||
ASPerformBlockOnMainThread(^{
|
||||
if (animatedImagePaused) {
|
||||
@@ -63,7 +66,7 @@
|
||||
|
||||
- (BOOL)animatedImagePaused
|
||||
{
|
||||
ASDN::MutexLocker l(_animatedImagePausedLock);
|
||||
ASDN::MutexLocker l(_animatedImageLock);
|
||||
return _animatedImagePaused;
|
||||
}
|
||||
|
||||
@@ -84,7 +87,7 @@
|
||||
|
||||
- (void)animatedImageFileReady
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ASPerformBlockOnMainThread(^{
|
||||
[self startAnimating];
|
||||
});
|
||||
}
|
||||
@@ -147,18 +150,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)__enterHierarchy
|
||||
{
|
||||
[super __enterHierarchy];
|
||||
[self startAnimating];
|
||||
}
|
||||
|
||||
- (void)__exitHierarchy
|
||||
{
|
||||
[super __exitHierarchy];
|
||||
[self stopAnimating];
|
||||
}
|
||||
|
||||
- (void)displayLinkFired:(CADisplayLink *)displayLink
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#import <AsyncDisplayKit/ASControlNode.h>
|
||||
|
||||
#import "ASImageProtocols.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
@@ -110,6 +112,22 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
|
||||
*/
|
||||
- (void)setNeedsDisplayWithCompletion:(void (^ _Nullable)(BOOL canceled))displayCompletionBlock;
|
||||
|
||||
/**
|
||||
* @abstract The animated image to playback
|
||||
*
|
||||
* @discussion Set this to an object which conforms to ASAnimatedImageProtocol
|
||||
* to have the ASImageNode playback an animated image.
|
||||
*/
|
||||
@property (nullable, atomic, strong) id <ASAnimatedImageProtocol> animatedImage;
|
||||
|
||||
/**
|
||||
* @abstract Pause the playback of an animated image.
|
||||
*
|
||||
* @discussion Set to YES to pause playback of an animated image and NO to resume
|
||||
* playback.
|
||||
*/
|
||||
@property (atomic, assign) BOOL animatedImagePaused;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#import <AsyncDisplayKit/ASDisplayNodeExtras.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
|
||||
#import <AsyncDisplayKit/ASTextNode.h>
|
||||
#import <AsyncDisplayKit/ASImageNode+AnimatedImage.h>
|
||||
#import <AsyncDisplayKit/ASImageNode+AnimatedImagePrivate.h>
|
||||
|
||||
#import "ASImageNode+CGExtras.h"
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#import "ASThread.h"
|
||||
#import "ASInternalHelpers.h"
|
||||
#import "ASImageContainerProtocolCategories.h"
|
||||
#import "ASImageNode+AnimatedImage.h"
|
||||
|
||||
#if PIN_REMOTE_IMAGE
|
||||
#import "ASPINRemoteImageDownloader.h"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#import <AsyncDisplayKit/ASControlNode.h>
|
||||
#import <AsyncDisplayKit/ASImageNode.h>
|
||||
#import <AsyncDisplayKit/ASImageNode+AnimatedImage.h>
|
||||
#import <AsyncDisplayKit/ASTextNode.h>
|
||||
#import <AsyncDisplayKit/ASButtonNode.h>
|
||||
#import <AsyncDisplayKit/ASMapNode.h>
|
||||
|
||||
@@ -136,21 +136,62 @@ withDownloadIdentifier:(id)downloadIdentifier;
|
||||
|
||||
@protocol ASAnimatedImageProtocol <NSObject>
|
||||
|
||||
/**
|
||||
@abstract Should be called when the objects cover image is ready.
|
||||
@param coverImageReadyCallback a block which receives the cover image.
|
||||
*/
|
||||
@property (nonatomic, strong, readwrite) void (^coverImageReadyCallback)(UIImage *coverImage);
|
||||
|
||||
@required
|
||||
|
||||
/**
|
||||
@abstract Return the objects's cover image.
|
||||
*/
|
||||
@property (nonatomic, readonly) UIImage *coverImage;
|
||||
/**
|
||||
@abstract Return a boolean to indicate that the cover image is ready.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL coverImageReady;
|
||||
/**
|
||||
@abstract Return the total duration of the animated image's playback.
|
||||
*/
|
||||
@property (nonatomic, readonly) CFTimeInterval totalDuration;
|
||||
/**
|
||||
@abstract Return the interval at which playback should occur. Will be set to a CADisplayLink's frame interval.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSUInteger frameInterval;
|
||||
/**
|
||||
@abstract Return the total number of loops the animated image should play or 0 to loop infinitely.
|
||||
*/
|
||||
@property (nonatomic, readonly) size_t loopCount;
|
||||
/**
|
||||
@abstract Return the total number of frames in the animated image.
|
||||
*/
|
||||
@property (nonatomic, readonly) size_t frameCount;
|
||||
/**
|
||||
@abstract Return YES when playback is ready to occur.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL playbackReady;
|
||||
/**
|
||||
@abstract Return any error that has occured. Playback will be paused if this returns non-nil.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSError *error;
|
||||
/**
|
||||
@abstract Should be called when playback is ready.
|
||||
*/
|
||||
@property (nonatomic, strong, readwrite) dispatch_block_t playbackReadyCallback;
|
||||
|
||||
/**
|
||||
@abstract Return the image at a given index.
|
||||
*/
|
||||
- (CGImageRef)imageAtIndex:(NSUInteger)index;
|
||||
/**
|
||||
@abstract Return the duration at a given index.
|
||||
*/
|
||||
- (CFTimeInterval)durationAtIndex:(NSUInteger)index;
|
||||
/**
|
||||
@abstract Clear any cached data. Called when playback is paused.
|
||||
*/
|
||||
- (void)clearAnimatedImageCache;
|
||||
|
||||
@end
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
@interface ASImageNode ()
|
||||
{
|
||||
ASDN::RecursiveMutex _animatedImageLock;
|
||||
ASDN::RecursiveMutex _animatedImagePausedLock;
|
||||
ASDN::Mutex _displayLinkLock;
|
||||
id <ASAnimatedImageProtocol> _animatedImage;
|
||||
BOOL _animatedImagePaused;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// ASAnimatedImage
|
||||
//
|
||||
// Created by Garrett Moon on 3/22/16.
|
||||
// Copyright © 2016 Facebook, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
@end
|
||||
23
examples/AnimatedGIF/ASAnimatedImage/AppDelegate.m
Normal file
23
examples/AnimatedGIF/ASAnimatedImage/AppDelegate.m
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// ASAnimatedImage
|
||||
//
|
||||
// Created by Garrett Moon on 3/22/16.
|
||||
// Copyright © 2016 Facebook, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -29,9 +29,4 @@
|
||||
[self.view addSubnode:imageNode];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user