Address comments and cleanup

This commit is contained in:
Garrett Moon 2016-04-06 10:59:10 -07:00
parent f4b526a8db
commit e9b57d9da4
8 changed files with 36 additions and 23 deletions

View File

@ -1,23 +1,15 @@
// //
// ASImageNode+AnimatedImage.h // ASImageNode+AnimatedImage.h
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 3/22/16. // Created by Garrett Moon on 3/22/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
#import "ASImageNode.h" #import "ASImageNode.h"
#import "ASImageProtocols.h" #import "ASImageProtocols.h"
@interface ASImageNode () @interface ASImageNode ()
@property (atomic, assign) BOOL animatedImagePaused; @property (atomic, assign) BOOL animatedImagePaused;
@end
@interface ASImageNode (AnimatedImage)
@property (nullable, atomic, strong) id <ASAnimatedImageProtocol> animatedImage; @property (nullable, atomic, strong) id <ASAnimatedImageProtocol> animatedImage;
@end @end

View File

@ -1,9 +1,9 @@
// //
// ASImageNode+AnimatedImage.m // ASImageNode+AnimatedImage.m
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 3/22/16. // Created by Garrett Moon on 3/22/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
#import "ASImageNode+AnimatedImage.h" #import "ASImageNode+AnimatedImage.h"
@ -15,6 +15,7 @@
#import "ASEqualityHelpers.h" #import "ASEqualityHelpers.h"
#import "ASDisplayNode+FrameworkPrivate.h" #import "ASDisplayNode+FrameworkPrivate.h"
#import "ASImageNode+AnimatedImagePrivate.h" #import "ASImageNode+AnimatedImagePrivate.h"
#import "ASInternalHelpers.h"
@interface ASWeakProxy : NSObject @interface ASWeakProxy : NSObject
@ -53,6 +54,25 @@
return _animatedImage; return _animatedImage;
} }
- (void)setAnimatedImagePaused:(BOOL)animatedImagePaused
{
ASDN::MutexLocker l(_animatedImagePausedLock);
_animatedImagePaused = animatedImagePaused;
ASPerformBlockOnMainThread(^{
if (animatedImagePaused) {
[self stopAnimating];
} else {
[self startAnimating];
}
});
}
- (BOOL)animatedImagePaused
{
ASDN::MutexLocker l(_animatedImagePausedLock);
return _animatedImagePaused;
}
- (void)coverImageCompleted:(UIImage *)coverImage - (void)coverImageCompleted:(UIImage *)coverImage
{ {
BOOL setCoverImage = YES; BOOL setCoverImage = YES;

View File

@ -1,16 +1,18 @@
// //
// ASImageNode+AnimatedImagePrivate.h // ASImageNode+AnimatedImagePrivate.h
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 3/30/16. // Created by Garrett Moon on 3/30/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
@interface ASImageNode () @interface ASImageNode ()
{ {
ASDN::RecursiveMutex _animatedImageLock; ASDN::RecursiveMutex _animatedImageLock;
ASDN::RecursiveMutex _animatedImagePausedLock;
ASDN::Mutex _displayLinkLock; ASDN::Mutex _displayLinkLock;
id <ASAnimatedImageProtocol> _animatedImage; id <ASAnimatedImageProtocol> _animatedImage;
BOOL _animatedImagePaused;
CADisplayLink *_displayLink; CADisplayLink *_displayLink;
//accessed on main thread only //accessed on main thread only

View File

@ -1,9 +1,9 @@
// //
// ASImageContainerProtocolCategories.h // ASImageContainerProtocolCategories.h
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 3/18/16. // Created by Garrett Moon on 3/18/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>

View File

@ -1,9 +1,9 @@
// //
// ASImageContainerProtocolCategories.m // ASImageContainerProtocolCategories.m
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 3/18/16. // Created by Garrett Moon on 3/18/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
#import "ASImageContainerProtocolCategories.h" #import "ASImageContainerProtocolCategories.h"

View File

@ -1,9 +1,9 @@
// //
// ASPINRemoteImageDownloader.h // ASPINRemoteImageDownloader.h
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 2/5/16. // Created by Garrett Moon on 2/5/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>

View File

@ -1,9 +1,9 @@
// //
// ASPINRemoteImageDownloader.m // ASPINRemoteImageDownloader.m
// Pods // AsyncDisplayKit
// //
// Created by Garrett Moon on 2/5/16. // Created by Garrett Moon on 2/5/16.
// // Copyright © 2016 Facebook. All rights reserved.
// //
#ifdef PIN_REMOTE_IMAGE #ifdef PIN_REMOTE_IMAGE

View File

@ -22,7 +22,6 @@
ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] init]; ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] init];
imageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/originals/07/44/38/074438e7c75034df2dcf37ba1057803e.gif"]; imageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/originals/07/44/38/074438e7c75034df2dcf37ba1057803e.gif"];
// imageNode.URL = [NSURL fileURLWithPath:@"/Users/garrett/Downloads/new-transparent-gif-221.gif"];
imageNode.frame = self.view.bounds; imageNode.frame = self.view.bounds;
imageNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; imageNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
imageNode.contentMode = UIViewContentModeScaleAspectFit; imageNode.contentMode = UIViewContentModeScaleAspectFit;