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)
Showing 1 of 2 files from the diff.
Other files ignored by Codecov
Tests/Tests/SDAnimatedImageTest.m
has changed.
@@ -160,14 +160,14 @@
Loading
160 | 160 | } |
|
161 | 161 | } |
|
162 | 162 | ||
163 | - | - (void)resetCurrentFrameIndex { |
|
164 | - | self.currentFrame = nil; |
|
165 | - | self.currentFrameIndex = 0; |
|
166 | - | self.currentLoopCount = 0; |
|
167 | - | self.currentTime = 0; |
|
168 | - | self.bufferMiss = NO; |
|
169 | - | self.needsDisplayWhenImageBecomesAvailable = NO; |
|
170 | - | [self handleFrameChange]; |
|
163 | + | - (void)resetCurrentFrameStatus { |
|
164 | + | // These should not trigger KVO, user don't need to receive an `index == 0, image == nil` callback. |
|
165 | + | _currentFrame = nil; |
|
166 | + | _currentFrameIndex = 0; |
|
167 | + | _currentLoopCount = 0; |
|
168 | + | _currentTime = 0; |
|
169 | + | _bufferMiss = NO; |
|
170 | + | _needsDisplayWhenImageBecomesAvailable = NO; |
|
171 | 171 | } |
|
172 | 172 | ||
173 | 173 | - (void)clearFrameBuffer { |
@@ -191,7 +191,8 @@
Loading
191 | 191 | [_fetchQueue cancelAllOperations]; |
|
192 | 192 | // Using `_displayLink` here because when UIImageView dealloc, it may trigger `[self stopAnimating]`, we already release the display link in SDAnimatedImageView's dealloc method. |
|
193 | 193 | [_displayLink stop]; |
|
194 | - | [self resetCurrentFrameIndex]; |
|
194 | + | // We need to reset the frame status, but not trigger any handle. This can ensure next time's playing status correct. |
|
195 | + | [self resetCurrentFrameStatus]; |
|
195 | 196 | } |
|
196 | 197 | ||
197 | 198 | - (void)pausePlaying { |
Files | Coverage |
---|---|
SDWebImage | 83.27% |
SDWebImageMapKit/MapKit/MKAnnotationView+WebCache.m | 65.51% |
Project Totals (70 files) | 83.20% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.