(OLD)Add better support for stateful view (UIButton) for image URL/progress state management#2790
(OLD)Add better support for stateful view (UIButton) for image URL/progress state management#2790dreampiggy wants to merge 12 commits intoSDWebImage:masterfrom
Conversation
…o feature_set_image_state_api # Conflicts: # SDWebImage.xcodeproj/project.pbxproj # SDWebImage/UIView+WebCache.m
…iner, since it's more suitable and easy
Codecov Report
@@ Coverage Diff @@
## master #2790 +/- ##
=========================================
Coverage ? 82.18%
=========================================
Files ? 58
Lines ? 6428
Branches ? 0
=========================================
Hits ? 5283
Misses ? 1145
Partials ? 0
Continue to review full report at Codecov.
|
|
This pull request has been automatically marked as stale because it has not had |
|
This pull request has been automatically marked as stale because it has not had |
|
This sounds trivial for most users. (Who use UIButton). But the new added API will introduce more problems. The changes need more polish. I'll close it for now. Maybe we can do a totally refactory on v6.0.0 |
New Pull Request Checklist
I have read and understood the CONTRIBUTING guide
I have read the Documentation
I have searched for a similar pull request in the project and found none
I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
I have added the required tests to prove the fix/feature I am adding
I have updated the documentation (if necessary)
I have run the tests and they pass
I have run the lint and it passes (
pod lib lint)This merge request fixes / refers to the following issues: #2701
Pull Request Description
This is the implemntation based on #2701 draft. To solve our current implementation for stateful View Category method.
Reason
Stateful view means the
UIView/NSViewsubclass, which has multiple image instance to set, such asUIButton setImage:forState:orUIImageView.image/UIImage.highlightedImage.See #2701. Our image request loading model, use a
Operation Key, for stateful view to load the image. It's OK because for different state, it use a different operation key, no conflict.However, currtent these API in
UIView+WebCache, it's not good:What if I use UIButton with
sd_imageProgressto observe the progress changes ? Should it report the current state's progress, ornormalprogress ? or even background image's progress ? This is the root case of massive.Solution
To solve this problem, we follow the same design model as
Operation Keyon image request. Now, eachOperation Keywill bind all the state associated to this request. I introduce aSDWebImageStateContainerclass.Each opeartion key bind a state container, and state container can be extended to include all the things we want represent the state.
SDSetImageBlockand process your own logic. (like thatSDWebImageContext, but for top-level view category, not the network or cache system)