Merge pull request #3092 from dreampiggy/fix_animated_image_callback_when_stop
Fix the issue that SDAnimatedImageView will trigger an empty callback when animation stopped. This will cause some bad effect such as rendering a empty image or placeholder image (especially on iOS 14)
This commit is contained in:
commit
3df06e9f4b
|
@ -160,14 +160,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)resetCurrentFrameIndex {
|
||||
self.currentFrame = nil;
|
||||
self.currentFrameIndex = 0;
|
||||
self.currentLoopCount = 0;
|
||||
self.currentTime = 0;
|
||||
self.bufferMiss = NO;
|
||||
self.needsDisplayWhenImageBecomesAvailable = NO;
|
||||
[self handleFrameChange];
|
||||
- (void)resetCurrentFrameStatus {
|
||||
// These should not trigger KVO, user don't need to receive an `index == 0, image == nil` callback.
|
||||
_currentFrame = nil;
|
||||
_currentFrameIndex = 0;
|
||||
_currentLoopCount = 0;
|
||||
_currentTime = 0;
|
||||
_bufferMiss = NO;
|
||||
_needsDisplayWhenImageBecomesAvailable = NO;
|
||||
}
|
||||
|
||||
- (void)clearFrameBuffer {
|
||||
|
@ -191,7 +191,8 @@
|
|||
[_fetchQueue cancelAllOperations];
|
||||
// Using `_displayLink` here because when UIImageView dealloc, it may trigger `[self stopAnimating]`, we already release the display link in SDAnimatedImageView's dealloc method.
|
||||
[_displayLink stop];
|
||||
[self resetCurrentFrameIndex];
|
||||
// We need to reset the frame status, but not trigger any handle. This can ensure next time's playing status correct.
|
||||
[self resetCurrentFrameStatus];
|
||||
}
|
||||
|
||||
- (void)pausePlaying {
|
||||
|
|
|
@ -395,7 +395,6 @@ static const NSUInteger kTestGIFFrameCount = 5; // local TestImage.gif loop coun
|
|||
imageView.animates = NO;
|
||||
#endif
|
||||
expect(imageView.player.frameBuffer.count).equal(0);
|
||||
expect(imageView.currentFrameIndex).equal(0);
|
||||
|
||||
[imageView removeFromSuperview];
|
||||
[expectation fulfill];
|
||||
|
|
Loading…
Reference in New Issue