Merge pull request #2530 from zhongwuzw/fix_flanimatedImage_step_2
Fix FLAnimatedImageView reuse wrong image && remove GCD strong retained
This commit is contained in:
commit
944c57eaa9
|
@ -145,9 +145,12 @@ static inline FLAnimatedImage * SDWebImageCreateFLAnimatedImage(FLAnimatedImageV
|
||||||
dispatch_group_leave(group);
|
dispatch_group_leave(group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
__weak typeof(strongSelf) wweakSelf = strongSelf;
|
||||||
// Hack, mark we need should use dispatch group notify for completedBlock
|
// Hack, mark we need should use dispatch group notify for completedBlock
|
||||||
objc_setAssociatedObject(group, &SDWebImageInternalSetImageGroupKey, @(YES), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
objc_setAssociatedObject(group, &SDWebImageInternalSetImageGroupKey, @(YES), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
|
__strong typeof(wweakSelf) sstrongSelf = wweakSelf;
|
||||||
|
if (!sstrongSelf || ![url isEqual:sstrongSelf.sd_imageURL]) { return ; }
|
||||||
// Step 3. Check if data exist or query disk cache
|
// Step 3. Check if data exist or query disk cache
|
||||||
__block NSData *gifData = imageData;
|
__block NSData *gifData = imageData;
|
||||||
if (!gifData) {
|
if (!gifData) {
|
||||||
|
@ -155,18 +158,19 @@ static inline FLAnimatedImage * SDWebImageCreateFLAnimatedImage(FLAnimatedImageV
|
||||||
gifData = [[SDImageCache sharedImageCache] diskImageDataForKey:key];
|
gifData = [[SDImageCache sharedImageCache] diskImageDataForKey:key];
|
||||||
}
|
}
|
||||||
// Step 4. Create FLAnimatedImage
|
// Step 4. Create FLAnimatedImage
|
||||||
FLAnimatedImage *animatedImage = SDWebImageCreateFLAnimatedImage(strongSelf, gifData);
|
FLAnimatedImage *animatedImage = SDWebImageCreateFLAnimatedImage(sstrongSelf, gifData);
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (![url isEqual:sstrongSelf.sd_imageURL]) { return ; }
|
||||||
// Step 5. Set animatedImage or normal image
|
// Step 5. Set animatedImage or normal image
|
||||||
if (animatedImage) {
|
if (animatedImage) {
|
||||||
if (strongSelf.sd_cacheFLAnimatedImage) {
|
if (sstrongSelf.sd_cacheFLAnimatedImage) {
|
||||||
image.sd_FLAnimatedImage = animatedImage;
|
image.sd_FLAnimatedImage = animatedImage;
|
||||||
}
|
}
|
||||||
strongSelf.image = animatedImage.posterImage;
|
sstrongSelf.image = animatedImage.posterImage;
|
||||||
strongSelf.animatedImage = animatedImage;
|
sstrongSelf.animatedImage = animatedImage;
|
||||||
} else {
|
} else {
|
||||||
strongSelf.image = image;
|
sstrongSelf.image = image;
|
||||||
strongSelf.animatedImage = nil;
|
sstrongSelf.animatedImage = nil;
|
||||||
}
|
}
|
||||||
dispatch_group_leave(group);
|
dispatch_group_leave(group);
|
||||||
});
|
});
|
||||||
|
@ -174,7 +178,7 @@ static inline FLAnimatedImage * SDWebImageCreateFLAnimatedImage(FLAnimatedImageV
|
||||||
}
|
}
|
||||||
progress:progressBlock
|
progress:progressBlock
|
||||||
completed:completedBlock
|
completed:completedBlock
|
||||||
context:@{SDWebImageInternalSetImageGroupKey : group}];
|
context:@{SDWebImageInternalSetImageGroupKey: group}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue