Skip to content

Support for a custom downloader and delegate to provide them #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

brucehappy
Copy link

Currently, image downloading within the framework is handled by two static functions on JTSSimpleImageDownloader, called from the JTSImageViewController without a means of override or customization. This PR refactors the existing downloading process to utilize two protocols:

  1. JTSImageViewControllerDownloadDelegate - A delegate which provides instances of a downloader
  2. JTSImageViewControllerDownloader - A downloader which handles downloading the image and provides progress updates

The 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.

…n. Refactored the existing code to implement the downloader and delegate protocols.
@markst
Copy link

markst commented Feb 17, 2016

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants