Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes an issue with GIFs that would always be covered by their placeh… #326

Merged
merged 1 commit into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## master

* Add your own contributions to the next release on the line below this with your name.
- Fixed an issue where GIFs with placeholders never had their placeholders uncover the GIF. [Garrett Moon](https://github.com/garrettmoon)
- [Yoga] Implement ASYogaLayoutSpec, a simplified integration strategy for Yoga-powered layout calculation. [Scott Goodson](https://github.com/appleguy)
- Fixed an issue where calls to setNeedsDisplay and setNeedsLayout would stop working on loaded nodes. [Garrett Moon](https://github.com/garrettmoon)
- [ASTextKitFontSizeAdjuster] [Ricky Cancro] Replace use of NSAttributedString's boundingRectWithSize:options:context: with NSLayoutManager's boundingRectForGlyphRange:inTextContainer:
Expand Down
9 changes: 9 additions & 0 deletions Source/ASImageNode+AnimatedImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ - (void)_locked_setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage
return;
}

id <ASAnimatedImageProtocol> previousAnimatedImage = _animatedImage;
_animatedImage = animatedImage;

if (animatedImage != nil) {
Expand All @@ -73,6 +74,13 @@ - (void)_locked_setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage
};
}
}

[self animatedImageSet:_animatedImage previousAnimatedImage:previousAnimatedImage];
}

- (void)animatedImageSet:(id <ASAnimatedImageProtocol>)newAnimatedImage previousAnimatedImage:(id <ASAnimatedImageProtocol>)previousAnimatedImage
{
//Subclasses may override
}

- (id <ASAnimatedImageProtocol>)animatedImage
Expand Down Expand Up @@ -301,6 +309,7 @@ - (void)displayLinkFired:(CADisplayLink *)displayLink
self.lastDisplayLinkFire = 0;
} else {
self.contents = (__bridge id)frameImage;
[self displayDidFinish];
}
}

Expand Down
12 changes: 12 additions & 0 deletions Source/ASImageNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
*
* @discussion Set this to an object which conforms to ASAnimatedImageProtocol
* to have the ASImageNode playback an animated image.
* @warning this method should not be overridden, it may not always be called as
* another method is used internally. If you need to know when the animatedImage
* is set, override @c animatedImageSet:previousAnimatedImage:
*/
@property (nullable, nonatomic, strong) id <ASAnimatedImageProtocol> animatedImage;

Expand All @@ -168,6 +171,15 @@ typedef UIImage * _Nullable (^asimagenode_modification_block_t)(UIImage *image);
*/
@property (nonatomic, strong) NSString *animatedImageRunLoopMode;

/**
* @abstract Method called when animated image has been set
*
* @discussion This method is for subclasses to override so they can know if an animated image
* has been set on the node.
* @warning this method is called with the node's lock held.
*/
- (void)animatedImageSet:(id <ASAnimatedImageProtocol>)newAnimatedImage previousAnimatedImage:(id <ASAnimatedImageProtocol>)previousAnimatedImage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe didSetAnimatedImage:oldValue: is a little clearer and more terse?


@end

@interface ASImageNode (Unavailable)
Expand Down
2 changes: 1 addition & 1 deletion Source/ASMultiplexImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ - (void)displayDidFinish

- (BOOL)placeholderShouldPersist
{
return (self.image == nil && self.imageIdentifiers.count > 0);
return (self.image == nil && self.animatedImage == nil && self.imageIdentifiers.count > 0);
}

/* displayWillStart in ASNetworkImageNode has a very similar implementation. Changes here are likely necessary
Expand Down
2 changes: 1 addition & 1 deletion Source/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ - (BOOL)shouldRenderProgressImages
- (BOOL)placeholderShouldPersist
{
ASDN::MutexLocker l(__instanceLock__);
return (self.image == nil && _URL != nil);
return (self.image == nil && self.animatedImage == nil && _URL != nil);
}

/* displayWillStart in ASMultiplexImageNode has a very similar implementation. Changes here are likely necessary
Expand Down