-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Config AFImageDownloader NSURLCache and ask AFImageRequestCache implementer if an image should be cached #4010
Config AFImageDownloader NSURLCache and ask AFImageRequestCache implementer if an image should be cached #4010
Conversation
Hoping this will fly with you guys ;) With these new features, we can do this:
|
Codecov Report
@@ Coverage Diff @@
## master #4010 +/- ##
==========================================
+ Coverage 82.52% 82.77% +0.25%
==========================================
Files 45 45
Lines 5270 5371 +101
Branches 439 442 +3
==========================================
+ Hits 4349 4446 +97
- Misses 682 685 +3
- Partials 239 240 +1
Continue to review full report at Codecov.
|
…com/WJE/AFNetworking into config_afimagedownloader_nsurlcache
Candidate resolution for AFNetworking/issues/4008 and See AFNetworking/issues/4009 |
Hello @SlaunchaMan, @TheDom, it seems you were the last people to PR. Could you help getting this PR reviewed (and hopefully accepted)? Also, there hasn't been any release since March last year. Are there any plans for a new 3.1.x release? |
🎉🎉🎉🎉🎉 I suppose you'll do the merge, @hemangshah? |
Fixes #4035 |
@wjehenddher I don’t see the |
Fixes #4008 |
HI @SlaunchaMan About #4010 (comment) I'm being consistent with the other methods: the param - (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; within AFAutoPurgingImageCache.h The test case is here: It's a mock that returns Makes sense? |
🎉🎉🎉🎉🎉 Thank you @SlaunchaMan Do you folks have ETA for new AFN 3.x release? |
Hopefully very soon! |
Before this I was using this piece of code
The only issue I'm getting with this is I always end up with animation on imageView. Previously I was checking if response is not null it means the image was downloaded from network then it's the first time image will be displayed and I add animation. Second execution will return cached image and at that time the response will be nil. So I am directly setting the image. After changing to Disk caching as suggested this isn't working anymore and I'm always getting the animation. Anyone knows how to fix this ? |
How we can get back the cached image after using your code ? |
The new feature consists of 2 parts:
Allow user to config
AFImageDownloader +defaultURLCache
. Currently, the values are hardcoded 20Mb mem, 150Mb disk.Provide a hook in
AFAutoPurgingImageCache
soUIImages
can be filtered before cached. Ideally, one could filter outUIImage
that exceeds certain raster size.Use case for this new two features:
A
UICollectionView
shows thumbnails of JPGs. Tapping anyUICollectionViewCell
opens a full sizeUIImageView
that displays the full size JPG.Under thew current implementation, large JPGs boot out thumbnails.
Hence JPGs and thumbnails are downloaded almost always as both caches keep getting recycled.
References
SO: https://stackoverflow.com/questions/41939774/how-to-limit-size-of-image-disk-cache-using-afnetworking/45329948#45329948
See AFNetworking/issues/4009