├── JHNewsDetail.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── a123.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── a123.xcuserdatad │ └── xcschemes │ ├── JHNewsDetail.xcscheme │ └── xcschememanagement.plist ├── JHNewsDetail.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── a123.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── JHNewsDetail ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Html │ ├── index.html │ ├── newsDetail.css │ └── newsDetail.js ├── Info.plist ├── Main │ └── ViewController.swift ├── Other │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── JHCommon.swift ├── PhotoBrower │ ├── Controller │ │ ├── DetailVC.swift │ │ └── DetailVC.xib │ ├── Layout │ │ └── DetailFlowLayout.swift │ ├── Model │ │ └── JHImgModel.swift │ └── View │ │ ├── DetailCell.swift │ │ └── DetailCell.xib └── ViewController.swift ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── a123.xcuserdatad │ │ └── xcschemes │ │ ├── Pods-JHNewsDetail.xcscheme │ │ ├── SDWebImage.xcscheme │ │ ├── WebViewJavascriptBridge.xcscheme │ │ └── xcschememanagement.plist ├── SDWebImage │ ├── LICENSE │ ├── README.md │ └── SDWebImage │ │ ├── NSData+ImageContentType.h │ │ ├── NSData+ImageContentType.m │ │ ├── SDImageCache.h │ │ ├── SDImageCache.m │ │ ├── SDWebImageCompat.h │ │ ├── SDWebImageCompat.m │ │ ├── SDWebImageDecoder.h │ │ ├── SDWebImageDecoder.m │ │ ├── SDWebImageDownloader.h │ │ ├── SDWebImageDownloader.m │ │ ├── SDWebImageDownloaderOperation.h │ │ ├── SDWebImageDownloaderOperation.m │ │ ├── SDWebImageManager.h │ │ ├── SDWebImageManager.m │ │ ├── SDWebImageOperation.h │ │ ├── SDWebImagePrefetcher.h │ │ ├── SDWebImagePrefetcher.m │ │ ├── UIButton+WebCache.h │ │ ├── UIButton+WebCache.m │ │ ├── UIImage+GIF.h │ │ ├── UIImage+GIF.m │ │ ├── UIImage+MultiFormat.h │ │ ├── UIImage+MultiFormat.m │ │ ├── UIImageView+HighlightedWebCache.h │ │ ├── UIImageView+HighlightedWebCache.m │ │ ├── UIImageView+WebCache.h │ │ ├── UIImageView+WebCache.m │ │ ├── UIView+WebCacheOperation.h │ │ └── UIView+WebCacheOperation.m ├── Target Support Files │ ├── Pods-JHNewsDetail │ │ ├── Info.plist │ │ ├── Pods-JHNewsDetail-acknowledgements.markdown │ │ ├── Pods-JHNewsDetail-acknowledgements.plist │ │ ├── Pods-JHNewsDetail-dummy.m │ │ ├── Pods-JHNewsDetail-frameworks.sh │ │ ├── Pods-JHNewsDetail-resources.sh │ │ ├── Pods-JHNewsDetail-umbrella.h │ │ ├── Pods-JHNewsDetail.debug.xcconfig │ │ ├── Pods-JHNewsDetail.modulemap │ │ └── Pods-JHNewsDetail.release.xcconfig │ ├── SDWebImage │ │ ├── Info.plist │ │ ├── SDWebImage-dummy.m │ │ ├── SDWebImage-prefix.pch │ │ ├── SDWebImage-umbrella.h │ │ ├── SDWebImage.modulemap │ │ └── SDWebImage.xcconfig │ └── WebViewJavascriptBridge │ │ ├── Info.plist │ │ ├── WebViewJavascriptBridge-dummy.m │ │ ├── WebViewJavascriptBridge-prefix.pch │ │ ├── WebViewJavascriptBridge-umbrella.h │ │ ├── WebViewJavascriptBridge.modulemap │ │ └── WebViewJavascriptBridge.xcconfig └── WebViewJavascriptBridge │ ├── LICENSE │ ├── README.md │ └── WebViewJavascriptBridge │ ├── WKWebViewJavascriptBridge.h │ ├── WKWebViewJavascriptBridge.m │ ├── WebViewJavascriptBridge.h │ ├── WebViewJavascriptBridge.m │ ├── WebViewJavascriptBridgeBase.h │ ├── WebViewJavascriptBridgeBase.m │ ├── WebViewJavascriptBridge_JS.h │ └── WebViewJavascriptBridge_JS.m └── README.md /JHNewsDetail.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JHNewsDetail.xcodeproj/project.xcworkspace/xcuserdata/a123.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuanzhihua/JHNewsDetail/5a8ae2c96a97f5e70ccc2c0c3f8e8601acadb0b9/JHNewsDetail.xcodeproj/project.xcworkspace/xcuserdata/a123.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /JHNewsDetail.xcodeproj/xcuserdata/a123.xcuserdatad/xcschemes/JHNewsDetail.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /JHNewsDetail.xcodeproj/xcuserdata/a123.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | JHNewsDetail.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 9D68ECCE1D9F84E300242289 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /JHNewsDetail.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JHNewsDetail.xcworkspace/xcuserdata/a123.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuanzhihua/JHNewsDetail/5a8ae2c96a97f5e70ccc2c0c3f8e8601acadb0b9/JHNewsDetail.xcworkspace/xcuserdata/a123.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /JHNewsDetail/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // JHNewsDetail 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /JHNewsDetail/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /JHNewsDetail/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JHNewsDetail/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /JHNewsDetail/Html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
中超造世界最囧保级怪:上来先夺冠 挣扎6年垮了
8 |
9 | 雷蒙侃体育 10 | 网易号 11 | 2016-09-28 14:16:10 12 |
13 |

  上轮联赛之后,本赛季的保级悬念基本揭开,不出意外,去年的黑马石家庄永昌将携手昔日的中超冠军长春亚泰降级……特别是亚泰,作为一支长期排名中下游的球队,在连续三个赛季死里逃生之后,如今恐再难脱身。放眼中国足球历史,像亚泰这样的保级专业户还有很多,他们为我们献上无数场惊心动魄的保级大战,不过常在河边走哪有不湿鞋,纵使是保级专业户,也有悲催降级落难之时。

14 |
15 | 16 |
17 |
18 |

  青岛中能

19 |

  青岛中能从前身青岛海牛1995年进入甲A后,仅仅在1996赛季降级过一次,不过也只用了一个赛季就重返顶级联赛。在甲A和中超联赛中,青岛队的绝对实力都不强,但是每年的征程基本上都很有规律,联赛开始阶段成绩都不错,但随着联赛的深入就开始掉链子,到末期都会有保级压力,但每次都化险为夷,成功保级,被称为“保级专业户”。

20 |
21 | 22 |
23 |
24 |

  特别值得一提的是1999年,当时青岛队上演了保级的逆袭神话:在联赛倒数第三轮打响前,青岛队仅积21分,一只脚已经踏入甲B赛场,结果他们背水一战,先后客场战胜上海申花,主场击败天津泰达和吉林敖东,豪取三连胜,出人意料地成功保级。在中国足球成立职业联赛以来,青岛队在顶级联赛中年年为保级而战,且年年都能保级成功,成功率高达95%,不过这种神奇在2014赛季被国安队终结,末轮只需要一分即可保级的青岛硬生生被格隆的头球绝杀,在工体告别中超,如今的他们位列中甲倒数第二,濒临降级,保级专业户的名号难保。

25 |
26 | 27 |
28 |
29 |

  深圳健力宝

30 |

  深足的保级能力之强,可以说是有传统的。早在甲A时代,深足就表现出超强的保级能力,98、99赛季的甲A联赛,深圳队都是在最后一轮联赛结束才保级成功,就是最佳佐证。而进入中超之后,深圳队在04年麻雀变凤凰,凭借朱广沪培养的一干球星,夺得中超元年冠军,似乎要从此脱离保级的命运。

31 |
32 | 33 |
34 |
35 |

  不过在随后一个赛季,深足内部出现问题,加上资金不足,深足依然难逃保级的命运,但却也藉此拉开了深足创造六年保级,六年成功奇迹的序幕。05赛季,深足以联赛第12保级成功;06赛季,联赛第11位;07赛季,第14位;08赛季,第12位;09赛季,第11位;10赛季,第12位,基本上,此前6个赛季,深足每每看似都无法完成保级任务了,却每每最后时刻惊险保级,堪称中外足球史上最会保级的球队。但这一规律没能在2011赛季延续,保级专业户在那年悲剧降级,他们还创造了一个尴尬纪录,成为首支夺得过中超冠军的降级队。

36 |

  辽宁宏运

37 |

  自从辽小虎在1999年一鸣惊人,勇夺联赛亚军之后,辽足的资金问题就暴露在阳光下,球队只能卖血生存。曲圣卿、张玉宁、李铁、李金羽等人相继出走,随之而来的就是成绩下滑,辽足只得被迫开启保级专业户的模式,连续几个赛季勉强保级。不过他们仍然没能逃过降级的命运,2009赛季辽足排名倒数第二降级。不过肇俊哲等人的坚守使得球队在第二年又重回中超联赛。

38 |
39 | 40 |
41 |
42 |

  之后依靠杨旭、于汉超等第二代辽小虎的出现,辽足进入一个辉煌时期,在2011年夺得联赛季军。但穷困难倒英雄汉,于汉超为救球队只得依靠转会救主,辽足重回保级专业户行列,连续四个赛季排名十名开外,上个赛季最为惊现,他们提前一轮才艰难保级成功,之后俱乐部举办的盛大的“海鲜盛筵”还引起了不小的争论。

43 |
44 | 45 |
46 |
47 |

  河南建业

48 |

  在2000年至2006年的七年中,中国足球经历了一系列的变化,2001年打入世界杯,2002年世界杯上糟糕演出,2003年底联赛改革、废甲AB级成立超级甲级联赛;而在这七年的时间里,河南建业渐渐成长成一支甲级劲旅,冲入中超。之后开启了他们错综复杂的中超之旅。2007年首个中超赛季,建业排名第12勉强保级,之后逐渐彰显黑马本色,专治各种不服的口号被叫响,2009赛季还在曾诚、赵鹏、肖智等人的率领下曾获得中超季军,2010赛季参加亚冠联赛。不过也是从那个赛季开始,建业开始逐渐平庸并沦落到保级的地步。

49 |
50 | 51 |
52 |
53 |

  2012赛季,建业位列联赛倒数第一 悲惨降级。之后俱乐部加强整顿,于次年重回中超。2014赛季最后一轮,建业队在北京工人体育场上演了队史上最为惊心动魄的《死里逃生》大片,在北京国安整场90分钟持续不断的狂轰滥炸中,全队上下众志成城,顽强地用血肉之躯保住了0-0的平局,力压阿尔滨1分奇迹般保级。上赛季,在贾秀全的调教下,稳守反击为主的建业排名一路飙升,最终名列第五,河南航海体育场也成为恒大、国安诸强难以逾越的大山,专治各种不服的建业再次回归。本赛季,积34分排名第8,不出意外已经成功保级,他们无愧是保级队中混得最好的球队。

54 |
55 | 56 |
57 |
58 |

特别声明:本文为网易自媒体平台“网易号”作者上传并发布,仅代表该作者观点。网易仅提供信息发布平台。

