Coder Social home page Coder Social logo

zerocc2014 / webasdkimagemanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ide/webasdkimagemanager

0.0 0.0 0.0 28 KB

Image downloader and cache for AsyncDisplayKit that uses SDWebImage

License: MIT License

Ruby 10.50% Objective-C 89.50%

webasdkimagemanager's Introduction

WebASDKImageManager

Version License Platform

Notice

AsyncDisplayKit now uses Pinterest's PINRemoteImage and PINCache if you include them as dependencies. They provide the functionality that WebASDKImageManager originally set to provide and manage memory more efficiently because they work more tightly with AsyncDisplayKit. Unless you specifically wish to use SDWebImage, you should use AsyncDisplayKit's default functionality.


An image downloader and cache for AsyncDisplayKit that uses SDWebImage. This is an implementation of ASImageDownloaderProtocol and ASImageCacheProtocol that is compatible with ASNetworkImageNode.

By default, ASNetworkImageNode does not cache images and does not coalesce network requests for the same image. SDWebImage does both of these. With WebASDKImageManager, you get the image downloading and caching optimizations of SDWebImage and the asynchronous layout and layer precompositing features of ASDK.

Installation

WebASDKImageManager is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "WebASDKImageManager"

Usage

The easiest way to use WebASDKImageManager is an initializer it provides in a category on ASNetworkImageNode.

ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] initWithWebImage];
// Setting the URL property will automatically access the memory and disk
// caches, and download and cache the image if necessary
imageNode.URL = imageURL;

Configuration

By default, image downloading and caching is handled by a shared WebASDKImageManager instance. You can get a reference to the shared manager by calling [SDWebASDKImageManager sharedManager]. Its webImageOptions property is the way to configure the downloading and caching behavior for all ASNetworkImageNode instances that used the shared manager.

SDWebASDKImageManager *defaultManager = [SDWebASDKImageManager sharedManager];
// No longer try to download images that were previously unavailable
defaultManager.webImageOptions &= ~SDWebImageRetryFailed;

Defaults

The default options are SDWebImageRetryFailed and SDWebImageContinueInBackground, which are generally what you want. See SDWebImage's SDWebImageOptions enum for all of the supported options.

Configuring a Single Image Node

Sometimes you may want to configure an image node differently than the default. You can do this by creating a new WebASDKImageManager that is configured to meet your needs.

SDWebImageManager *webImageManager = [SDWebImageManager sharedManager];
SDWebASDKImageManager *asyncImageManager =
  [[SDWebASDKImageManager alloc] initWithWebImageManager:webImageManager];
asyncImageManager.webImageOptions = SDWebImageRetryFailed | SDWebImageCacheMemoryOnly;

WebASDKImageManager conforms to ASImageDownloaderProtocol and ASImageCacheProtocol, so you can use your new manager to create a new image node.

ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] initWithCache:asyncImageManager 
                                                               downloader:asyncImageManager];

webasdkimagemanager's People

Contributors

dvlprliu avatar gauravmnit07 avatar ide avatar skensell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.