diff --git a/AsyncDisplayKit/ASImageNode+AnimatedImage.h b/AsyncDisplayKit/ASImageNode+AnimatedImage.h index c9fd235c67..9e8126580e 100644 --- a/AsyncDisplayKit/ASImageNode+AnimatedImage.h +++ b/AsyncDisplayKit/ASImageNode+AnimatedImage.h @@ -1,23 +1,15 @@ // // ASImageNode+AnimatedImage.h -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 3/22/16. -// +// Copyright © 2016 Facebook. All rights reserved. // #import "ASImageNode.h" - #import "ASImageProtocols.h" @interface ASImageNode () - @property (atomic, assign) BOOL animatedImagePaused; - -@end - -@interface ASImageNode (AnimatedImage) - @property (nullable, atomic, strong) id animatedImage; - @end diff --git a/AsyncDisplayKit/ASImageNode+AnimatedImage.mm b/AsyncDisplayKit/ASImageNode+AnimatedImage.mm index 6f877903c4..a0533ae245 100644 --- a/AsyncDisplayKit/ASImageNode+AnimatedImage.mm +++ b/AsyncDisplayKit/ASImageNode+AnimatedImage.mm @@ -1,9 +1,9 @@ // // ASImageNode+AnimatedImage.m -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 3/22/16. -// +// Copyright © 2016 Facebook. All rights reserved. // #import "ASImageNode+AnimatedImage.h" @@ -15,6 +15,7 @@ #import "ASEqualityHelpers.h" #import "ASDisplayNode+FrameworkPrivate.h" #import "ASImageNode+AnimatedImagePrivate.h" +#import "ASInternalHelpers.h" @interface ASWeakProxy : NSObject @@ -53,6 +54,25 @@ 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 { BOOL setCoverImage = YES; diff --git a/AsyncDisplayKit/ASImageNode+AnimatedImagePrivate.h b/AsyncDisplayKit/ASImageNode+AnimatedImagePrivate.h index e50619d498..18244b9283 100644 --- a/AsyncDisplayKit/ASImageNode+AnimatedImagePrivate.h +++ b/AsyncDisplayKit/ASImageNode+AnimatedImagePrivate.h @@ -1,16 +1,18 @@ // // ASImageNode+AnimatedImagePrivate.h -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 3/30/16. -// +// Copyright © 2016 Facebook. All rights reserved. // @interface ASImageNode () { ASDN::RecursiveMutex _animatedImageLock; + ASDN::RecursiveMutex _animatedImagePausedLock; ASDN::Mutex _displayLinkLock; id _animatedImage; + BOOL _animatedImagePaused; CADisplayLink *_displayLink; //accessed on main thread only diff --git a/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.h b/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.h index 282317a14f..dfe9e163c2 100644 --- a/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.h +++ b/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.h @@ -1,9 +1,9 @@ // // ASImageContainerProtocolCategories.h -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 3/18/16. -// +// Copyright © 2016 Facebook. All rights reserved. // #import diff --git a/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.m b/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.m index 2c40116a1b..90b3da6f65 100644 --- a/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.m +++ b/AsyncDisplayKit/Details/ASImageContainerProtocolCategories.m @@ -1,9 +1,9 @@ // // ASImageContainerProtocolCategories.m -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 3/18/16. -// +// Copyright © 2016 Facebook. All rights reserved. // #import "ASImageContainerProtocolCategories.h" diff --git a/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.h b/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.h index 1a7850b2fa..12c6b27376 100644 --- a/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.h +++ b/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.h @@ -1,9 +1,9 @@ // // ASPINRemoteImageDownloader.h -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 2/5/16. -// +// Copyright © 2016 Facebook. All rights reserved. // #import diff --git a/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m b/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m index 2c9e6b3d33..eac91e2929 100644 --- a/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m +++ b/AsyncDisplayKit/Details/ASPINRemoteImageDownloader.m @@ -1,9 +1,9 @@ // // ASPINRemoteImageDownloader.m -// Pods +// AsyncDisplayKit // // Created by Garrett Moon on 2/5/16. -// +// Copyright © 2016 Facebook. All rights reserved. // #ifdef PIN_REMOTE_IMAGE diff --git a/examples/ASAnimatedImage/ASAnimatedImage/ViewController.m b/examples/ASAnimatedImage/ASAnimatedImage/ViewController.m index 7f055748fe..9087dfdd5d 100644 --- a/examples/ASAnimatedImage/ASAnimatedImage/ViewController.m +++ b/examples/ASAnimatedImage/ASAnimatedImage/ViewController.m @@ -22,7 +22,6 @@ 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 fileURLWithPath:@"/Users/garrett/Downloads/new-transparent-gif-221.gif"]; imageNode.frame = self.view.bounds; imageNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; imageNode.contentMode = UIViewContentModeScaleAspectFit;