59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /JHNewsDetail/Html/newsDetail.css: -------------------------------------------------------------------------------- 1 | body{ 2 | /* background-color: gray;*/ 3 | } 4 | 5 | #title{ 6 | font-size:23px; 7 | margin-top:10px; 8 | font-weight:bolder; 9 | } 10 | 11 | #subTitle{ 12 | text-align:center; 13 | margin-top:10px; 14 | } 15 | 16 | .source{ 17 | color: orangered; 18 | font-size:13px; 19 | margin-right: 10px; 20 | } 21 | 22 | .articleTags{ 23 | color:skyblue; 24 | border:1px solid skyblue; 25 | font-size:13px; 26 | padding: 2px; 27 | border-radius:5px; 28 | margin-right: 10px; 29 | } 30 | 31 | .ptime{ 32 | color:gray; 33 | font-size:13px; 34 | } -------------------------------------------------------------------------------- /JHNewsDetail/Html/newsDetail.js: -------------------------------------------------------------------------------- 1 | window.onload = function(){ 2 | // 这段代码是固定的,必须要放到js中 3 | function setupWebViewJavascriptBridge(callback) { 4 | if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } 5 | if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } 6 | window.WVJBCallbacks = [callback]; 7 | var WVJBIframe = document.createElement('iframe'); 8 | WVJBIframe.style.display = 'none'; 9 | WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; 10 | document.documentElement.appendChild(WVJBIframe); 11 | setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) 12 | } 13 | 14 | // 与OC交互的所有JS方法都要在这里注册,才能让OC和JS之间相互调用 15 | setupWebViewJavascriptBridge(function(bridge) { 16 | 17 | var srcArr = []; 18 | 19 | var allImage = document.getElementsByTagName('img'); 20 | for(var i=0; i= 0.8) return; 51 | body.style.fontSize = 33 * data + 'px' 52 | }); 53 | 54 | 55 | 56 | }) 57 | 58 | }; -------------------------------------------------------------------------------- /JHNewsDetail/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /JHNewsDetail/Main/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // 网易新闻详情页 4 | // 5 | // Created by 123 on 16/9/30. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import WebViewJavascriptBridge 11 | 12 | class ViewController: UIViewController,UIWebViewDelegate { 13 | 14 | @IBOutlet weak var webView: UIWebView! 15 | @IBOutlet weak var bottomView: UIView! 16 | @IBOutlet weak var sw: UISwitch! 17 | @IBOutlet weak var leftTitle: UILabel! 18 | @IBOutlet weak var rightTitle: UIButton! 19 | 20 | var bridge: WebViewJavascriptBridge? 21 | var isLight = false 22 | weak var detailVC: DetailVC? 23 | 24 | 25 | override func viewDidLoad() { 26 | super.viewDidLoad() 27 | 28 | let indexPath = NSBundle.mainBundle().URLForResource("index", withExtension: "html") 29 | let request = NSURLRequest(URL: indexPath!) 30 | self.webView.loadRequest(request) 31 | 32 | self.bridge?.setWebViewDelegate(self) 33 | self.bridge = WebViewJavascriptBridge(forWebView: self.webView) 34 | WebViewJavascriptBridge.enableLogging() 35 | 36 | self.bridge?.registerHandler("openCameraLib", handler: { (data, responseCallback) -> Void in 37 | let srcArr = data["srcArr"] as! [[String: AnyObject]] 38 | var listMS = [JHImgModel]() 39 | for i in 0.. Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /JHNewsDetail/Other/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /JHNewsDetail/Other/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JHNewsDetail/Other/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /JHNewsDetail/Other/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | NSAppTransportSecurity 47 | 48 | NSAllowsArbitraryLoads 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /JHNewsDetail/Other/JHCommon.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JHCommon.swift 3 | // 网易新闻详情页 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// 屏幕大小 12 | let kScreenBounds = UIScreen.mainScreen().bounds 13 | 14 | /// 屏幕宽度 15 | let kScreenWidth: CGFloat = UIScreen.mainScreen().bounds.width 16 | 17 | /// 屏幕高度 18 | let kScreenHeight: CGFloat = UIScreen.mainScreen().bounds.height 19 | 20 | /// 全局的间距 21 | let kCommonMargin: CGFloat = 10 -------------------------------------------------------------------------------- /JHNewsDetail/PhotoBrower/Controller/DetailVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailVC.swift 3 | // 网易新闻详情页 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private let cellID = "detail" 12 | 13 | class DetailVC: UIViewController { 14 | 15 | var currentIndexPath: NSIndexPath { 16 | get { 17 | return collectionView.indexPathsForVisibleItems().first! 18 | } 19 | } 20 | 21 | 22 | lazy var collectionView: UICollectionView = { 23 | 24 | let frame = CGRect(x: 0, y: 0, width: kScreenWidth + kCommonMargin, height: kScreenHeight * 0.9) 25 | let collectionView = UICollectionView(frame: frame, collectionViewLayout: DetailFlowLayout()) 26 | collectionView.dataSource = self 27 | 28 | self.view.addSubview(collectionView) 29 | 30 | return collectionView 31 | 32 | }() 33 | 34 | /// 记录数据源 35 | var listMs: [JHImgModel] = [JHImgModel]() 36 | 37 | /// 记录需要滚动的行号 38 | var scrollToRow: Int = 0 39 | 40 | } 41 | 42 | // 主要的业务逻辑 43 | extension DetailVC { 44 | 45 | override func viewDidLoad() { 46 | super.viewDidLoad() 47 | 48 | /// 注册cell 49 | let nib = UINib(nibName: "DetailCell", bundle: nil) 50 | collectionView.registerNib(nib, forCellWithReuseIdentifier: cellID) 51 | 52 | let indexPath = NSIndexPath(forRow: scrollToRow, inSection: 0) 53 | 54 | // atScrollPosition: cell与collectionView的对齐方式 55 | collectionView.scrollToItemAtIndexPath(indexPath, atScrollPosition: .Left, animated: false) 56 | 57 | } 58 | 59 | /** 60 | 关闭方法 61 | */ 62 | @IBAction func close() { 63 | dismissViewControllerAnimated(true, completion: nil) 64 | } 65 | 66 | @IBAction func save() { 67 | 68 | 69 | let cell = collectionView.cellForItemAtIndexPath(currentIndexPath) as! DetailCell 70 | let image = cell.imageView.image 71 | 72 | UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil) 73 | 74 | } 75 | 76 | } 77 | 78 | 79 | // MARK: - 数据源方法 80 | extension DetailVC: UICollectionViewDataSource { 81 | 82 | func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 83 | return listMs.count 84 | } 85 | 86 | func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 87 | 88 | let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellID, forIndexPath: indexPath) as! DetailCell 89 | cell.listM = listMs[indexPath.row] 90 | return cell 91 | } 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /JHNewsDetail/PhotoBrower/Controller/DetailVC.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /JHNewsDetail/PhotoBrower/Layout/DetailFlowLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailFlowLayout.swift 3 | // 网易新闻详情页 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DetailFlowLayout: UICollectionViewFlowLayout { 12 | 13 | override func prepareLayout() { 14 | itemSize = CGSize(width: kScreenWidth, height: kScreenHeight * 0.9) 15 | scrollDirection = .Horizontal 16 | minimumLineSpacing = kCommonMargin 17 | collectionView?.pagingEnabled = true 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /JHNewsDetail/PhotoBrower/Model/JHImgModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JHImgModel.swift 3 | // 网易新闻详情页 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class JHImgModel: NSObject { 12 | // 图片的URL地址 13 | var pic_url: String? 14 | 15 | init(dic: [String: AnyObject]) { 16 | super.init() 17 | setValuesForKeysWithDictionary(dic) 18 | } 19 | 20 | override func setValue(value: AnyObject?, forUndefinedKey key: String) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JHNewsDetail/PhotoBrower/View/DetailCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailCell.swift 3 | // 网易新闻详情页 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SDWebImage 11 | 12 | class DetailCell: UICollectionViewCell { 13 | 14 | @IBOutlet weak var imageView: UIImageView! 15 | 16 | var listM: JHImgModel? { 17 | 18 | didSet { 19 | let url = NSURL(string: listM?.pic_url ?? "") 20 | imageView.contentMode = .ScaleAspectFit 21 | imageView.sd_setImageWithURL(url, placeholderImage: UIImage(named: "placehoder_picture")) 22 | } 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /JHNewsDetail/PhotoBrower/View/DetailCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /JHNewsDetail/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // JHNewsDetail 4 | // 5 | // Created by 123 on 16/10/1. 6 | // Copyright © 2016年 叶建华. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | platform :ios, "6.0" 3 | use_frameworks! 4 | 5 | pod 'WebViewJavascriptBridge', '~> 5.0' 6 | pod 'SDWebImage' 7 | 8 | target :JHNewsDetail 9 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDWebImage (3.7.6): 3 | - SDWebImage/Core (= 3.7.6) 4 | - SDWebImage/Core (3.7.6) 5 | - WebViewJavascriptBridge (5.0.5) 6 | 7 | DEPENDENCIES: 8 | - SDWebImage 9 | - WebViewJavascriptBridge (~> 5.0) 10 | 11 | SPEC CHECKSUMS: 12 | SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9 13 | WebViewJavascriptBridge: a4d502315f1b8d9a51cd6a9174147ed567ec3bc5 14 | 15 | PODFILE CHECKSUM: d35e219e13b6e5abdd34ed567e7727a7536fc44d 16 | 17 | COCOAPODS: 1.0.1 18 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SDWebImage (3.7.6): 3 | - SDWebImage/Core (= 3.7.6) 4 | - SDWebImage/Core (3.7.6) 5 | - WebViewJavascriptBridge (5.0.5) 6 | 7 | DEPENDENCIES: 8 | - SDWebImage 9 | - WebViewJavascriptBridge (~> 5.0) 10 | 11 | SPEC CHECKSUMS: 12 | SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9 13 | WebViewJavascriptBridge: a4d502315f1b8d9a51cd6a9174147ed567ec3bc5 14 | 15 | PODFILE CHECKSUM: d35e219e13b6e5abdd34ed567e7727a7536fc44d 16 | 17 | COCOAPODS: 1.0.1 18 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/a123.xcuserdatad/xcschemes/Pods-JHNewsDetail.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/a123.xcuserdatad/xcschemes/SDWebImage.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/a123.xcuserdatad/xcschemes/WebViewJavascriptBridge.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/a123.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-JHNewsDetail.xcscheme 8 | 9 | isShown 10 | 11 | 12 | SDWebImage.xcscheme 13 | 14 | isShown 15 | 16 | 17 | WebViewJavascriptBridge.xcscheme 18 | 19 | isShown 20 | 21 | 22 | 23 | SuppressBuildableAutocreation 24 | 25 | 15CE474B87C83B19CC7E9DA349419A4E 26 | 27 | primary 28 | 29 | 30 | 4192D3EB17A3C8F0CA6B08715BD44C4B 31 | 32 | primary 33 | 34 | 35 | 9D982728D21B2955192B74A56788023C 36 | 37 | primary 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Pods/SDWebImage/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | @interface NSData (ImageContentType) 9 | 10 | /** 11 | * Compute the content type for an image data 12 | * 13 | * @param data the input data 14 | * 15 | * @return the content type as string (i.e. image/jpeg, image/gif) 16 | */ 17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data; 18 | 19 | @end 20 | 21 | 22 | @interface NSData (ImageContentTypeDeprecated) 23 | 24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import "NSData+ImageContentType.h" 7 | 8 | 9 | @implementation NSData (ImageContentType) 10 | 11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data { 12 | uint8_t c; 13 | [data getBytes:&c length:1]; 14 | switch (c) { 15 | case 0xFF: 16 | return @"image/jpeg"; 17 | case 0x89: 18 | return @"image/png"; 19 | case 0x47: 20 | return @"image/gif"; 21 | case 0x49: 22 | case 0x4D: 23 | return @"image/tiff"; 24 | case 0x52: 25 | // R as RIFF for WEBP 26 | if ([data length] < 12) { 27 | return nil; 28 | } 29 | 30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 32 | return @"image/webp"; 33 | } 34 | 35 | return nil; 36 | } 37 | return nil; 38 | } 39 | 40 | @end 41 | 42 | 43 | @implementation NSData (ImageContentTypeDeprecated) 44 | 45 | + (NSString *)contentTypeForImageData:(NSData *)data { 46 | return [self sd_contentTypeForImageData:data]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDImageCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | typedef NS_ENUM(NSInteger, SDImageCacheType) { 13 | /** 14 | * The image wasn't available the SDWebImage caches, but was downloaded from the web. 15 | */ 16 | SDImageCacheTypeNone, 17 | /** 18 | * The image was obtained from the disk cache. 19 | */ 20 | SDImageCacheTypeDisk, 21 | /** 22 | * The image was obtained from the memory cache. 23 | */ 24 | SDImageCacheTypeMemory 25 | }; 26 | 27 | typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); 28 | 29 | typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); 30 | 31 | typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); 32 | 33 | /** 34 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed 35 | * asynchronous so it doesn’t add unnecessary latency to the UI. 36 | */ 37 | @interface SDImageCache : NSObject 38 | 39 | /** 40 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 41 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 42 | */ 43 | @property (assign, nonatomic) BOOL shouldDecompressImages; 44 | 45 | /** 46 | * disable iCloud backup [defaults to YES] 47 | */ 48 | @property (assign, nonatomic) BOOL shouldDisableiCloud; 49 | 50 | /** 51 | * use memory cache [defaults to YES] 52 | */ 53 | @property (assign, nonatomic) BOOL shouldCacheImagesInMemory; 54 | 55 | /** 56 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. 57 | */ 58 | @property (assign, nonatomic) NSUInteger maxMemoryCost; 59 | 60 | /** 61 | * The maximum number of objects the cache should hold. 62 | */ 63 | @property (assign, nonatomic) NSUInteger maxMemoryCountLimit; 64 | 65 | /** 66 | * The maximum length of time to keep an image in the cache, in seconds 67 | */ 68 | @property (assign, nonatomic) NSInteger maxCacheAge; 69 | 70 | /** 71 | * The maximum size of the cache, in bytes. 72 | */ 73 | @property (assign, nonatomic) NSUInteger maxCacheSize; 74 | 75 | /** 76 | * Returns global shared cache instance 77 | * 78 | * @return SDImageCache global instance 79 | */ 80 | + (SDImageCache *)sharedImageCache; 81 | 82 | /** 83 | * Init a new cache store with a specific namespace 84 | * 85 | * @param ns The namespace to use for this cache store 86 | */ 87 | - (id)initWithNamespace:(NSString *)ns; 88 | 89 | /** 90 | * Init a new cache store with a specific namespace and directory 91 | * 92 | * @param ns The namespace to use for this cache store 93 | * @param directory Directory to cache disk images in 94 | */ 95 | - (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory; 96 | 97 | -(NSString *)makeDiskCachePath:(NSString*)fullNamespace; 98 | 99 | /** 100 | * Add a read-only cache path to search for images pre-cached by SDImageCache 101 | * Useful if you want to bundle pre-loaded images with your app 102 | * 103 | * @param path The path to use for this read-only cache path 104 | */ 105 | - (void)addReadOnlyCachePath:(NSString *)path; 106 | 107 | /** 108 | * Store an image into memory and disk cache at the given key. 109 | * 110 | * @param image The image to store 111 | * @param key The unique image cache key, usually it's image absolute URL 112 | */ 113 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key; 114 | 115 | /** 116 | * Store an image into memory and optionally disk cache at the given key. 117 | * 118 | * @param image The image to store 119 | * @param key The unique image cache key, usually it's image absolute URL 120 | * @param toDisk Store the image to disk cache if YES 121 | */ 122 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; 123 | 124 | /** 125 | * Store an image into memory and optionally disk cache at the given key. 126 | * 127 | * @param image The image to store 128 | * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage 129 | * @param imageData The image data as returned by the server, this representation will be used for disk storage 130 | * instead of converting the given image object into a storable/compressed image format in order 131 | * to save quality and CPU 132 | * @param key The unique image cache key, usually it's image absolute URL 133 | * @param toDisk Store the image to disk cache if YES 134 | */ 135 | - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; 136 | 137 | /** 138 | * Store image NSData into disk cache at the given key. 139 | * 140 | * @param imageData The image data to store 141 | * @param key The unique image cache key, usually it's image absolute URL 142 | */ 143 | - (void)storeImageDataToDisk:(NSData *)imageData forKey:(NSString *)key; 144 | 145 | /** 146 | * Query the disk cache asynchronously. 147 | * 148 | * @param key The unique key used to store the wanted image 149 | */ 150 | - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock; 151 | 152 | /** 153 | * Query the memory cache synchronously. 154 | * 155 | * @param key The unique key used to store the wanted image 156 | */ 157 | - (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; 158 | 159 | /** 160 | * Query the disk cache synchronously after checking the memory cache. 161 | * 162 | * @param key The unique key used to store the wanted image 163 | */ 164 | - (UIImage *)imageFromDiskCacheForKey:(NSString *)key; 165 | 166 | /** 167 | * Remove the image from memory and disk cache synchronously 168 | * 169 | * @param key The unique image cache key 170 | */ 171 | - (void)removeImageForKey:(NSString *)key; 172 | 173 | 174 | /** 175 | * Remove the image from memory and disk cache asynchronously 176 | * 177 | * @param key The unique image cache key 178 | * @param completion An block that should be executed after the image has been removed (optional) 179 | */ 180 | - (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion; 181 | 182 | /** 183 | * Remove the image from memory and optionally disk cache asynchronously 184 | * 185 | * @param key The unique image cache key 186 | * @param fromDisk Also remove cache entry from disk if YES 187 | */ 188 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; 189 | 190 | /** 191 | * Remove the image from memory and optionally disk cache asynchronously 192 | * 193 | * @param key The unique image cache key 194 | * @param fromDisk Also remove cache entry from disk if YES 195 | * @param completion An block that should be executed after the image has been removed (optional) 196 | */ 197 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion; 198 | 199 | /** 200 | * Clear all memory cached images 201 | */ 202 | - (void)clearMemory; 203 | 204 | /** 205 | * Clear all disk cached images. Non-blocking method - returns immediately. 206 | * @param completion An block that should be executed after cache expiration completes (optional) 207 | */ 208 | - (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion; 209 | 210 | /** 211 | * Clear all disk cached images 212 | * @see clearDiskOnCompletion: 213 | */ 214 | - (void)clearDisk; 215 | 216 | /** 217 | * Remove all expired cached image from disk. Non-blocking method - returns immediately. 218 | * @param completionBlock An block that should be executed after cache expiration completes (optional) 219 | */ 220 | - (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock; 221 | 222 | /** 223 | * Remove all expired cached image from disk 224 | * @see cleanDiskWithCompletionBlock: 225 | */ 226 | - (void)cleanDisk; 227 | 228 | /** 229 | * Get the size used by the disk cache 230 | */ 231 | - (NSUInteger)getSize; 232 | 233 | /** 234 | * Get the number of images in the disk cache 235 | */ 236 | - (NSUInteger)getDiskCount; 237 | 238 | /** 239 | * Asynchronously calculate the disk cache's size. 240 | */ 241 | - (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock; 242 | 243 | /** 244 | * Async check if image exists in disk cache already (does not load the image) 245 | * 246 | * @param key the key describing the url 247 | * @param completionBlock the block to be executed when the check is done. 248 | * @note the completion block will be always executed on the main queue 249 | */ 250 | - (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 251 | 252 | /** 253 | * Check if image exists in disk cache already (does not load the image) 254 | * 255 | * @param key the key describing the url 256 | * 257 | * @return YES if an image exists for the given key 258 | */ 259 | - (BOOL)diskImageExistsWithKey:(NSString *)key; 260 | 261 | /** 262 | * Get the cache path for a certain key (needs the cache path root folder) 263 | * 264 | * @param key the key (can be obtained from url using cacheKeyForURL) 265 | * @param path the cache path root folder 266 | * 267 | * @return the cache path 268 | */ 269 | - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; 270 | 271 | /** 272 | * Get the default cache path for a certain key 273 | * 274 | * @param key the key (can be obtained from url using cacheKeyForURL) 275 | * 276 | * @return the default cache path 277 | */ 278 | - (NSString *)defaultCachePathForKey:(NSString *)key; 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | 12 | #ifdef __OBJC_GC__ 13 | #error SDWebImage does not support Objective-C Garbage Collection 14 | #endif 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 17 | #error SDWebImage doesn't support Deployment Target version < 5.0 18 | #endif 19 | 20 | #if !TARGET_OS_IPHONE 21 | #import 22 | #ifndef UIImage 23 | #define UIImage NSImage 24 | #endif 25 | #ifndef UIImageView 26 | #define UIImageView NSImageView 27 | #endif 28 | #else 29 | 30 | #import 31 | 32 | #endif 33 | 34 | #ifndef NS_ENUM 35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 36 | #endif 37 | 38 | #ifndef NS_OPTIONS 39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 40 | #endif 41 | 42 | #if OS_OBJECT_USE_OBJC 43 | #undef SDDispatchQueueRelease 44 | #undef SDDispatchQueueSetterSementics 45 | #define SDDispatchQueueRelease(q) 46 | #define SDDispatchQueueSetterSementics strong 47 | #else 48 | #undef SDDispatchQueueRelease 49 | #undef SDDispatchQueueSetterSementics 50 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 51 | #define SDDispatchQueueSetterSementics assign 52 | #endif 53 | 54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 55 | 56 | typedef void(^SDWebImageNoParamsBlock)(); 57 | 58 | extern NSString *const SDWebImageErrorDomain; 59 | 60 | #define dispatch_main_sync_safe(block)\ 61 | if ([NSThread isMainThread]) {\ 62 | block();\ 63 | } else {\ 64 | dispatch_sync(dispatch_get_main_queue(), block);\ 65 | } 66 | 67 | #define dispatch_main_async_safe(block)\ 68 | if ([NSThread isMainThread]) {\ 69 | block();\ 70 | } else {\ 71 | dispatch_async(dispatch_get_main_queue(), block);\ 72 | } 73 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageCompat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 11/12/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if !__has_feature(objc_arc) 12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag 13 | #endif 14 | 15 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { 16 | if (!image) { 17 | return nil; 18 | } 19 | 20 | if ([image.images count] > 0) { 21 | NSMutableArray *scaledImages = [NSMutableArray array]; 22 | 23 | for (UIImage *tempImage in image.images) { 24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 25 | } 26 | 27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 28 | } 29 | else { 30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 31 | CGFloat scale = 1; 32 | if (key.length >= 8) { 33 | NSRange range = [key rangeOfString:@"@2x."]; 34 | if (range.location != NSNotFound) { 35 | scale = 2.0; 36 | } 37 | 38 | range = [key rangeOfString:@"@3x."]; 39 | if (range.location != NSNotFound) { 40 | scale = 3.0; 41 | } 42 | } 43 | 44 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 45 | image = scaledImage; 46 | } 47 | return image; 48 | } 49 | } 50 | 51 | NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 52 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import 12 | #import "SDWebImageCompat.h" 13 | 14 | @interface UIImage (ForceDecode) 15 | 16 | + (UIImage *)decodedImageWithImage:(UIImage *)image; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import "SDWebImageDecoder.h" 12 | 13 | @implementation UIImage (ForceDecode) 14 | 15 | + (UIImage *)decodedImageWithImage:(UIImage *)image { 16 | // while downloading huge amount of images 17 | // autorelease the bitmap context 18 | // and all vars to help system to free memory 19 | // when there are memory warning. 20 | // on iOS7, do not forget to call 21 | // [[SDImageCache sharedImageCache] clearMemory]; 22 | 23 | if (image == nil) { // Prevent "CGBitmapContextCreateImage: invalid context 0x0" error 24 | return nil; 25 | } 26 | 27 | @autoreleasepool{ 28 | // do not decode animated images 29 | if (image.images != nil) { 30 | return image; 31 | } 32 | 33 | CGImageRef imageRef = image.CGImage; 34 | 35 | CGImageAlphaInfo alpha = CGImageGetAlphaInfo(imageRef); 36 | BOOL anyAlpha = (alpha == kCGImageAlphaFirst || 37 | alpha == kCGImageAlphaLast || 38 | alpha == kCGImageAlphaPremultipliedFirst || 39 | alpha == kCGImageAlphaPremultipliedLast); 40 | if (anyAlpha) { 41 | return image; 42 | } 43 | 44 | // current 45 | CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(CGImageGetColorSpace(imageRef)); 46 | CGColorSpaceRef colorspaceRef = CGImageGetColorSpace(imageRef); 47 | 48 | BOOL unsupportedColorSpace = (imageColorSpaceModel == kCGColorSpaceModelUnknown || 49 | imageColorSpaceModel == kCGColorSpaceModelMonochrome || 50 | imageColorSpaceModel == kCGColorSpaceModelCMYK || 51 | imageColorSpaceModel == kCGColorSpaceModelIndexed); 52 | if (unsupportedColorSpace) { 53 | colorspaceRef = CGColorSpaceCreateDeviceRGB(); 54 | } 55 | 56 | size_t width = CGImageGetWidth(imageRef); 57 | size_t height = CGImageGetHeight(imageRef); 58 | NSUInteger bytesPerPixel = 4; 59 | NSUInteger bytesPerRow = bytesPerPixel * width; 60 | NSUInteger bitsPerComponent = 8; 61 | 62 | 63 | // kCGImageAlphaNone is not supported in CGBitmapContextCreate. 64 | // Since the original image here has no alpha info, use kCGImageAlphaNoneSkipLast 65 | // to create bitmap graphics contexts without alpha info. 66 | CGContextRef context = CGBitmapContextCreate(NULL, 67 | width, 68 | height, 69 | bitsPerComponent, 70 | bytesPerRow, 71 | colorspaceRef, 72 | kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); 73 | 74 | // Draw the image into the context and retrieve the new bitmap image without alpha 75 | CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); 76 | CGImageRef imageRefWithoutAlpha = CGBitmapContextCreateImage(context); 77 | UIImage *imageWithoutAlpha = [UIImage imageWithCGImage:imageRefWithoutAlpha 78 | scale:image.scale 79 | orientation:image.imageOrientation]; 80 | 81 | if (unsupportedColorSpace) { 82 | CGColorSpaceRelease(colorspaceRef); 83 | } 84 | 85 | CGContextRelease(context); 86 | CGImageRelease(imageRefWithoutAlpha); 87 | 88 | return imageWithoutAlpha; 89 | } 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { 14 | SDWebImageDownloaderLowPriority = 1 << 0, 15 | SDWebImageDownloaderProgressiveDownload = 1 << 1, 16 | 17 | /** 18 | * By default, request prevent the use of NSURLCache. With this flag, NSURLCache 19 | * is used with default policies. 20 | */ 21 | SDWebImageDownloaderUseNSURLCache = 1 << 2, 22 | 23 | /** 24 | * Call completion block with nil image/imageData if the image was read from NSURLCache 25 | * (to be combined with `SDWebImageDownloaderUseNSURLCache`). 26 | */ 27 | 28 | SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, 29 | /** 30 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 31 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 32 | */ 33 | 34 | SDWebImageDownloaderContinueInBackground = 1 << 4, 35 | 36 | /** 37 | * Handles cookies stored in NSHTTPCookieStore by setting 38 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 39 | */ 40 | SDWebImageDownloaderHandleCookies = 1 << 5, 41 | 42 | /** 43 | * Enable to allow untrusted SSL certificates. 44 | * Useful for testing purposes. Use with caution in production. 45 | */ 46 | SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, 47 | 48 | /** 49 | * Put the image in the high priority queue. 50 | */ 51 | SDWebImageDownloaderHighPriority = 1 << 7, 52 | }; 53 | 54 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { 55 | /** 56 | * Default value. All download operations will execute in queue style (first-in-first-out). 57 | */ 58 | SDWebImageDownloaderFIFOExecutionOrder, 59 | 60 | /** 61 | * All download operations will execute in stack style (last-in-first-out). 62 | */ 63 | SDWebImageDownloaderLIFOExecutionOrder 64 | }; 65 | 66 | extern NSString *const SDWebImageDownloadStartNotification; 67 | extern NSString *const SDWebImageDownloadStopNotification; 68 | 69 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); 70 | 71 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); 72 | 73 | typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers); 74 | 75 | /** 76 | * Asynchronous downloader dedicated and optimized for image loading. 77 | */ 78 | @interface SDWebImageDownloader : NSObject 79 | 80 | /** 81 | * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. 82 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. 83 | */ 84 | @property (assign, nonatomic) BOOL shouldDecompressImages; 85 | 86 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads; 87 | 88 | /** 89 | * Shows the current amount of downloads that still need to be downloaded 90 | */ 91 | @property (readonly, nonatomic) NSUInteger currentDownloadCount; 92 | 93 | 94 | /** 95 | * The timeout value (in seconds) for the download operation. Default: 15.0. 96 | */ 97 | @property (assign, nonatomic) NSTimeInterval downloadTimeout; 98 | 99 | 100 | /** 101 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. 102 | */ 103 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; 104 | 105 | /** 106 | * Singleton method, returns the shared instance 107 | * 108 | * @return global shared instance of downloader class 109 | */ 110 | + (SDWebImageDownloader *)sharedDownloader; 111 | 112 | /** 113 | * Set the default URL credential to be set for request operations. 114 | */ 115 | @property (strong, nonatomic) NSURLCredential *urlCredential; 116 | 117 | /** 118 | * Set username 119 | */ 120 | @property (strong, nonatomic) NSString *username; 121 | 122 | /** 123 | * Set password 124 | */ 125 | @property (strong, nonatomic) NSString *password; 126 | 127 | /** 128 | * Set filter to pick headers for downloading image HTTP request. 129 | * 130 | * This block will be invoked for each downloading image request, returned 131 | * NSDictionary will be used as headers in corresponding HTTP request. 132 | */ 133 | @property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter; 134 | 135 | /** 136 | * Set a value for a HTTP header to be appended to each download HTTP request. 137 | * 138 | * @param value The value for the header field. Use `nil` value to remove the header. 139 | * @param field The name of the header field to set. 140 | */ 141 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; 142 | 143 | /** 144 | * Returns the value of the specified HTTP header field. 145 | * 146 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field. 147 | */ 148 | - (NSString *)valueForHTTPHeaderField:(NSString *)field; 149 | 150 | /** 151 | * Sets a subclass of `SDWebImageDownloaderOperation` as the default 152 | * `NSOperation` to be used each time SDWebImage constructs a request 153 | * operation to download an image. 154 | * 155 | * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set 156 | * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. 157 | */ 158 | - (void)setOperationClass:(Class)operationClass; 159 | 160 | /** 161 | * Creates a SDWebImageDownloader async downloader instance with a given URL 162 | * 163 | * The delegate will be informed when the image is finish downloaded or an error has happen. 164 | * 165 | * @see SDWebImageDownloaderDelegate 166 | * 167 | * @param url The URL to the image to download 168 | * @param options The options to be used for this download 169 | * @param progressBlock A block called repeatedly while the image is downloading 170 | * @param completedBlock A block called once the download is completed. 171 | * If the download succeeded, the image parameter is set, in case of error, 172 | * error parameter is set with the error. The last parameter is always YES 173 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the 174 | * SDWebImageDownloaderProgressiveDownload option, this block is called 175 | * repeatedly with the partial image object and the finished argument set to NO 176 | * before to be called a last time with the full image and finished argument 177 | * set to YES. In case of error, the finished argument is always YES. 178 | * 179 | * @return A cancellable SDWebImageOperation 180 | */ 181 | - (id )downloadImageWithURL:(NSURL *)url 182 | options:(SDWebImageDownloaderOptions)options 183 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 184 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock; 185 | 186 | /** 187 | * Sets the download queue suspension state 188 | */ 189 | - (void)setSuspended:(BOOL)suspended; 190 | 191 | /** 192 | * Cancels all download operations in the queue 193 | */ 194 | - (void)cancelAllDownloads; 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageDownloader.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | extern NSString *const SDWebImageDownloadStartNotification; 14 | extern NSString *const SDWebImageDownloadReceiveResponseNotification; 15 | extern NSString *const SDWebImageDownloadStopNotification; 16 | extern NSString *const SDWebImageDownloadFinishNotification; 17 | 18 | @interface SDWebImageDownloaderOperation : NSOperation 19 | 20 | /** 21 | * The request used by the operation's connection. 22 | */ 23 | @property (strong, nonatomic, readonly) NSURLRequest *request; 24 | 25 | 26 | @property (assign, nonatomic) BOOL shouldDecompressImages; 27 | 28 | /** 29 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. 30 | * 31 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. 32 | */ 33 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage; 34 | 35 | /** 36 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 37 | * 38 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 39 | */ 40 | @property (nonatomic, strong) NSURLCredential *credential; 41 | 42 | /** 43 | * The SDWebImageDownloaderOptions for the receiver. 44 | */ 45 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 46 | 47 | /** 48 | * The expected size of data. 49 | */ 50 | @property (assign, nonatomic) NSInteger expectedSize; 51 | 52 | /** 53 | * The response returned by the operation's connection. 54 | */ 55 | @property (strong, nonatomic) NSURLResponse *response; 56 | 57 | /** 58 | * Initializes a `SDWebImageDownloaderOperation` object 59 | * 60 | * @see SDWebImageDownloaderOperation 61 | * 62 | * @param request the URL request 63 | * @param options downloader options 64 | * @param progressBlock the block executed when a new chunk of data arrives. 65 | * @note the progress block is executed on a background queue 66 | * @param completedBlock the block executed when the download is done. 67 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue 68 | * @param cancelBlock the block executed if the download (operation) is cancelled 69 | * 70 | * @return the initialized instance 71 | */ 72 | - (id)initWithRequest:(NSURLRequest *)request 73 | options:(SDWebImageDownloaderOptions)options 74 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 75 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock 76 | cancelled:(SDWebImageNoParamsBlock)cancelBlock; 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageOperation.h" 11 | #import "SDWebImageDownloader.h" 12 | #import "SDImageCache.h" 13 | 14 | typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { 15 | /** 16 | * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. 17 | * This flag disable this blacklisting. 18 | */ 19 | SDWebImageRetryFailed = 1 << 0, 20 | 21 | /** 22 | * By default, image downloads are started during UI interactions, this flags disable this feature, 23 | * leading to delayed download on UIScrollView deceleration for instance. 24 | */ 25 | SDWebImageLowPriority = 1 << 1, 26 | 27 | /** 28 | * This flag disables on-disk caching 29 | */ 30 | SDWebImageCacheMemoryOnly = 1 << 2, 31 | 32 | /** 33 | * This flag enables progressive download, the image is displayed progressively during download as a browser would do. 34 | * By default, the image is only displayed once completely downloaded. 35 | */ 36 | SDWebImageProgressiveDownload = 1 << 3, 37 | 38 | /** 39 | * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. 40 | * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. 41 | * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. 42 | * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. 43 | * 44 | * Use this flag only if you can't make your URLs static with embedded cache busting parameter. 45 | */ 46 | SDWebImageRefreshCached = 1 << 4, 47 | 48 | /** 49 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 50 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 51 | */ 52 | SDWebImageContinueInBackground = 1 << 5, 53 | 54 | /** 55 | * Handles cookies stored in NSHTTPCookieStore by setting 56 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 57 | */ 58 | SDWebImageHandleCookies = 1 << 6, 59 | 60 | /** 61 | * Enable to allow untrusted SSL certificates. 62 | * Useful for testing purposes. Use with caution in production. 63 | */ 64 | SDWebImageAllowInvalidSSLCertificates = 1 << 7, 65 | 66 | /** 67 | * By default, images are loaded in the order in which they were queued. This flag moves them to 68 | * the front of the queue. 69 | */ 70 | SDWebImageHighPriority = 1 << 8, 71 | 72 | /** 73 | * By default, placeholder images are loaded while the image is loading. This flag will delay the loading 74 | * of the placeholder image until after the image has finished loading. 75 | */ 76 | SDWebImageDelayPlaceholder = 1 << 9, 77 | 78 | /** 79 | * We usually don't call transformDownloadedImage delegate method on animated images, 80 | * as most transformation code would mangle it. 81 | * Use this flag to transform them anyway. 82 | */ 83 | SDWebImageTransformAnimatedImage = 1 << 10, 84 | 85 | /** 86 | * By default, image is added to the imageView after download. But in some cases, we want to 87 | * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance) 88 | * Use this flag if you want to manually set the image in the completion when success 89 | */ 90 | SDWebImageAvoidAutoSetImage = 1 << 11 91 | }; 92 | 93 | typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); 94 | 95 | typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL); 96 | 97 | typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url); 98 | 99 | 100 | @class SDWebImageManager; 101 | 102 | @protocol SDWebImageManagerDelegate 103 | 104 | @optional 105 | 106 | /** 107 | * Controls which image should be downloaded when the image is not found in the cache. 108 | * 109 | * @param imageManager The current `SDWebImageManager` 110 | * @param imageURL The url of the image to be downloaded 111 | * 112 | * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. 113 | */ 114 | - (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; 115 | 116 | /** 117 | * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. 118 | * NOTE: This method is called from a global queue in order to not to block the main thread. 119 | * 120 | * @param imageManager The current `SDWebImageManager` 121 | * @param image The image to transform 122 | * @param imageURL The url of the image to transform 123 | * 124 | * @return The transformed image object. 125 | */ 126 | - (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; 127 | 128 | @end 129 | 130 | /** 131 | * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. 132 | * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). 133 | * You can use this class directly to benefit from web image downloading with caching in another context than 134 | * a UIView. 135 | * 136 | * Here is a simple example of how to use SDWebImageManager: 137 | * 138 | * @code 139 | 140 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; 141 | [manager downloadImageWithURL:imageURL 142 | options:0 143 | progress:nil 144 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 145 | if (image) { 146 | // do something with image 147 | } 148 | }]; 149 | 150 | * @endcode 151 | */ 152 | @interface SDWebImageManager : NSObject 153 | 154 | @property (weak, nonatomic) id delegate; 155 | 156 | @property (strong, nonatomic, readonly) SDImageCache *imageCache; 157 | @property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; 158 | 159 | /** 160 | * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can 161 | * be used to remove dynamic part of an image URL. 162 | * 163 | * The following example sets a filter in the application delegate that will remove any query-string from the 164 | * URL before to use it as a cache key: 165 | * 166 | * @code 167 | 168 | [[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { 169 | url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; 170 | return [url absoluteString]; 171 | }]; 172 | 173 | * @endcode 174 | */ 175 | @property (nonatomic, copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter; 176 | 177 | /** 178 | * Returns global SDWebImageManager instance. 179 | * 180 | * @return SDWebImageManager shared instance 181 | */ 182 | + (SDWebImageManager *)sharedManager; 183 | 184 | /** 185 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 186 | * 187 | * @param url The URL to the image 188 | * @param options A mask to specify options to use for this request 189 | * @param progressBlock A block called while image is downloading 190 | * @param completedBlock A block called when operation has been completed. 191 | * 192 | * This parameter is required. 193 | * 194 | * This block has no return value and takes the requested UIImage as first parameter. 195 | * In case of error the image parameter is nil and the second parameter may contain an NSError. 196 | * 197 | * The third parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache 198 | * or from the memory cache or from the network. 199 | * 200 | * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is 201 | * downloading. This block is thus called repeatedly with a partial image. When image is fully downloaded, the 202 | * block is called a last time with the full image and the last parameter set to YES. 203 | * 204 | * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation 205 | */ 206 | - (id )downloadImageWithURL:(NSURL *)url 207 | options:(SDWebImageOptions)options 208 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 209 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock; 210 | 211 | /** 212 | * Saves image to cache for given URL 213 | * 214 | * @param image The image to cache 215 | * @param url The URL to the image 216 | * 217 | */ 218 | 219 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; 220 | 221 | /** 222 | * Cancel all current operations 223 | */ 224 | - (void)cancelAll; 225 | 226 | /** 227 | * Check one or more operations running 228 | */ 229 | - (BOOL)isRunning; 230 | 231 | /** 232 | * Check if image has already been cached 233 | * 234 | * @param url image url 235 | * 236 | * @return if the image was already cached 237 | */ 238 | - (BOOL)cachedImageExistsForURL:(NSURL *)url; 239 | 240 | /** 241 | * Check if image has already been cached on disk only 242 | * 243 | * @param url image url 244 | * 245 | * @return if the image was already cached (disk only) 246 | */ 247 | - (BOOL)diskImageExistsForURL:(NSURL *)url; 248 | 249 | /** 250 | * Async check if image has already been cached 251 | * 252 | * @param url image url 253 | * @param completionBlock the block to be executed when the check is finished 254 | * 255 | * @note the completion block is always executed on the main queue 256 | */ 257 | - (void)cachedImageExistsForURL:(NSURL *)url 258 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 259 | 260 | /** 261 | * Async check if image has already been cached on disk only 262 | * 263 | * @param url image url 264 | * @param completionBlock the block to be executed when the check is finished 265 | * 266 | * @note the completion block is always executed on the main queue 267 | */ 268 | - (void)diskImageExistsForURL:(NSURL *)url 269 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; 270 | 271 | 272 | /** 273 | *Return the cache key for a given URL 274 | */ 275 | - (NSString *)cacheKeyForURL:(NSURL *)url; 276 | 277 | @end 278 | 279 | 280 | #pragma mark - Deprecated 281 | 282 | typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`"); 283 | typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`"); 284 | 285 | 286 | @interface SDWebImageManager (Deprecated) 287 | 288 | /** 289 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 290 | * 291 | * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:` 292 | */ 293 | - (id )downloadWithURL:(NSURL *)url 294 | options:(SDWebImageOptions)options 295 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 296 | completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`"); 297 | 298 | @end 299 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | 11 | @protocol SDWebImageOperation 12 | 13 | - (void)cancel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @class SDWebImagePrefetcher; 13 | 14 | @protocol SDWebImagePrefetcherDelegate 15 | 16 | @optional 17 | 18 | /** 19 | * Called when an image was prefetched. 20 | * 21 | * @param imagePrefetcher The current image prefetcher 22 | * @param imageURL The image url that was prefetched 23 | * @param finishedCount The total number of images that were prefetched (successful or not) 24 | * @param totalCount The total number of images that were to be prefetched 25 | */ 26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 27 | 28 | /** 29 | * Called when all images are prefetched. 30 | * @param imagePrefetcher The current image prefetcher 31 | * @param totalCount The total number of images that were prefetched (whether successful or not) 32 | * @param skippedCount The total number of images that were skipped 33 | */ 34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 35 | 36 | @end 37 | 38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); 39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); 40 | 41 | /** 42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. 43 | */ 44 | @interface SDWebImagePrefetcher : NSObject 45 | 46 | /** 47 | * The web image manager 48 | */ 49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager; 50 | 51 | /** 52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3. 53 | */ 54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads; 55 | 56 | /** 57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. 58 | */ 59 | @property (nonatomic, assign) SDWebImageOptions options; 60 | 61 | /** 62 | * Queue options for Prefetcher. Defaults to Main Queue. 63 | */ 64 | @property (nonatomic, assign) dispatch_queue_t prefetcherQueue; 65 | 66 | @property (weak, nonatomic) id delegate; 67 | 68 | /** 69 | * Return the global image prefetcher instance. 70 | */ 71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; 72 | 73 | /** 74 | * Allows you to instantiate a prefetcher with any arbitrary image manager. 75 | */ 76 | - (id)initWithImageManager:(SDWebImageManager *)manager; 77 | 78 | /** 79 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 80 | * currently one image is downloaded at a time, 81 | * and skips images for failed downloads and proceed to the next image in the list 82 | * 83 | * @param urls list of URLs to prefetch 84 | */ 85 | - (void)prefetchURLs:(NSArray *)urls; 86 | 87 | /** 88 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 89 | * currently one image is downloaded at a time, 90 | * and skips images for failed downloads and proceed to the next image in the list 91 | * 92 | * @param urls list of URLs to prefetch 93 | * @param progressBlock block to be called when progress updates; 94 | * first parameter is the number of completed (successful or not) requests, 95 | * second parameter is the total number of images originally requested to be prefetched 96 | * @param completionBlock block to be called when prefetching is completed 97 | * first param is the number of completed (successful or not) requests, 98 | * second parameter is the number of skipped requests 99 | */ 100 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; 101 | 102 | /** 103 | * Remove and cancel queued list 104 | */ 105 | - (void)cancelPrefetching; 106 | 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImagePrefetcher.h" 10 | 11 | @interface SDWebImagePrefetcher () 12 | 13 | @property (strong, nonatomic) SDWebImageManager *manager; 14 | @property (strong, nonatomic) NSArray *prefetchURLs; 15 | @property (assign, nonatomic) NSUInteger requestedCount; 16 | @property (assign, nonatomic) NSUInteger skippedCount; 17 | @property (assign, nonatomic) NSUInteger finishedCount; 18 | @property (assign, nonatomic) NSTimeInterval startedTime; 19 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; 20 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; 21 | 22 | @end 23 | 24 | @implementation SDWebImagePrefetcher 25 | 26 | + (SDWebImagePrefetcher *)sharedImagePrefetcher { 27 | static dispatch_once_t once; 28 | static id instance; 29 | dispatch_once(&once, ^{ 30 | instance = [self new]; 31 | }); 32 | return instance; 33 | } 34 | 35 | - (id)init { 36 | return [self initWithImageManager:[SDWebImageManager new]]; 37 | } 38 | 39 | - (id)initWithImageManager:(SDWebImageManager *)manager { 40 | if ((self = [super init])) { 41 | _manager = manager; 42 | _options = SDWebImageLowPriority; 43 | _prefetcherQueue = dispatch_get_main_queue(); 44 | self.maxConcurrentDownloads = 3; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { 50 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; 51 | } 52 | 53 | - (NSUInteger)maxConcurrentDownloads { 54 | return self.manager.imageDownloader.maxConcurrentDownloads; 55 | } 56 | 57 | - (void)startPrefetchingAtIndex:(NSUInteger)index { 58 | if (index >= self.prefetchURLs.count) return; 59 | self.requestedCount++; 60 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 61 | if (!finished) return; 62 | self.finishedCount++; 63 | 64 | if (image) { 65 | if (self.progressBlock) { 66 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 67 | } 68 | } 69 | else { 70 | if (self.progressBlock) { 71 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 72 | } 73 | // Add last failed 74 | self.skippedCount++; 75 | } 76 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { 77 | [self.delegate imagePrefetcher:self 78 | didPrefetchURL:self.prefetchURLs[index] 79 | finishedCount:self.finishedCount 80 | totalCount:self.prefetchURLs.count 81 | ]; 82 | } 83 | if (self.prefetchURLs.count > self.requestedCount) { 84 | dispatch_async(self.prefetcherQueue, ^{ 85 | [self startPrefetchingAtIndex:self.requestedCount]; 86 | }); 87 | } else if (self.finishedCount == self.requestedCount) { 88 | [self reportStatus]; 89 | if (self.completionBlock) { 90 | self.completionBlock(self.finishedCount, self.skippedCount); 91 | self.completionBlock = nil; 92 | } 93 | self.progressBlock = nil; 94 | } 95 | }]; 96 | } 97 | 98 | - (void)reportStatus { 99 | NSUInteger total = [self.prefetchURLs count]; 100 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { 101 | [self.delegate imagePrefetcher:self 102 | didFinishWithTotalCount:(total - self.skippedCount) 103 | skippedCount:self.skippedCount 104 | ]; 105 | } 106 | } 107 | 108 | - (void)prefetchURLs:(NSArray *)urls { 109 | [self prefetchURLs:urls progress:nil completed:nil]; 110 | } 111 | 112 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { 113 | [self cancelPrefetching]; // Prevent duplicate prefetch request 114 | self.startedTime = CFAbsoluteTimeGetCurrent(); 115 | self.prefetchURLs = urls; 116 | self.completionBlock = completionBlock; 117 | self.progressBlock = progressBlock; 118 | 119 | if (urls.count == 0) { 120 | if (completionBlock) { 121 | completionBlock(0,0); 122 | } 123 | } else { 124 | // Starts prefetching from the very first image on the list with the max allowed concurrency 125 | NSUInteger listCount = self.prefetchURLs.count; 126 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 127 | [self startPrefetchingAtIndex:i]; 128 | } 129 | } 130 | } 131 | 132 | - (void)cancelPrefetching { 133 | self.prefetchURLs = nil; 134 | self.skippedCount = 0; 135 | self.requestedCount = 0; 136 | self.finishedCount = 0; 137 | [self.manager cancelAll]; 138 | } 139 | 140 | @end 141 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.h 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (GIF) 12 | 13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name; 14 | 15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 16 | 17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.m 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "UIImage+GIF.h" 10 | #import 11 | 12 | @implementation UIImage (GIF) 13 | 14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 15 | if (!data) { 16 | return nil; 17 | } 18 | 19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 20 | 21 | size_t count = CGImageSourceGetCount(source); 22 | 23 | UIImage *animatedImage; 24 | 25 | if (count <= 1) { 26 | animatedImage = [[UIImage alloc] initWithData:data]; 27 | } 28 | else { 29 | NSMutableArray *images = [NSMutableArray array]; 30 | 31 | NSTimeInterval duration = 0.0f; 32 | 33 | for (size_t i = 0; i < count; i++) { 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); 35 | if (!image) { 36 | continue; 37 | } 38 | 39 | duration += [self sd_frameDurationAtIndex:i source:source]; 40 | 41 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; 42 | 43 | CGImageRelease(image); 44 | } 45 | 46 | if (!duration) { 47 | duration = (1.0f / 10.0f) * count; 48 | } 49 | 50 | animatedImage = [UIImage animatedImageWithImages:images duration:duration]; 51 | } 52 | 53 | CFRelease(source); 54 | 55 | return animatedImage; 56 | } 57 | 58 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { 59 | float frameDuration = 0.1f; 60 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); 61 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; 62 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; 63 | 64 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; 65 | if (delayTimeUnclampedProp) { 66 | frameDuration = [delayTimeUnclampedProp floatValue]; 67 | } 68 | else { 69 | 70 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; 71 | if (delayTimeProp) { 72 | frameDuration = [delayTimeProp floatValue]; 73 | } 74 | } 75 | 76 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. 77 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify 78 | // a duration of <= 10 ms. See and 79 | // for more information. 80 | 81 | if (frameDuration < 0.011f) { 82 | frameDuration = 0.100f; 83 | } 84 | 85 | CFRelease(cfFrameProperties); 86 | return frameDuration; 87 | } 88 | 89 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name { 90 | CGFloat scale = [UIScreen mainScreen].scale; 91 | 92 | if (scale > 1.0f) { 93 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; 94 | 95 | NSData *data = [NSData dataWithContentsOfFile:retinaPath]; 96 | 97 | if (data) { 98 | return [UIImage sd_animatedGIFWithData:data]; 99 | } 100 | 101 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 102 | 103 | data = [NSData dataWithContentsOfFile:path]; 104 | 105 | if (data) { 106 | return [UIImage sd_animatedGIFWithData:data]; 107 | } 108 | 109 | return [UIImage imageNamed:name]; 110 | } 111 | else { 112 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 113 | 114 | NSData *data = [NSData dataWithContentsOfFile:path]; 115 | 116 | if (data) { 117 | return [UIImage sd_animatedGIFWithData:data]; 118 | } 119 | 120 | return [UIImage imageNamed:name]; 121 | } 122 | } 123 | 124 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { 125 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { 126 | return self; 127 | } 128 | 129 | CGSize scaledSize = size; 130 | CGPoint thumbnailPoint = CGPointZero; 131 | 132 | CGFloat widthFactor = size.width / self.size.width; 133 | CGFloat heightFactor = size.height / self.size.height; 134 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; 135 | scaledSize.width = self.size.width * scaleFactor; 136 | scaledSize.height = self.size.height * scaleFactor; 137 | 138 | if (widthFactor > heightFactor) { 139 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; 140 | } 141 | else if (widthFactor < heightFactor) { 142 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; 143 | } 144 | 145 | NSMutableArray *scaledImages = [NSMutableArray array]; 146 | 147 | for (UIImage *image in self.images) { 148 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); 149 | 150 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; 151 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 152 | 153 | [scaledImages addObject:newImage]; 154 | 155 | UIGraphicsEndImageContext(); 156 | } 157 | 158 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; 159 | } 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (MultiFormat) 12 | 13 | + (UIImage *)sd_imageWithData:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "UIImage+MultiFormat.h" 10 | #import "UIImage+GIF.h" 11 | #import "NSData+ImageContentType.h" 12 | #import 13 | 14 | #ifdef SD_WEBP 15 | #import "UIImage+WebP.h" 16 | #endif 17 | 18 | @implementation UIImage (MultiFormat) 19 | 20 | + (UIImage *)sd_imageWithData:(NSData *)data { 21 | if (!data) { 22 | return nil; 23 | } 24 | 25 | UIImage *image; 26 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; 27 | if ([imageContentType isEqualToString:@"image/gif"]) { 28 | image = [UIImage sd_animatedGIFWithData:data]; 29 | } 30 | #ifdef SD_WEBP 31 | else if ([imageContentType isEqualToString:@"image/webp"]) 32 | { 33 | image = [UIImage sd_imageWithWebPData:data]; 34 | } 35 | #endif 36 | else { 37 | image = [[UIImage alloc] initWithData:data]; 38 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; 39 | if (orientation != UIImageOrientationUp) { 40 | image = [UIImage imageWithCGImage:image.CGImage 41 | scale:image.scale 42 | orientation:orientation]; 43 | } 44 | } 45 | 46 | 47 | return image; 48 | } 49 | 50 | 51 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { 52 | UIImageOrientation result = UIImageOrientationUp; 53 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); 54 | if (imageSource) { 55 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); 56 | if (properties) { 57 | CFTypeRef val; 58 | int exifOrientation; 59 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); 60 | if (val) { 61 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); 62 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; 63 | } // else - if it's not set it remains at up 64 | CFRelease((CFTypeRef) properties); 65 | } else { 66 | //NSLog(@"NO PROPERTIES, FAIL"); 67 | } 68 | CFRelease(imageSource); 69 | } 70 | return result; 71 | } 72 | 73 | #pragma mark EXIF orientation tag converter 74 | // Convert an EXIF image orientation to an iOS one. 75 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html 76 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { 77 | UIImageOrientation orientation = UIImageOrientationUp; 78 | switch (exifOrientation) { 79 | case 1: 80 | orientation = UIImageOrientationUp; 81 | break; 82 | 83 | case 3: 84 | orientation = UIImageOrientationDown; 85 | break; 86 | 87 | case 8: 88 | orientation = UIImageOrientationLeft; 89 | break; 90 | 91 | case 6: 92 | orientation = UIImageOrientationRight; 93 | break; 94 | 95 | case 2: 96 | orientation = UIImageOrientationUpMirrored; 97 | break; 98 | 99 | case 4: 100 | orientation = UIImageOrientationDownMirrored; 101 | break; 102 | 103 | case 5: 104 | orientation = UIImageOrientationLeftMirrored; 105 | break; 106 | 107 | case 7: 108 | orientation = UIImageOrientationRightMirrored; 109 | break; 110 | default: 111 | break; 112 | } 113 | return orientation; 114 | } 115 | 116 | 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageManager.h" 12 | 13 | /** 14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 15 | */ 16 | @interface UIImageView (HighlightedWebCache) 17 | 18 | /** 19 | * Set the imageView `highlightedImage` with an `url`. 20 | * 21 | * The download is asynchronous and cached. 22 | * 23 | * @param url The url for the image. 24 | */ 25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url; 26 | 27 | /** 28 | * Set the imageView `highlightedImage` with an `url` and custom options. 29 | * 30 | * The download is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 34 | */ 35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; 36 | 37 | /** 38 | * Set the imageView `highlightedImage` with an `url`. 39 | * 40 | * The download is asynchronous and cached. 41 | * 42 | * @param url The url for the image. 43 | * @param completedBlock A block called when operation has been completed. This block has no return value 44 | * and takes the requested UIImage as first parameter. In case of error the image parameter 45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 46 | * indicating if the image was retrieved from the local cache or from the network. 47 | * The fourth parameter is the original image url. 48 | */ 49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 50 | 51 | /** 52 | * Set the imageView `highlightedImage` with an `url` and custom options. 53 | * 54 | * The download is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 58 | * @param completedBlock A block called when operation has been completed. This block has no return value 59 | * and takes the requested UIImage as first parameter. In case of error the image parameter 60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 61 | * indicating if the image was retrieved from the local cache or from the network. 62 | * The fourth parameter is the original image url. 63 | */ 64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 65 | 66 | /** 67 | * Set the imageView `highlightedImage` with an `url` and custom options. 68 | * 69 | * The download is asynchronous and cached. 70 | * 71 | * @param url The url for the image. 72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 73 | * @param progressBlock A block called while image is downloading 74 | * @param completedBlock A block called when operation has been completed. This block has no return value 75 | * and takes the requested UIImage as first parameter. In case of error the image parameter 76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 77 | * indicating if the image was retrieved from the local cache or from the network. 78 | * The fourth parameter is the original image url. 79 | */ 80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 81 | 82 | /** 83 | * Cancel the current download 84 | */ 85 | - (void)sd_cancelCurrentHighlightedImageLoad; 86 | 87 | @end 88 | 89 | 90 | @interface UIImageView (HighlightedWebCacheDeprecated) 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); 93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); 94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); 96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); 97 | 98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImageView+HighlightedWebCache.h" 10 | #import "UIView+WebCacheOperation.h" 11 | 12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" 13 | 14 | @implementation UIImageView (HighlightedWebCache) 15 | 16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url { 17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 18 | } 19 | 20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 22 | } 23 | 24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 26 | } 27 | 28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 30 | } 31 | 32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 33 | [self sd_cancelCurrentHighlightedImageLoad]; 34 | 35 | if (url) { 36 | __weak __typeof(self)wself = self; 37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 38 | if (!wself) return; 39 | dispatch_main_sync_safe (^ 40 | { 41 | if (!wself) return; 42 | if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) 43 | { 44 | completedBlock(image, error, cacheType, url); 45 | return; 46 | } 47 | else if (image) { 48 | wself.highlightedImage = image; 49 | [wself setNeedsLayout]; 50 | } 51 | if (completedBlock && finished) { 52 | completedBlock(image, error, cacheType, url); 53 | } 54 | }); 55 | }]; 56 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; 57 | } else { 58 | dispatch_main_async_safe(^{ 59 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 60 | if (completedBlock) { 61 | completedBlock(nil, error, SDImageCacheTypeNone, url); 62 | } 63 | }); 64 | } 65 | } 66 | 67 | - (void)sd_cancelCurrentHighlightedImageLoad { 68 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; 69 | } 70 | 71 | @end 72 | 73 | 74 | @implementation UIImageView (HighlightedWebCacheDeprecated) 75 | 76 | - (void)setHighlightedImageWithURL:(NSURL *)url { 77 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 78 | } 79 | 80 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 81 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 82 | } 83 | 84 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 85 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 86 | if (completedBlock) { 87 | completedBlock(image, error, cacheType); 88 | } 89 | }]; 90 | } 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 93 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 94 | if (completedBlock) { 95 | completedBlock(image, error, cacheType); 96 | } 97 | }]; 98 | } 99 | 100 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { 101 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 102 | if (completedBlock) { 103 | completedBlock(image, error, cacheType); 104 | } 105 | }]; 106 | } 107 | 108 | - (void)cancelCurrentHighlightedImageLoad { 109 | [self sd_cancelCurrentHighlightedImageLoad]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView. 14 | * 15 | * Usage with a UITableViewCell sub-class: 16 | * 17 | * @code 18 | 19 | #import 20 | 21 | ... 22 | 23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 24 | { 25 | static NSString *MyIdentifier = @"MyIdentifier"; 26 | 27 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 28 | 29 | if (cell == nil) { 30 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] 31 | autorelease]; 32 | } 33 | 34 | // Here we use the provided sd_setImageWithURL: method to load the web image 35 | // Ensure you use a placeholder image otherwise cells will be initialized with no image 36 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] 37 | placeholderImage:[UIImage imageNamed:@"placeholder"]]; 38 | 39 | cell.textLabel.text = @"My Text"; 40 | return cell; 41 | } 42 | 43 | * @endcode 44 | */ 45 | @interface UIImageView (WebCache) 46 | 47 | /** 48 | * Get the current image URL. 49 | * 50 | * Note that because of the limitations of categories this property can get out of sync 51 | * if you use sd_setImage: directly. 52 | */ 53 | - (NSURL *)sd_imageURL; 54 | 55 | /** 56 | * Set the imageView `image` with an `url`. 57 | * 58 | * The download is asynchronous and cached. 59 | * 60 | * @param url The url for the image. 61 | */ 62 | - (void)sd_setImageWithURL:(NSURL *)url; 63 | 64 | /** 65 | * Set the imageView `image` with an `url` and a placeholder. 66 | * 67 | * The download is asynchronous and cached. 68 | * 69 | * @param url The url for the image. 70 | * @param placeholder The image to be set initially, until the image request finishes. 71 | * @see sd_setImageWithURL:placeholderImage:options: 72 | */ 73 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 74 | 75 | /** 76 | * Set the imageView `image` with an `url`, placeholder and custom options. 77 | * 78 | * The download is asynchronous and cached. 79 | * 80 | * @param url The url for the image. 81 | * @param placeholder The image to be set initially, until the image request finishes. 82 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 83 | */ 84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 85 | 86 | /** 87 | * Set the imageView `image` with an `url`. 88 | * 89 | * The download is asynchronous and cached. 90 | * 91 | * @param url The url for the image. 92 | * @param completedBlock A block called when operation has been completed. This block has no return value 93 | * and takes the requested UIImage as first parameter. In case of error the image parameter 94 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 95 | * indicating if the image was retrieved from the local cache or from the network. 96 | * The fourth parameter is the original image url. 97 | */ 98 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 99 | 100 | /** 101 | * Set the imageView `image` with an `url`, placeholder. 102 | * 103 | * The download is asynchronous and cached. 104 | * 105 | * @param url The url for the image. 106 | * @param placeholder The image to be set initially, until the image request finishes. 107 | * @param completedBlock A block called when operation has been completed. This block has no return value 108 | * and takes the requested UIImage as first parameter. In case of error the image parameter 109 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 110 | * indicating if the image was retrieved from the local cache or from the network. 111 | * The fourth parameter is the original image url. 112 | */ 113 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 114 | 115 | /** 116 | * Set the imageView `image` with an `url`, placeholder and custom options. 117 | * 118 | * The download is asynchronous and cached. 119 | * 120 | * @param url The url for the image. 121 | * @param placeholder The image to be set initially, until the image request finishes. 122 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 123 | * @param completedBlock A block called when operation has been completed. This block has no return value 124 | * and takes the requested UIImage as first parameter. In case of error the image parameter 125 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 126 | * indicating if the image was retrieved from the local cache or from the network. 127 | * The fourth parameter is the original image url. 128 | */ 129 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 130 | 131 | /** 132 | * Set the imageView `image` with an `url`, placeholder and custom options. 133 | * 134 | * The download is asynchronous and cached. 135 | * 136 | * @param url The url for the image. 137 | * @param placeholder The image to be set initially, until the image request finishes. 138 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 139 | * @param progressBlock A block called while image is downloading 140 | * @param completedBlock A block called when operation has been completed. This block has no return value 141 | * and takes the requested UIImage as first parameter. In case of error the image parameter 142 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 143 | * indicating if the image was retrieved from the local cache or from the network. 144 | * The fourth parameter is the original image url. 145 | */ 146 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 147 | 148 | /** 149 | * Set the imageView `image` with an `url` and optionally a placeholder image. 150 | * 151 | * The download is asynchronous and cached. 152 | * 153 | * @param url The url for the image. 154 | * @param placeholder The image to be set initially, until the image request finishes. 155 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 156 | * @param progressBlock A block called while image is downloading 157 | * @param completedBlock A block called when operation has been completed. This block has no return value 158 | * and takes the requested UIImage as first parameter. In case of error the image parameter 159 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 160 | * indicating if the image was retrieved from the local cache or from the network. 161 | * The fourth parameter is the original image url. 162 | */ 163 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 164 | 165 | /** 166 | * Download an array of images and starts them in an animation loop 167 | * 168 | * @param arrayOfURLs An array of NSURL 169 | */ 170 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; 171 | 172 | /** 173 | * Cancel the current download 174 | */ 175 | - (void)sd_cancelCurrentImageLoad; 176 | 177 | - (void)sd_cancelCurrentAnimationImagesLoad; 178 | 179 | /** 180 | * Show activity UIActivityIndicatorView 181 | */ 182 | - (void)setShowActivityIndicatorView:(BOOL)show; 183 | 184 | /** 185 | * set desired UIActivityIndicatorViewStyle 186 | * 187 | * @param style The style of the UIActivityIndicatorView 188 | */ 189 | - (void)setIndicatorStyle:(UIActivityIndicatorViewStyle)style; 190 | 191 | @end 192 | 193 | 194 | @interface UIImageView (WebCacheDeprecated) 195 | 196 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); 197 | 198 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); 199 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); 200 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); 201 | 202 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); 203 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); 204 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); 205 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); 206 | 207 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithPreviousCachedImageWithURL:placeholderImage:options:progress:completed:`"); 208 | 209 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); 210 | 211 | - (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); 212 | 213 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); 214 | 215 | @end 216 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @interface UIView (WebCacheOperation) 13 | 14 | /** 15 | * Set the image load operation (storage in a UIView based dictionary) 16 | * 17 | * @param operation the operation 18 | * @param key key for storing the operation 19 | */ 20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; 21 | 22 | /** 23 | * Cancel all operations for the current UIView and key 24 | * 25 | * @param key key for identifying the operations 26 | */ 27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; 28 | 29 | /** 30 | * Just remove the operations corresponding to the current UIView and key without cancelling them 31 | * 32 | * @param key key for identifying the operations 33 | */ 34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIView+WebCacheOperation.h" 10 | #import "objc/runtime.h" 11 | 12 | static char loadOperationKey; 13 | 14 | @implementation UIView (WebCacheOperation) 15 | 16 | - (NSMutableDictionary *)operationDictionary { 17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 18 | if (operations) { 19 | return operations; 20 | } 21 | operations = [NSMutableDictionary dictionary]; 22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 23 | return operations; 24 | } 25 | 26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { 27 | [self sd_cancelImageLoadOperationWithKey:key]; 28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 29 | [operationDictionary setObject:operation forKey:key]; 30 | } 31 | 32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { 33 | // Cancel in progress downloader from queue 34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 35 | id operations = [operationDictionary objectForKey:key]; 36 | if (operations) { 37 | if ([operations isKindOfClass:[NSArray class]]) { 38 | for (id operation in operations) { 39 | if (operation) { 40 | [operation cancel]; 41 | } 42 | } 43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ 44 | [(id) operations cancel]; 45 | } 46 | [operationDictionary removeObjectForKey:key]; 47 | } 48 | } 49 | 50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key { 51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 52 | [operationDictionary removeObjectForKey:key]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SDWebImage 5 | 6 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is furnished 13 | to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 27 | 28 | ## WebViewJavascriptBridge 29 | 30 | Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec 31 | 32 | Permission is hereby granted, free of charge, to any person 33 | obtaining a copy of this software and associated documentation 34 | files (the "Software"), to deal in the Software without 35 | restriction, including without limitation the rights to use, 36 | copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the 38 | Software is furnished to do so, subject to the following 39 | conditions: 40 | 41 | The above copyright notice and this permission notice shall be 42 | included in all copies or substantial portions of the Software. 43 | 44 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 45 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 46 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 47 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 48 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 49 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 50 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 51 | OTHER DEALINGS IN THE SOFTWARE. 52 | 53 | Generated by CocoaPods - https://cocoapods.org 54 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is furnished 24 | to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in all 27 | copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | 38 | Title 39 | SDWebImage 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec 46 | 47 | Permission is hereby granted, free of charge, to any person 48 | obtaining a copy of this software and associated documentation 49 | files (the "Software"), to deal in the Software without 50 | restriction, including without limitation the rights to use, 51 | copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the 53 | Software is furnished to do so, subject to the following 54 | conditions: 55 | 56 | The above copyright notice and this permission notice shall be 57 | included in all copies or substantial portions of the Software. 58 | 59 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 60 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 61 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 62 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 63 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 64 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 65 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 66 | OTHER DEALINGS IN THE SOFTWARE. 67 | 68 | Title 69 | WebViewJavascriptBridge 70 | Type 71 | PSGroupSpecifier 72 | 73 | 74 | FooterText 75 | Generated by CocoaPods - https://cocoapods.org 76 | Title 77 | 78 | Type 79 | PSGroupSpecifier 80 | 81 | 82 | StringsTable 83 | Acknowledgements 84 | Title 85 | Acknowledgements 86 | 87 | 88 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_JHNewsDetail : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_JHNewsDetail 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/SDWebImage/SDWebImage.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/SDWebImage/SDWebImage.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_JHNewsDetailVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_JHNewsDetailVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage" "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage/SDWebImage.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "SDWebImage" -framework "WebViewJavascriptBridge" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_JHNewsDetail { 2 | umbrella header "Pods-JHNewsDetail-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-JHNewsDetail/Pods-JHNewsDetail.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage" "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage/SDWebImage.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "SDWebImage" -framework "WebViewJavascriptBridge" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.7.6 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_SDWebImage : NSObject 3 | @end 4 | @implementation PodsDummy_SDWebImage 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "NSData+ImageContentType.h" 4 | #import "SDImageCache.h" 5 | #import "SDWebImageCompat.h" 6 | #import "SDWebImageDecoder.h" 7 | #import "SDWebImageDownloader.h" 8 | #import "SDWebImageDownloaderOperation.h" 9 | #import "SDWebImageManager.h" 10 | #import "SDWebImageOperation.h" 11 | #import "SDWebImagePrefetcher.h" 12 | #import "UIButton+WebCache.h" 13 | #import "UIImage+GIF.h" 14 | #import "UIImage+MultiFormat.h" 15 | #import "UIImageView+HighlightedWebCache.h" 16 | #import "UIImageView+WebCache.h" 17 | #import "UIView+WebCacheOperation.h" 18 | 19 | FOUNDATION_EXPORT double SDWebImageVersionNumber; 20 | FOUNDATION_EXPORT const unsigned char SDWebImageVersionString[]; 21 | 22 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage.modulemap: -------------------------------------------------------------------------------- 1 | framework module SDWebImage { 2 | umbrella header "SDWebImage-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SDWebImage 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_LDFLAGS = -framework "ImageIO" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 5.0.5 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_WebViewJavascriptBridge : NSObject 3 | @end 4 | @implementation PodsDummy_WebViewJavascriptBridge 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "WebViewJavascriptBridge.h" 4 | #import "WebViewJavascriptBridgeBase.h" 5 | #import "WKWebViewJavascriptBridge.h" 6 | 7 | FOUNDATION_EXPORT double WebViewJavascriptBridgeVersionNumber; 8 | FOUNDATION_EXPORT const unsigned char WebViewJavascriptBridgeVersionString[]; 9 | 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap: -------------------------------------------------------------------------------- 1 | framework module WebViewJavascriptBridge { 2 | umbrella header "WebViewJavascriptBridge-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_LDFLAGS = -framework "UIKit" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/README.md: -------------------------------------------------------------------------------- 1 | WebViewJavascriptBridge 2 | ======================= 3 | 4 | [![Build Status](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge.svg)](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge) 5 | 6 | An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews. 7 | 8 | Who uses WebViewJavascriptBridge? 9 | --------------------------------- 10 | WebViewJavascriptBridge is used by a range of companies and projects. This is a small and incomplete sample list: 11 | 12 | - [Facebook Messenger](https://www.facebook.com/mobile/messenger) 13 | - [Facebook Paper](https://facebook.com/paper) 14 | - [Yardsale](http://www.getyardsale.com/) 15 | - [EverTrue](http://www.evertrue.com/) 16 | - [Game Insight](http://www.game-insight.com/) 17 | - [Sush.io](http://www.sush.io) 18 | - [Imbed](http://imbed.github.io/) 19 | - [CareZone](https://carezone.com) 20 | - [Hemlig](http://www.hemlig.co) 21 | - [Altralogica](http://www.altralogica.it) 22 | - [鼎盛中华](https://itunes.apple.com/us/app/ding-sheng-zhong-hua/id537273940?mt=8) 23 | - [FRIL](https://fril.jp) 24 | - [留白·WHITE](http://liubaiapp.com) 25 | 26 | Installation (iOS & OSX) 27 | ------------------------ 28 | 29 | ### Installation with CocoaPods 30 | Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: 31 | 32 | ```ruby 33 | `pod 'WebViewJavascriptBridge', '~> 5.0'` 34 | ``` 35 | 36 | ### Manual installation 37 | 38 | Drag the `WebViewJavascriptBridge` folder into your project. 39 | 40 | In the dialog that appears, uncheck "Copy items into destination group's folder" and select "Create groups for any folders". 41 | 42 | Examples 43 | -------- 44 | 45 | See the `Example Apps/` folder. Open either the iOS or OSX project and hit run to see it in action. 46 | 47 | To use a WebViewJavascriptBridge in your own project: 48 | 49 | Usage 50 | ----- 51 | 52 | 1) Import the header file and declare an ivar property: 53 | 54 | ```objc 55 | #import "WebViewJavascriptBridge.h" 56 | ``` 57 | 58 | ... 59 | 60 | ```objc 61 | @property WebViewJavascriptBridge* bridge; 62 | ``` 63 | 64 | 2) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX): 65 | 66 | ```objc 67 | self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; 68 | ``` 69 | 70 | 3) Register a handler in ObjC, and call a JS handler: 71 | 72 | ```objc 73 | [self.bridge registerHandler:@"ObjC Echo" handler:^(id data, WVJBResponseCallback responseCallback) { 74 | NSLog(@"ObjC Echo called with: %@", data); 75 | responseCallback(data); 76 | }]; 77 | [self.bridge callHandler:@"JS Echo" responseCallback:^(id responseData) { 78 | NSLog(@"ObjC received response: %@", responseData); 79 | }]; 80 | ``` 81 | 82 | 4) Copy and paste `setupWebViewJavascriptBridge` into your JS: 83 | 84 | ```javascript 85 | function setupWebViewJavascriptBridge(callback) { 86 | if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } 87 | if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } 88 | window.WVJBCallbacks = [callback]; 89 | var WVJBIframe = document.createElement('iframe'); 90 | WVJBIframe.style.display = 'none'; 91 | WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; 92 | document.documentElement.appendChild(WVJBIframe); 93 | setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) 94 | } 95 | ``` 96 | 97 | 5) Finally, call `setupWebViewJavascriptBridge` and then use the bridge to register handlers and call ObjC handlers: 98 | 99 | ```javascript 100 | setupWebViewJavascriptBridge(function(bridge) { 101 | 102 | /* Initialize your app here */ 103 | 104 | bridge.registerHandler('JS Echo', function(data, responseCallback) { 105 | console.log("JS Echo called with:", data) 106 | responseCallback(data) 107 | }) 108 | bridge.callHandler('ObjC Echo', function responseCallback(responseData) { 109 | console.log("JS received response:", responseData) 110 | }) 111 | }) 112 | ``` 113 | 114 | WKWebView Support (iOS 8+ & OS 10.10+) 115 | -------------------------------------- 116 | 117 | (WARNING: WKWebView still has [bugs and missing network APIs.](https://github.com/ShingoFukuyama/WKWebViewTips/blob/master/README.md) It may not be a simple drop-in replacement). 118 | 119 | WebViewJavascriptBridge supports [WKWebView](http://nshipster.com/wkwebkit/) for iOS 8 and OSX Yosemite. In order to use WKWebView you need to instantiate the `WKWebViewJavascriptBridge`. The rest of the `WKWebViewJavascriptBridge` API is the same as `WebViewJavascriptBridge`. 120 | 121 | 1) Import the header file: 122 | 123 | ```objc 124 | #import "WKWebViewJavascriptBridge.h" 125 | ``` 126 | 127 | 2) Instantiate WKWebViewJavascriptBridge and with a WKWebView object 128 | 129 | ```objc 130 | WKWebViewJavascriptBridge* bridge = [WKWebViewJavascriptBridge bridgeForWebView:webView]; 131 | ``` 132 | 133 | Contributors & Forks 134 | -------------------- 135 | Contributors: https://github.com/marcuswestin/WebViewJavascriptBridge/graphs/contributors 136 | 137 | Forks: https://github.com/marcuswestin/WebViewJavascriptBridge/network/members 138 | 139 | API Reference 140 | ------------- 141 | 142 | ### ObjC API 143 | 144 | ##### `[WebViewJavascriptBridge bridgeForWebView:(UIWebView/WebView*)webview` 145 | 146 | Create a javascript bridge for the given web view. 147 | 148 | Example: 149 | 150 | ```objc 151 | [WebViewJavascriptBridge bridgeForWebView:webView]; 152 | ``` 153 | 154 | ##### `[bridge registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler]` 155 | 156 | Register a handler called `handlerName`. The javascript can then call this handler with `WebViewJavascriptBridge.callHandler("handlerName")`. 157 | 158 | Example: 159 | 160 | ```objc 161 | [self.bridge registerHandler:@"getScreenHeight" handler:^(id data, WVJBResponseCallback responseCallback) { 162 | responseCallback([NSNumber numberWithInt:[UIScreen mainScreen].bounds.size.height]); 163 | }]; 164 | [self.bridge registerHandler:@"log" handler:^(id data, WVJBResponseCallback responseCallback) { 165 | NSLog(@"Log: %@", data); 166 | }]; 167 | 168 | ``` 169 | 170 | ##### `[bridge callHandler:(NSString*)handlerName data:(id)data]` 171 | ##### `[bridge callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)callback]` 172 | 173 | Call the javascript handler called `handlerName`. If a `responseCallback` block is given the javascript handler can respond. 174 | 175 | Example: 176 | 177 | ```objc 178 | [self.bridge callHandler:@"showAlert" data:@"Hi from ObjC to JS!"]; 179 | [self.bridge callHandler:@"getCurrentPageUrl" data:nil responseCallback:^(id responseData) { 180 | NSLog(@"Current UIWebView page URL is: %@", responseData); 181 | }]; 182 | ``` 183 | 184 | #### `[bridge setWebViewDelegate:UIWebViewDelegate*)webViewDelegate]` 185 | 186 | Optionally, set a `UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html). 187 | 188 | 189 | 190 | 191 | ### Javascript API 192 | 193 | ##### `bridge.registerHandler("handlerName", function(responseData) { ... })` 194 | 195 | Register a handler called `handlerName`. The ObjC can then call this handler with `[bridge callHandler:"handlerName" data:@"Foo"]` and `[bridge callHandler:"handlerName" data:@"Foo" responseCallback:^(id responseData) { ... }]` 196 | 197 | Example: 198 | 199 | ```javascript 200 | bridge.registerHandler("showAlert", function(data) { alert(data) }) 201 | bridge.registerHandler("getCurrentPageUrl", function(data, responseCallback) { 202 | responseCallback(document.location.toString()) 203 | }) 204 | ``` 205 | 206 | 207 | ##### `bridge.callHander("handlerName", data)` 208 | ##### `bridge.callHander("handlerName", data, function responseCallback(responseData) { ... })` 209 | 210 | Call an ObjC handler called `handlerName`. If a `responseCallback` function is given the ObjC handler can respond. 211 | 212 | Example: 213 | 214 | ```javascript 215 | bridge.callHandler("Log", "Foo") 216 | bridge.callHandler("getScreenHeight", null, function(response) { 217 | alert('Screen height:' + response) 218 | }) 219 | ``` 220 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebViewJavascriptBridge.h 3 | // 4 | // Created by @LokiMeyburg on 10/15/14. 5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved. 6 | // 7 | 8 | #if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_1) 9 | #define supportsWKWebKit 10 | #endif 11 | 12 | #if defined(supportsWKWebKit ) 13 | 14 | #import 15 | #import "WebViewJavascriptBridgeBase.h" 16 | #import 17 | 18 | @interface WKWebViewJavascriptBridge : NSObject 19 | 20 | + (instancetype)bridgeForWebView:(WKWebView*)webView; 21 | + (void)enableLogging; 22 | 23 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler; 24 | - (void)callHandler:(NSString*)handlerName; 25 | - (void)callHandler:(NSString*)handlerName data:(id)data; 26 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; 27 | - (void)reset; 28 | - (void)setWebViewDelegate:(id)webViewDelegate; 29 | 30 | @end 31 | 32 | #endif -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // WKWebViewJavascriptBridge.m 3 | // 4 | // Created by @LokiMeyburg on 10/15/14. 5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved. 6 | // 7 | 8 | 9 | #import "WKWebViewJavascriptBridge.h" 10 | 11 | #if defined(supportsWKWebKit) 12 | 13 | @implementation WKWebViewJavascriptBridge { 14 | WKWebView* _webView; 15 | id _webViewDelegate; 16 | long _uniqueId; 17 | WebViewJavascriptBridgeBase *_base; 18 | } 19 | 20 | /* API 21 | *****/ 22 | 23 | + (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } 24 | 25 | + (instancetype)bridgeForWebView:(WKWebView*)webView { 26 | WKWebViewJavascriptBridge* bridge = [[self alloc] init]; 27 | [bridge _setupInstance:webView]; 28 | [bridge reset]; 29 | return bridge; 30 | } 31 | 32 | - (void)send:(id)data { 33 | [self send:data responseCallback:nil]; 34 | } 35 | 36 | - (void)send:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 37 | [_base sendData:data responseCallback:responseCallback handlerName:nil]; 38 | } 39 | 40 | - (void)callHandler:(NSString *)handlerName { 41 | [self callHandler:handlerName data:nil responseCallback:nil]; 42 | } 43 | 44 | - (void)callHandler:(NSString *)handlerName data:(id)data { 45 | [self callHandler:handlerName data:data responseCallback:nil]; 46 | } 47 | 48 | - (void)callHandler:(NSString *)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 49 | [_base sendData:data responseCallback:responseCallback handlerName:handlerName]; 50 | } 51 | 52 | - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { 53 | _base.messageHandlers[handlerName] = [handler copy]; 54 | } 55 | 56 | - (void)reset { 57 | [_base reset]; 58 | } 59 | 60 | - (void)setWebViewDelegate:(id)webViewDelegate { 61 | _webViewDelegate = webViewDelegate; 62 | } 63 | 64 | /* Internals 65 | ***********/ 66 | 67 | - (void)dealloc { 68 | _base = nil; 69 | _webView = nil; 70 | _webViewDelegate = nil; 71 | _webView.navigationDelegate = nil; 72 | } 73 | 74 | 75 | /* WKWebView Specific Internals 76 | ******************************/ 77 | 78 | - (void) _setupInstance:(WKWebView*)webView { 79 | _webView = webView; 80 | _webView.navigationDelegate = self; 81 | _base = [[WebViewJavascriptBridgeBase alloc] init]; 82 | _base.delegate = self; 83 | } 84 | 85 | 86 | - (void)WKFlushMessageQueue { 87 | [_webView evaluateJavaScript:[_base webViewJavascriptFetchQueyCommand] completionHandler:^(NSString* result, NSError* error) { 88 | if (error != nil) { 89 | NSLog(@"WebViewJavascriptBridge: WARNING: Error when trying to fetch data from WKWebView: %@", error); 90 | } 91 | [_base flushMessageQueue:result]; 92 | }]; 93 | } 94 | 95 | - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 96 | { 97 | if (webView != _webView) { return; } 98 | 99 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 100 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFinishNavigation:)]) { 101 | [strongDelegate webView:webView didFinishNavigation:navigation]; 102 | } 103 | } 104 | 105 | 106 | - (void)webView:(WKWebView *)webView 107 | decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction 108 | decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { 109 | if (webView != _webView) { return; } 110 | NSURL *url = navigationAction.request.URL; 111 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 112 | 113 | if ([_base isCorrectProcotocolScheme:url]) { 114 | if ([_base isBridgeLoadedURL:url]) { 115 | [_base injectJavascriptFile]; 116 | } else if ([_base isQueueMessageURL:url]) { 117 | [self WKFlushMessageQueue]; 118 | } else { 119 | [_base logUnkownMessage:url]; 120 | } 121 | decisionHandler(WKNavigationActionPolicyCancel); 122 | } 123 | 124 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { 125 | [_webViewDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler]; 126 | } else { 127 | decisionHandler(WKNavigationActionPolicyAllow); 128 | } 129 | } 130 | 131 | - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { 132 | if (webView != _webView) { return; } 133 | 134 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 135 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didStartProvisionalNavigation:)]) { 136 | [strongDelegate webView:webView didStartProvisionalNavigation:navigation]; 137 | } 138 | } 139 | 140 | 141 | - (void)webView:(WKWebView *)webView 142 | didFailNavigation:(WKNavigation *)navigation 143 | withError:(NSError *)error { 144 | if (webView != _webView) { return; } 145 | 146 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 147 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailNavigation:withError:)]) { 148 | [strongDelegate webView:webView didFailNavigation:navigation withError:error]; 149 | } 150 | } 151 | 152 | - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { 153 | if (webView != _webView) { return; } 154 | 155 | __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; 156 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailProvisionalNavigation:withError:)]) { 157 | [strongDelegate webView:webView didFailProvisionalNavigation:navigation withError:error]; 158 | } 159 | } 160 | 161 | - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand 162 | { 163 | [_webView evaluateJavaScript:javascriptCommand completionHandler:nil]; 164 | return NULL; 165 | } 166 | 167 | 168 | 169 | @end 170 | 171 | 172 | #endif 173 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridge.h 3 | // ExampleApp-iOS 4 | // 5 | // Created by Marcus Westin on 6/14/13. 6 | // Copyright (c) 2013 Marcus Westin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WebViewJavascriptBridgeBase.h" 11 | 12 | #if defined __MAC_OS_X_VERSION_MAX_ALLOWED 13 | #import 14 | #define WVJB_PLATFORM_OSX 15 | #define WVJB_WEBVIEW_TYPE WebView 16 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject 17 | #define WVJB_WEBVIEW_DELEGATE_INTERFACE NSObject 18 | #elif defined __IPHONE_OS_VERSION_MAX_ALLOWED 19 | #import 20 | #define WVJB_PLATFORM_IOS 21 | #define WVJB_WEBVIEW_TYPE UIWebView 22 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject 23 | #define WVJB_WEBVIEW_DELEGATE_INTERFACE NSObject 24 | #endif 25 | 26 | @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE 27 | 28 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView; 29 | + (void)enableLogging; 30 | + (void)setLogMaxLength:(int)length; 31 | 32 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler; 33 | - (void)callHandler:(NSString*)handlerName; 34 | - (void)callHandler:(NSString*)handlerName data:(id)data; 35 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; 36 | - (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate; 37 | @end 38 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridge.m 3 | // ExampleApp-iOS 4 | // 5 | // Created by Marcus Westin on 6/14/13. 6 | // Copyright (c) 2013 Marcus Westin. All rights reserved. 7 | // 8 | 9 | #import "WebViewJavascriptBridge.h" 10 | 11 | #if __has_feature(objc_arc_weak) 12 | #define WVJB_WEAK __weak 13 | #else 14 | #define WVJB_WEAK __unsafe_unretained 15 | #endif 16 | 17 | @implementation WebViewJavascriptBridge { 18 | WVJB_WEAK WVJB_WEBVIEW_TYPE* _webView; 19 | WVJB_WEAK id _webViewDelegate; 20 | long _uniqueId; 21 | WebViewJavascriptBridgeBase *_base; 22 | } 23 | 24 | /* API 25 | *****/ 26 | 27 | + (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } 28 | + (void)setLogMaxLength:(int)length { [WebViewJavascriptBridgeBase setLogMaxLength:length]; } 29 | 30 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView { 31 | WebViewJavascriptBridge* bridge = [[self alloc] init]; 32 | [bridge _platformSpecificSetup:webView]; 33 | return bridge; 34 | } 35 | 36 | - (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate { 37 | _webViewDelegate = webViewDelegate; 38 | } 39 | 40 | - (void)send:(id)data { 41 | [self send:data responseCallback:nil]; 42 | } 43 | 44 | - (void)send:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 45 | [_base sendData:data responseCallback:responseCallback handlerName:nil]; 46 | } 47 | 48 | - (void)callHandler:(NSString *)handlerName { 49 | [self callHandler:handlerName data:nil responseCallback:nil]; 50 | } 51 | 52 | - (void)callHandler:(NSString *)handlerName data:(id)data { 53 | [self callHandler:handlerName data:data responseCallback:nil]; 54 | } 55 | 56 | - (void)callHandler:(NSString *)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback { 57 | [_base sendData:data responseCallback:responseCallback handlerName:handlerName]; 58 | } 59 | 60 | - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { 61 | _base.messageHandlers[handlerName] = [handler copy]; 62 | } 63 | 64 | /* Platform agnostic internals 65 | *****************************/ 66 | 67 | - (void)dealloc { 68 | [self _platformSpecificDealloc]; 69 | _base = nil; 70 | _webView = nil; 71 | _webViewDelegate = nil; 72 | } 73 | 74 | - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand 75 | { 76 | return [_webView stringByEvaluatingJavaScriptFromString:javascriptCommand]; 77 | } 78 | 79 | /* Platform specific internals: OSX 80 | **********************************/ 81 | #if defined WVJB_PLATFORM_OSX 82 | 83 | - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { 84 | _webView = webView; 85 | 86 | _webView.policyDelegate = self; 87 | 88 | _base = [[WebViewJavascriptBridgeBase alloc] init]; 89 | _base.delegate = self; 90 | } 91 | 92 | - (void) _platformSpecificDealloc { 93 | _webView.policyDelegate = nil; 94 | } 95 | 96 | - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener 97 | { 98 | if (webView != _webView) { return; } 99 | 100 | NSURL *url = [request URL]; 101 | if ([_base isCorrectProcotocolScheme:url]) { 102 | if ([_base isBridgeLoadedURL:url]) { 103 | [_base injectJavascriptFile]; 104 | } else if ([_base isQueueMessageURL:url]) { 105 | NSString *messageQueueString = [self _evaluateJavascript:[_base webViewJavascriptFetchQueyCommand]]; 106 | [_base flushMessageQueue:messageQueueString]; 107 | } else { 108 | [_base logUnkownMessage:url]; 109 | } 110 | [listener ignore]; 111 | } else if (_webViewDelegate && [_webViewDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)]) { 112 | [_webViewDelegate webView:webView decidePolicyForNavigationAction:actionInformation request:request frame:frame decisionListener:listener]; 113 | } else { 114 | [listener use]; 115 | } 116 | } 117 | 118 | 119 | 120 | /* Platform specific internals: iOS 121 | **********************************/ 122 | #elif defined WVJB_PLATFORM_IOS 123 | 124 | - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { 125 | _webView = webView; 126 | _webView.delegate = self; 127 | _base = [[WebViewJavascriptBridgeBase alloc] init]; 128 | _base.delegate = self; 129 | } 130 | 131 | - (void) _platformSpecificDealloc { 132 | _webView.delegate = nil; 133 | } 134 | 135 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 136 | if (webView != _webView) { return; } 137 | 138 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 139 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 140 | [strongDelegate webViewDidFinishLoad:webView]; 141 | } 142 | } 143 | 144 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { 145 | if (webView != _webView) { return; } 146 | 147 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 148 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) { 149 | [strongDelegate webView:webView didFailLoadWithError:error]; 150 | } 151 | } 152 | 153 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 154 | if (webView != _webView) { return YES; } 155 | NSURL *url = [request URL]; 156 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 157 | if ([_base isCorrectProcotocolScheme:url]) { 158 | if ([_base isBridgeLoadedURL:url]) { 159 | [_base injectJavascriptFile]; 160 | } else if ([_base isQueueMessageURL:url]) { 161 | NSString *messageQueueString = [self _evaluateJavascript:[_base webViewJavascriptFetchQueyCommand]]; 162 | [_base flushMessageQueue:messageQueueString]; 163 | } else { 164 | [_base logUnkownMessage:url]; 165 | } 166 | return NO; 167 | } else if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) { 168 | return [strongDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType]; 169 | } else { 170 | return YES; 171 | } 172 | } 173 | 174 | - (void)webViewDidStartLoad:(UIWebView *)webView { 175 | if (webView != _webView) { return; } 176 | 177 | __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; 178 | if (strongDelegate && [strongDelegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 179 | [strongDelegate webViewDidStartLoad:webView]; 180 | } 181 | } 182 | 183 | #endif 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridgeBase.h 3 | // 4 | // Created by @LokiMeyburg on 10/15/14. 5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #define kCustomProtocolScheme @"wvjbscheme" 11 | #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__" 12 | #define kBridgeLoaded @"__BRIDGE_LOADED__" 13 | 14 | typedef void (^WVJBResponseCallback)(id responseData); 15 | typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); 16 | typedef NSDictionary WVJBMessage; 17 | 18 | @protocol WebViewJavascriptBridgeBaseDelegate 19 | - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand; 20 | @end 21 | 22 | @interface WebViewJavascriptBridgeBase : NSObject 23 | 24 | 25 | @property (assign) id delegate; 26 | @property (strong, nonatomic) NSMutableArray* startupMessageQueue; 27 | @property (strong, nonatomic) NSMutableDictionary* responseCallbacks; 28 | @property (strong, nonatomic) NSMutableDictionary* messageHandlers; 29 | @property (strong, nonatomic) WVJBHandler messageHandler; 30 | 31 | + (void)enableLogging; 32 | + (void)setLogMaxLength:(int)length; 33 | - (void)reset; 34 | - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName; 35 | - (void)flushMessageQueue:(NSString *)messageQueueString; 36 | - (void)injectJavascriptFile; 37 | - (BOOL)isCorrectProcotocolScheme:(NSURL*)url; 38 | - (BOOL)isQueueMessageURL:(NSURL*)urll; 39 | - (BOOL)isBridgeLoadedURL:(NSURL*)urll; 40 | - (void)logUnkownMessage:(NSURL*)url; 41 | - (NSString *)webViewJavascriptCheckCommand; 42 | - (NSString *)webViewJavascriptFetchQueyCommand; 43 | 44 | @end -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridgeBase.m 3 | // 4 | // Created by @LokiMeyburg on 10/15/14. 5 | // Copyright (c) 2014 @LokiMeyburg. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "WebViewJavascriptBridgeBase.h" 10 | #import "WebViewJavascriptBridge_JS.h" 11 | 12 | @implementation WebViewJavascriptBridgeBase { 13 | id _webViewDelegate; 14 | long _uniqueId; 15 | } 16 | 17 | static bool logging = false; 18 | static int logMaxLength = 500; 19 | 20 | + (void)enableLogging { logging = true; } 21 | + (void)setLogMaxLength:(int)length { logMaxLength = length;} 22 | 23 | -(id)init { 24 | self = [super init]; 25 | self.messageHandlers = [NSMutableDictionary dictionary]; 26 | self.startupMessageQueue = [NSMutableArray array]; 27 | self.responseCallbacks = [NSMutableDictionary dictionary]; 28 | _uniqueId = 0; 29 | return(self); 30 | } 31 | 32 | - (void)dealloc { 33 | self.startupMessageQueue = nil; 34 | self.responseCallbacks = nil; 35 | self.messageHandlers = nil; 36 | } 37 | 38 | - (void)reset { 39 | self.startupMessageQueue = [NSMutableArray array]; 40 | self.responseCallbacks = [NSMutableDictionary dictionary]; 41 | _uniqueId = 0; 42 | } 43 | 44 | - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName { 45 | NSMutableDictionary* message = [NSMutableDictionary dictionary]; 46 | 47 | if (data) { 48 | message[@"data"] = data; 49 | } 50 | 51 | if (responseCallback) { 52 | NSString* callbackId = [NSString stringWithFormat:@"objc_cb_%ld", ++_uniqueId]; 53 | self.responseCallbacks[callbackId] = [responseCallback copy]; 54 | message[@"callbackId"] = callbackId; 55 | } 56 | 57 | if (handlerName) { 58 | message[@"handlerName"] = handlerName; 59 | } 60 | [self _queueMessage:message]; 61 | } 62 | 63 | - (void)flushMessageQueue:(NSString *)messageQueueString{ 64 | if (messageQueueString == nil || messageQueueString.length == 0) { 65 | NSLog(@"WebViewJavascriptBridge: WARNING: ObjC got nil while fetching the message queue JSON from webview. This can happen if the WebViewJavascriptBridge JS is not currently present in the webview, e.g if the webview just loaded a new page."); 66 | return; 67 | } 68 | 69 | id messages = [self _deserializeMessageJSON:messageQueueString]; 70 | for (WVJBMessage* message in messages) { 71 | if (![message isKindOfClass:[WVJBMessage class]]) { 72 | NSLog(@"WebViewJavascriptBridge: WARNING: Invalid %@ received: %@", [message class], message); 73 | continue; 74 | } 75 | [self _log:@"RCVD" json:message]; 76 | 77 | NSString* responseId = message[@"responseId"]; 78 | if (responseId) { 79 | WVJBResponseCallback responseCallback = _responseCallbacks[responseId]; 80 | responseCallback(message[@"responseData"]); 81 | [self.responseCallbacks removeObjectForKey:responseId]; 82 | } else { 83 | WVJBResponseCallback responseCallback = NULL; 84 | NSString* callbackId = message[@"callbackId"]; 85 | if (callbackId) { 86 | responseCallback = ^(id responseData) { 87 | if (responseData == nil) { 88 | responseData = [NSNull null]; 89 | } 90 | 91 | WVJBMessage* msg = @{ @"responseId":callbackId, @"responseData":responseData }; 92 | [self _queueMessage:msg]; 93 | }; 94 | } else { 95 | responseCallback = ^(id ignoreResponseData) { 96 | // Do nothing 97 | }; 98 | } 99 | 100 | WVJBHandler handler = self.messageHandlers[message[@"handlerName"]]; 101 | 102 | if (!handler) { 103 | NSLog(@"WVJBNoHandlerException, No handler for message from JS: %@", message); 104 | continue; 105 | } 106 | 107 | handler(message[@"data"], responseCallback); 108 | } 109 | } 110 | } 111 | 112 | - (void)injectJavascriptFile { 113 | NSString *js = WebViewJavascriptBridge_js(); 114 | [self _evaluateJavascript:js]; 115 | if (self.startupMessageQueue) { 116 | NSArray* queue = self.startupMessageQueue; 117 | self.startupMessageQueue = nil; 118 | for (id queuedMessage in queue) { 119 | [self _dispatchMessage:queuedMessage]; 120 | } 121 | } 122 | } 123 | 124 | -(BOOL)isCorrectProcotocolScheme:(NSURL*)url { 125 | if([[url scheme] isEqualToString:kCustomProtocolScheme]){ 126 | return YES; 127 | } else { 128 | return NO; 129 | } 130 | } 131 | 132 | -(BOOL)isQueueMessageURL:(NSURL*)url { 133 | if([[url host] isEqualToString:kQueueHasMessage]){ 134 | return YES; 135 | } else { 136 | return NO; 137 | } 138 | } 139 | 140 | -(BOOL)isBridgeLoadedURL:(NSURL*)url { 141 | return ([[url scheme] isEqualToString:kCustomProtocolScheme] && [[url host] isEqualToString:kBridgeLoaded]); 142 | } 143 | 144 | -(void)logUnkownMessage:(NSURL*)url { 145 | NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@://%@", kCustomProtocolScheme, [url path]); 146 | } 147 | 148 | -(NSString *)webViewJavascriptCheckCommand { 149 | return @"typeof WebViewJavascriptBridge == \'object\';"; 150 | } 151 | 152 | -(NSString *)webViewJavascriptFetchQueyCommand { 153 | return @"WebViewJavascriptBridge._fetchQueue();"; 154 | } 155 | 156 | // Private 157 | // ------------------------------------------- 158 | 159 | - (void) _evaluateJavascript:(NSString *)javascriptCommand { 160 | [self.delegate _evaluateJavascript:javascriptCommand]; 161 | } 162 | 163 | - (void)_queueMessage:(WVJBMessage*)message { 164 | if (self.startupMessageQueue) { 165 | [self.startupMessageQueue addObject:message]; 166 | } else { 167 | [self _dispatchMessage:message]; 168 | } 169 | } 170 | 171 | - (void)_dispatchMessage:(WVJBMessage*)message { 172 | NSString *messageJSON = [self _serializeMessage:message pretty:NO]; 173 | [self _log:@"SEND" json:messageJSON]; 174 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]; 175 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; 176 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\'" withString:@"\\\'"]; 177 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; 178 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\r" withString:@"\\r"]; 179 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\f" withString:@"\\f"]; 180 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2028" withString:@"\\u2028"]; 181 | messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2029" withString:@"\\u2029"]; 182 | 183 | NSString* javascriptCommand = [NSString stringWithFormat:@"WebViewJavascriptBridge._handleMessageFromObjC('%@');", messageJSON]; 184 | if ([[NSThread currentThread] isMainThread]) { 185 | [self _evaluateJavascript:javascriptCommand]; 186 | 187 | } else { 188 | dispatch_sync(dispatch_get_main_queue(), ^{ 189 | [self _evaluateJavascript:javascriptCommand]; 190 | }); 191 | } 192 | } 193 | 194 | - (NSString *)_serializeMessage:(id)message pretty:(BOOL)pretty{ 195 | return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:message options:(NSJSONWritingOptions)(pretty ? NSJSONWritingPrettyPrinted : 0) error:nil] encoding:NSUTF8StringEncoding]; 196 | } 197 | 198 | - (NSArray*)_deserializeMessageJSON:(NSString *)messageJSON { 199 | return [NSJSONSerialization JSONObjectWithData:[messageJSON dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil]; 200 | } 201 | 202 | - (void)_log:(NSString *)action json:(id)json { 203 | if (!logging) { return; } 204 | if (![json isKindOfClass:[NSString class]]) { 205 | json = [self _serializeMessage:json pretty:YES]; 206 | } 207 | if ([json length] > logMaxLength) { 208 | NSLog(@"WVJB %@: %@ [...]", action, [json substringToIndex:logMaxLength]); 209 | } else { 210 | NSLog(@"WVJB %@: %@", action, json); 211 | } 212 | } 213 | 214 | @end -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NSString * WebViewJavascriptBridge_js(); -------------------------------------------------------------------------------- /Pods/WebViewJavascriptBridge/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m: -------------------------------------------------------------------------------- 1 | // This file contains the source for the Javascript side of the 2 | // WebViewJavascriptBridge. It is plaintext, but converted to an NSString 3 | // via some preprocessor tricks. 4 | // 5 | // Previous implementations of WebViewJavascriptBridge loaded the javascript source 6 | // from a resource. This worked fine for app developers, but library developers who 7 | // included the bridge into their library, awkwardly had to ask consumers of their 8 | // library to include the resource, violating their encapsulation. By including the 9 | // Javascript as a string resource, the encapsulation of the library is maintained. 10 | 11 | #import "WebViewJavascriptBridge_JS.h" 12 | 13 | NSString * WebViewJavascriptBridge_js() { 14 | #define __wvjb_js_func__(x) #x 15 | 16 | // BEGIN preprocessorJSCode 17 | static NSString * preprocessorJSCode = @__wvjb_js_func__( 18 | ;(function() { 19 | if (window.WebViewJavascriptBridge) { 20 | return; 21 | } 22 | window.WebViewJavascriptBridge = { 23 | registerHandler: registerHandler, 24 | callHandler: callHandler, 25 | _fetchQueue: _fetchQueue, 26 | _handleMessageFromObjC: _handleMessageFromObjC 27 | }; 28 | 29 | var messagingIframe; 30 | var sendMessageQueue = []; 31 | var messageHandlers = {}; 32 | 33 | var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; 34 | var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'; 35 | 36 | var responseCallbacks = {}; 37 | var uniqueId = 1; 38 | 39 | function registerHandler(handlerName, handler) { 40 | messageHandlers[handlerName] = handler; 41 | } 42 | 43 | function callHandler(handlerName, data, responseCallback) { 44 | if (arguments.length == 2 && typeof data == 'function') { 45 | responseCallback = data; 46 | data = null; 47 | } 48 | _doSend({ handlerName:handlerName, data:data }, responseCallback); 49 | } 50 | 51 | function _doSend(message, responseCallback) { 52 | if (responseCallback) { 53 | var callbackId = 'cb_'+(uniqueId++)+'_'+new Date().getTime(); 54 | responseCallbacks[callbackId] = responseCallback; 55 | message['callbackId'] = callbackId; 56 | } 57 | sendMessageQueue.push(message); 58 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; 59 | } 60 | 61 | function _fetchQueue() { 62 | var messageQueueString = JSON.stringify(sendMessageQueue); 63 | sendMessageQueue = []; 64 | return messageQueueString; 65 | } 66 | 67 | function _dispatchMessageFromObjC(messageJSON) { 68 | setTimeout(function _timeoutDispatchMessageFromObjC() { 69 | var message = JSON.parse(messageJSON); 70 | var messageHandler; 71 | var responseCallback; 72 | 73 | if (message.responseId) { 74 | responseCallback = responseCallbacks[message.responseId]; 75 | if (!responseCallback) { 76 | return; 77 | } 78 | responseCallback(message.responseData); 79 | delete responseCallbacks[message.responseId]; 80 | } else { 81 | if (message.callbackId) { 82 | var callbackResponseId = message.callbackId; 83 | responseCallback = function(responseData) { 84 | _doSend({ responseId:callbackResponseId, responseData:responseData }); 85 | }; 86 | } 87 | 88 | var handler = messageHandlers[message.handlerName]; 89 | try { 90 | handler(message.data, responseCallback); 91 | } catch(exception) { 92 | console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception); 93 | } 94 | if (!handler) { 95 | console.log("WebViewJavascriptBridge: WARNING: no handler for message from ObjC:", message); 96 | } 97 | } 98 | }); 99 | } 100 | 101 | function _handleMessageFromObjC(messageJSON) { 102 | _dispatchMessageFromObjC(messageJSON); 103 | } 104 | 105 | messagingIframe = document.createElement('iframe'); 106 | messagingIframe.style.display = 'none'; 107 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; 108 | document.documentElement.appendChild(messagingIframe); 109 | 110 | setTimeout(_callWVJBCallbacks, 0); 111 | function _callWVJBCallbacks() { 112 | var callbacks = window.WVJBCallbacks; 113 | delete window.WVJBCallbacks; 114 | for (var i=0; i