Support for a custom downloader and delegate to provide them #95
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, image downloading within the framework is handled by two static functions on
JTSSimpleImageDownloader
, called from theJTSImageViewController
without a means of override or customization. This PR refactors the existing downloading process to utilize two protocols:JTSImageViewControllerDownloadDelegate
- A delegate which provides instances of a downloaderJTSImageViewControllerDownloader
- A downloader which handles downloading the image and provides progress updatesThe changes are backwards compatible with 1.5.1, and everything continues to work exactly the same as it has out-of-the-box. This compatibility is accomplished by providing default implementations of the protocols which use the existing downloader when one is not supplied by the user. These protocols can be used to easily provide a custom downloader within the framework. For instance, in my current project I have implemented the delegate and downloader using Alamofire to call a REST API, passing custom headers for Authorization, etc., and also interfacing with a caching system that was already in use within the project.
You will likely not want to bring in the changed pod spec, for obvious reasons. Please let me know if there are any other issues with the PR.