├── .gitignore ├── NetworkByYala.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── DaZuo.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── DaZuo.xcuserdatad │ └── xcschemes │ ├── NetworkByYala.xcscheme │ └── xcschememanagement.plist ├── NetworkByYala.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── DaZuo.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── NetworkByYala ├── ApiViewController.h ├── ApiViewController.m ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── DoubanCell.h ├── DoubanCell.m ├── DoubanRequest.h ├── DoubanRequest.m ├── DoubanViewController.h ├── DoubanViewController.m ├── Info.plist ├── NetworkClient │ ├── DZBaseRequest.h │ ├── DZBaseRequest.m │ ├── DZCacheRequest.h │ ├── DZCacheRequest.m │ ├── DZRequest.h │ ├── DZRequestConfig.h │ ├── DZRequestManager.h │ ├── DZRequestManager.m │ ├── DZRequestTool.h │ └── DZRequestTool.m ├── Resources │ └── NetworkByYala-PCH.pch ├── ResultViewController.h ├── ResultViewController.m ├── images.jpeg ├── main.m └── meinv.jpeg ├── Podfile ├── Podfile.lock └── Pods ├── AFNetworking ├── AFNetworking │ ├── AFHTTPSessionManager.h │ ├── AFHTTPSessionManager.m │ ├── AFNetworkReachabilityManager.h │ ├── AFNetworkReachabilityManager.m │ ├── AFNetworking.h │ ├── AFSecurityPolicy.h │ ├── AFSecurityPolicy.m │ ├── AFURLRequestSerialization.h │ ├── AFURLRequestSerialization.m │ ├── AFURLResponseSerialization.h │ ├── AFURLResponseSerialization.m │ ├── AFURLSessionManager.h │ └── AFURLSessionManager.m ├── LICENSE ├── README.md └── UIKit+AFNetworking │ ├── AFAutoPurgingImageCache.h │ ├── AFAutoPurgingImageCache.m │ ├── AFImageDownloader.h │ ├── AFImageDownloader.m │ ├── AFNetworkActivityIndicatorManager.h │ ├── AFNetworkActivityIndicatorManager.m │ ├── UIActivityIndicatorView+AFNetworking.h │ ├── UIActivityIndicatorView+AFNetworking.m │ ├── UIButton+AFNetworking.h │ ├── UIButton+AFNetworking.m │ ├── UIImage+AFNetworking.h │ ├── UIImageView+AFNetworking.h │ ├── UIImageView+AFNetworking.m │ ├── UIKit+AFNetworking.h │ ├── UIProgressView+AFNetworking.h │ ├── UIProgressView+AFNetworking.m │ ├── UIRefreshControl+AFNetworking.h │ ├── UIRefreshControl+AFNetworking.m │ ├── UIWebView+AFNetworking.h │ └── UIWebView+AFNetworking.m ├── Headers ├── Private │ ├── AFNetworking │ │ ├── AFAutoPurgingImageCache.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFImageDownloader.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLSessionManager.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIImage+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ └── UIWebView+AFNetworking.h │ └── MJRefresh │ │ ├── MJRefresh.h │ │ ├── MJRefreshAutoFooter.h │ │ ├── MJRefreshAutoGifFooter.h │ │ ├── MJRefreshAutoNormalFooter.h │ │ ├── MJRefreshAutoStateFooter.h │ │ ├── MJRefreshBackFooter.h │ │ ├── MJRefreshBackGifFooter.h │ │ ├── MJRefreshBackNormalFooter.h │ │ ├── MJRefreshBackStateFooter.h │ │ ├── MJRefreshComponent.h │ │ ├── MJRefreshConst.h │ │ ├── MJRefreshFooter.h │ │ ├── MJRefreshGifHeader.h │ │ ├── MJRefreshHeader.h │ │ ├── MJRefreshNormalHeader.h │ │ ├── MJRefreshStateHeader.h │ │ ├── UIScrollView+MJExtension.h │ │ ├── UIScrollView+MJRefresh.h │ │ └── UIView+MJExtension.h └── Public │ ├── AFNetworking │ ├── AFAutoPurgingImageCache.h │ ├── AFHTTPSessionManager.h │ ├── AFImageDownloader.h │ ├── AFNetworkActivityIndicatorManager.h │ ├── AFNetworkReachabilityManager.h │ ├── AFNetworking.h │ ├── AFSecurityPolicy.h │ ├── AFURLRequestSerialization.h │ ├── AFURLResponseSerialization.h │ ├── AFURLSessionManager.h │ ├── UIActivityIndicatorView+AFNetworking.h │ ├── UIButton+AFNetworking.h │ ├── UIImage+AFNetworking.h │ ├── UIImageView+AFNetworking.h │ ├── UIKit+AFNetworking.h │ ├── UIProgressView+AFNetworking.h │ ├── UIRefreshControl+AFNetworking.h │ └── UIWebView+AFNetworking.h │ └── MJRefresh │ ├── MJRefresh.h │ ├── MJRefreshAutoFooter.h │ ├── MJRefreshAutoGifFooter.h │ ├── MJRefreshAutoNormalFooter.h │ ├── MJRefreshAutoStateFooter.h │ ├── MJRefreshBackFooter.h │ ├── MJRefreshBackGifFooter.h │ ├── MJRefreshBackNormalFooter.h │ ├── MJRefreshBackStateFooter.h │ ├── MJRefreshComponent.h │ ├── MJRefreshConst.h │ ├── MJRefreshFooter.h │ ├── MJRefreshGifHeader.h │ ├── MJRefreshHeader.h │ ├── MJRefreshNormalHeader.h │ ├── MJRefreshStateHeader.h │ ├── UIScrollView+MJExtension.h │ ├── UIScrollView+MJRefresh.h │ └── UIView+MJExtension.h ├── MJRefresh ├── LICENSE ├── MJRefresh │ ├── Base │ │ ├── MJRefreshAutoFooter.h │ │ ├── MJRefreshAutoFooter.m │ │ ├── MJRefreshBackFooter.h │ │ ├── MJRefreshBackFooter.m │ │ ├── MJRefreshComponent.h │ │ ├── MJRefreshComponent.m │ │ ├── MJRefreshFooter.h │ │ ├── MJRefreshFooter.m │ │ ├── MJRefreshHeader.h │ │ └── MJRefreshHeader.m │ ├── Custom │ │ ├── Footer │ │ │ ├── Auto │ │ │ │ ├── MJRefreshAutoGifFooter.h │ │ │ │ ├── MJRefreshAutoGifFooter.m │ │ │ │ ├── MJRefreshAutoNormalFooter.h │ │ │ │ ├── MJRefreshAutoNormalFooter.m │ │ │ │ ├── MJRefreshAutoStateFooter.h │ │ │ │ └── MJRefreshAutoStateFooter.m │ │ │ └── Back │ │ │ │ ├── MJRefreshBackGifFooter.h │ │ │ │ ├── MJRefreshBackGifFooter.m │ │ │ │ ├── MJRefreshBackNormalFooter.h │ │ │ │ ├── MJRefreshBackNormalFooter.m │ │ │ │ ├── MJRefreshBackStateFooter.h │ │ │ │ └── MJRefreshBackStateFooter.m │ │ └── Header │ │ │ ├── MJRefreshGifHeader.h │ │ │ ├── MJRefreshGifHeader.m │ │ │ ├── MJRefreshNormalHeader.h │ │ │ ├── MJRefreshNormalHeader.m │ │ │ ├── MJRefreshStateHeader.h │ │ │ └── MJRefreshStateHeader.m │ ├── MJRefresh.bundle │ │ └── arrow@2x.png │ ├── MJRefresh.h │ ├── MJRefreshConst.h │ ├── MJRefreshConst.m │ ├── UIScrollView+MJExtension.h │ ├── UIScrollView+MJExtension.m │ ├── UIScrollView+MJRefresh.h │ ├── UIScrollView+MJRefresh.m │ ├── UIView+MJExtension.h │ └── UIView+MJExtension.m └── README.md ├── Manifest.lock ├── Pods.xcodeproj ├── project.pbxproj └── xcuserdata │ └── DaZuo.xcuserdatad │ └── xcschemes │ ├── AFNetworking.xcscheme │ ├── Pods.xcscheme │ └── xcschememanagement.plist └── Target Support Files ├── AFNetworking ├── AFNetworking-dummy.m ├── AFNetworking-prefix.pch └── AFNetworking.xcconfig ├── MJRefresh ├── MJRefresh-dummy.m ├── MJRefresh-prefix.pch └── MJRefresh.xcconfig └── Pods ├── Pods-acknowledgements.markdown ├── Pods-acknowledgements.plist ├── Pods-dummy.m ├── Pods-frameworks.sh ├── Pods-resources.sh ├── Pods.debug.xcconfig └── Pods.release.xcconfig /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /NetworkByYala.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NetworkByYala.xcodeproj/project.xcworkspace/xcuserdata/DaZuo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wenbingzuo/NetworkByYala/a8287ae2a83aab4bd75ace4fc916ef2d35fa997e/NetworkByYala.xcodeproj/project.xcworkspace/xcuserdata/DaZuo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NetworkByYala.xcodeproj/xcuserdata/DaZuo.xcuserdatad/xcschemes/NetworkByYala.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 | -------------------------------------------------------------------------------- /NetworkByYala.xcodeproj/xcuserdata/DaZuo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NetworkByYala.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8D9FBE221C16EED30077A9B4 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /NetworkByYala.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NetworkByYala.xcworkspace/xcuserdata/DaZuo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wenbingzuo/NetworkByYala/a8287ae2a83aab4bd75ace4fc916ef2d35fa997e/NetworkByYala.xcworkspace/xcuserdata/DaZuo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NetworkByYala.xcworkspace/xcuserdata/DaZuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /NetworkByYala/ApiViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ApiViewController.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ApiViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /NetworkByYala/ApiViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ApiViewController.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "ApiViewController.h" 10 | #import "ResultViewController.h" 11 | #import "DoubanViewController.h" 12 | 13 | @interface ApiViewController () 14 | 15 | @property (weak, nonatomic) IBOutlet UIProgressView *progressView; 16 | 17 | @end 18 | 19 | @implementation ApiViewController 20 | 21 | - (IBAction)sendGetRequest:(id)sender { 22 | DZBaseRequest *request = [DZBaseRequest new]; 23 | request.requestBaseURL = @"https://api.douban.com"; 24 | request.requestURL = @"/v2/music/search"; 25 | request.requestParameters = @{@"q":@"周杰伦"}; 26 | [request startWithRequestSuccessBlock:^(DZBaseRequest *request) { 27 | [self handleResult:request.responseObject]; 28 | } failureBlock:^(DZBaseRequest *request) { 29 | NSString *error = request.error.localizedDescription; 30 | if ([request.error.domain isEqualToString:DZRequestOutOfNetwork]) { 31 | error = @"没有网络 %>_<% "; 32 | } 33 | [self handleResult:error]; 34 | }]; 35 | } 36 | 37 | - (IBAction)sendPostRequest:(id)sender { 38 | DZBaseRequest *request = [DZBaseRequest new]; 39 | request.requestURL = @"http://www.oschina.net/action/api/user_updaterelation"; 40 | request.requestMethod = DZRequestMethodPOST; 41 | request.requestSerializerType = DZRequestSerializerTypeForm; 42 | request.responseSerializerType = DZResponseSerializerTypeHTTP; 43 | request.requestParameters = @{@"uid":@"2544566", @"hisuid":@"1181793", @"newrelation":@"1"}; 44 | request.delegate = self; 45 | [request start]; 46 | } 47 | 48 | - (IBAction)sendUploadRequest:(id)sender { 49 | DZBaseRequest *request = [DZBaseRequest new]; 50 | request.requestBaseURL = @"http://www.oschina.net"; 51 | request.requestURL = @"/action/api/portrait_update"; 52 | request.requestMethod = DZRequestMethodPOST; 53 | request.responseSerializerType = DZResponseSerializerTypeHTTP; 54 | request.requestSerializerType = DZRequestSerializerTypeForm; 55 | request.requestParameters = @{@"uid":@"2544566"}; 56 | [request setUploadProgress:^(NSProgress *progress) { 57 | dispatch_async(dispatch_get_main_queue(), ^{ 58 | self.progressView.progress = progress.fractionCompleted; 59 | }); 60 | }]; 61 | request.delegate = self; 62 | [request setConstructionBodyBlock:^(id formData) { 63 | NSData *data = UIImageJPEGRepresentation([UIImage imageNamed:@"images.jpeg"], 1); 64 | [formData appendPartWithFileData:data name:@"portrait" fileName:@"645.jpeg" mimeType:@"image/jpeg"]; 65 | }]; 66 | [request start]; 67 | } 68 | 69 | - (void)handleResult:(id)result { 70 | UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 71 | ResultViewController *resultVC = [sb instantiateViewControllerWithIdentifier:@"ResultViewController"]; 72 | resultVC.result = result; 73 | [self.navigationController pushViewController:resultVC animated:YES]; 74 | } 75 | 76 | #pragma mark - DZRequestDelegate 77 | - (void)requestWillStart:(DZBaseRequest *)request { 78 | DZDebugLog(@"开始请求"); 79 | } 80 | 81 | - (void)requestDidSuccess:(DZBaseRequest *)request { 82 | id result = request.responseObject; 83 | if ([result isKindOfClass:[NSData class]]) { 84 | result = [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]; 85 | } 86 | [self handleResult:result]; 87 | } 88 | 89 | - (void)requestDidFailure:(DZBaseRequest *)request { 90 | [self handleResult:request.error.localizedDescription]; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /NetworkByYala/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/8/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /NetworkByYala/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/8/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | DZDebugLog(@"%@", NSHomeDirectory()); 21 | [[DZRequestManager shareManager] startNetworkStateMonitoring]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application { 26 | // 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. 27 | // 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. 28 | } 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // 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. 37 | } 38 | 39 | - (void)applicationDidBecomeActive:(UIApplication *)application { 40 | // 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. 41 | } 42 | 43 | - (void)applicationWillTerminate:(UIApplication *)application { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /NetworkByYala/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 | } -------------------------------------------------------------------------------- /NetworkByYala/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 | -------------------------------------------------------------------------------- /NetworkByYala/DoubanCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // DoubanCell.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DoubanCell : UITableViewCell 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *mainTitle; 14 | @end 15 | -------------------------------------------------------------------------------- /NetworkByYala/DoubanCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // DoubanCell.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DoubanCell.h" 10 | 11 | @implementation DoubanCell 12 | 13 | - (void)awakeFromNib { 14 | // Initialization code 15 | } 16 | 17 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 18 | [super setSelected:selected animated:animated]; 19 | 20 | // Configure the view for the selected state 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /NetworkByYala/DoubanRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // DoubanRequest.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DZCacheRequest.h" 10 | 11 | @interface DoubanRequest : DZCacheRequest 12 | 13 | @property (nonatomic, assign) BOOL switching; 14 | 15 | 16 | - (void)startNotToggleWillStartTag; 17 | 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /NetworkByYala/DoubanRequest.m: -------------------------------------------------------------------------------- 1 | // 2 | // DoubanRequest.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DoubanRequest.h" 10 | 11 | @implementation DoubanRequest 12 | 13 | - (void)startNotToggleWillStartTag { 14 | [[DZRequestManager shareManager] startRequest:self]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /NetworkByYala/DoubanViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DoubanViewController.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DoubanViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /NetworkByYala/DoubanViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DoubanViewController.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DoubanViewController.h" 10 | #import 11 | #import "DoubanRequest.h" 12 | #import "DoubanCell.h" 13 | 14 | @interface DoubanViewController () 15 | 16 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 17 | 18 | @property (nonatomic, strong) DoubanRequest *request; 19 | 20 | @property (nonatomic, strong) NSArray *songs; 21 | 22 | @end 23 | 24 | @implementation DoubanViewController 25 | 26 | - (DoubanRequest *)request { 27 | if (!_request) { 28 | _request = [DoubanRequest new]; 29 | _request.requestBaseURL = @"http://api.douban.com/"; 30 | _request.requestURL = @"/v2/music/search"; 31 | _request.requestParameters = @{@"q":@"周杰伦"}; 32 | _request.cacheTimeInterval = 10; 33 | _request.switching = NO; 34 | __weak typeof(self) weakSelf = self; 35 | [_request setRequestSuccessBlock:^(DZBaseRequest *request) { 36 | NSArray *musics = request.responseObject[@"musics"]; 37 | NSMutableArray *data = [NSMutableArray array]; 38 | for (NSDictionary *dic in musics) { 39 | [data addObject:dic[@"title"]]; 40 | } 41 | weakSelf.songs = data; 42 | [weakSelf.tableView reloadData]; 43 | [weakSelf.tableView.mj_header endRefreshing]; 44 | }]; 45 | [_request setRequestFailureBlock:^(DZBaseRequest *request) { 46 | [weakSelf.tableView.mj_header endRefreshing]; 47 | }]; 48 | } 49 | return _request; 50 | } 51 | 52 | - (void)viewDidLoad { 53 | [super viewDidLoad]; 54 | __weak typeof(self) weakSelf = self; 55 | self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ 56 | [weakSelf loadData]; 57 | }]; 58 | } 59 | 60 | - (void)loadData { 61 | if (!self.request.switching) { 62 | [self.request startNotToggleWillStartTag]; 63 | } 64 | self.request.switching = NO; 65 | } 66 | 67 | - (void)viewWillAppear:(BOOL)animated { 68 | [super viewWillAppear:animated]; 69 | __weak typeof(self) weakSelf = self; 70 | [self.request setRequestStartBlock:^(DZBaseRequest *request) { 71 | weakSelf.request.switching = YES; 72 | [weakSelf.tableView.mj_header beginRefreshing]; 73 | }]; 74 | [self.request start]; 75 | } 76 | 77 | #pragma mark - UITableViewDataSource 78 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 79 | return 1; 80 | } 81 | 82 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 83 | return self.songs.count; 84 | } 85 | 86 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 87 | static NSString *kDoubanCellIdentifier = @"DoubanCellIdentifier"; 88 | DoubanCell *cell = [tableView dequeueReusableCellWithIdentifier:kDoubanCellIdentifier forIndexPath:indexPath]; 89 | 90 | cell.mainTitle.text = self.songs[indexPath.row]; 91 | return cell; 92 | } 93 | 94 | - (void)dealloc { 95 | DZDebugLog(@"%@ dealloc", [self class]); 96 | } 97 | @end 98 | -------------------------------------------------------------------------------- /NetworkByYala/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 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZBaseRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // DZBaseRequest.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/11/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DZRequestConfig.h" 11 | 12 | /** 13 | * HTTP request method 14 | */ 15 | typedef NS_ENUM(NSInteger, DZRequestMethod) { 16 | 17 | DZRequestMethodGET = 0, 18 | 19 | DZRequestMethodPOST, 20 | 21 | DZRequestMethodPUT, 22 | 23 | DZRequestMethodDELETE 24 | }; 25 | 26 | /** 27 | * request serializer type 28 | */ 29 | typedef NS_ENUM(NSInteger, DZRequestSerializerType) { 30 | /** 31 | * content-type: application/x-www-form-urlencoded not json type 32 | */ 33 | DZRequestSerializerTypeForm = 0, 34 | /** 35 | * content-type: application/json 36 | */ 37 | DZRequestSerializerTypeJSON 38 | }; 39 | 40 | /** 41 | * response serializer type 42 | */ 43 | typedef NS_ENUM(NSInteger, DZResponseSerializerType) { 44 | /** 45 | * get the origin data from server 46 | */ 47 | DZResponseSerializerTypeHTTP= 0, 48 | /** 49 | * JSON from server 50 | */ 51 | DZResponseSerializerTypeJSON 52 | }; 53 | 54 | @class DZBaseRequest; 55 | @protocol DZRequestDelegate 56 | 57 | @optional 58 | - (void)requestWillStart:(DZBaseRequest *)request; 59 | - (void)requestDidSuccess:(DZBaseRequest *)request; 60 | - (void)requestDidFailure:(DZBaseRequest *)request; 61 | 62 | @end 63 | 64 | @interface DZBaseRequest : NSObject 65 | 66 | @property (nonatomic, strong) NSURLSessionDataTask *task; 67 | 68 | //------------------处理返回值的方式---------------------- 69 | // block 70 | // `requestStartBlock`should not call `start` 71 | @property (nonatomic, copy) void(^requestStartBlock)(DZBaseRequest *); 72 | 73 | @property (nonatomic, copy) void (^uploadProgress)(NSProgress *progress); 74 | 75 | @property (nonatomic, copy) void(^requestSuccessBlock)(DZBaseRequest *); 76 | @property (nonatomic, strong) id responseObject; 77 | 78 | @property (nonatomic, copy) void(^requestFailureBlock)(DZBaseRequest *); 79 | @property (nonatomic, strong) NSError *error; 80 | 81 | // delegate 82 | @property (nonatomic, weak) id delegate; 83 | 84 | //----------------------------------------------------- 85 | 86 | /** 87 | * custom properties 88 | * 89 | */ 90 | // default is `DZ_ENVIRONMENT`, `DZ_ENVIRONMENT` configured in config.h, or set special value 91 | @property (nonatomic, copy) NSString *requestBaseURL; 92 | 93 | // default is `` 94 | @property (nonatomic, copy) NSString *requestURL; 95 | 96 | // default is 20 97 | @property (nonatomic, assign) NSTimeInterval requestTimeoutInterval; 98 | 99 | // default is `DZRequestMethodGET` 100 | @property (nonatomic, assign) DZRequestMethod requestMethod; 101 | 102 | // default is nil 103 | @property (nonatomic, strong) id requestParameters; 104 | 105 | // default is `DZRequestSerializerTypeJSON` 106 | @property (nonatomic, assign) DZRequestSerializerType requestSerializerType; 107 | 108 | // default is `DZResponseSerializerTypeJSON` 109 | @property (nonatomic, assign) DZResponseSerializerType responseSerializerType; 110 | 111 | // default is YES 112 | @property (nonatomic, assign) BOOL useCookies; 113 | 114 | // POST upload request such as images, default nil 115 | @property (nonatomic, copy) void (^constructionBodyBlock)(idformData); 116 | 117 | /** 118 | * if overwrite, call super or call `startRequest:` in `DZRequestManager`. `start` method invoke the will start tag and begin the request 119 | */ 120 | - (void)start; 121 | - (void)startWithRequestSuccessBlock:(void(^)(DZBaseRequest *request))success failureBlock:(void(^)(DZBaseRequest *request))failure; 122 | - (void)stop; 123 | 124 | // toggle when requst start 125 | - (void)requestWillStart; 126 | 127 | // toggle when request success 128 | - (void)requestCompleteSuccess; 129 | 130 | // toggle when request failure 131 | - (void)requestCompleteFailure; 132 | 133 | // set `requestStartBlock`, `requestSuccessBlock`, `requestFailureBlock` to nil 134 | //- (void)clearRequestBlock; 135 | 136 | 137 | @end 138 | 139 | /** 140 | * 通知 141 | */ 142 | FOUNDATION_EXPORT NSString * const DZRequestWillStartNotification; 143 | FOUNDATION_EXPORT NSString * const DZRequestDidFinishNotification; 144 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZBaseRequest.m: -------------------------------------------------------------------------------- 1 | // 2 | // DZBaseRequest.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/11/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DZBaseRequest.h" 10 | #import "DZRequestConfig.h" 11 | #import "DZRequestManager.h" 12 | 13 | NSString * const DZRequestWillStartNotification = @"com.forever.request.start"; 14 | NSString * const DZRequestDidFinishNotification = @"com.forever.request.finish"; 15 | 16 | @interface DZBaseRequest () 17 | 18 | //@property (nonatomic, assign) BOOL requesting; 19 | 20 | @end 21 | 22 | @implementation DZBaseRequest 23 | 24 | - (instancetype)init { 25 | self = [super init]; 26 | if (self) { 27 | self.requestBaseURL = DZ_ENVIRONMENT; 28 | self.requestURL = @""; 29 | self.requestTimeoutInterval = 20; 30 | self.requestMethod = DZRequestMethodGET; 31 | self.requestParameters = nil; 32 | self.requestSerializerType = DZRequestSerializerTypeJSON; 33 | self.responseSerializerType = DZResponseSerializerTypeJSON; 34 | self.useCookies = YES; 35 | self.constructionBodyBlock = nil; 36 | } 37 | return self; 38 | } 39 | 40 | - (void)requestWillStartTag { 41 | if (self.requestStartBlock) { 42 | self.requestStartBlock(self); 43 | } 44 | 45 | if ([self.delegate respondsToSelector:@selector(requestWillStart:)]) { 46 | [self.delegate requestWillStart:self]; 47 | } 48 | 49 | dispatch_async(dispatch_get_main_queue(), ^{ 50 | [[NSNotificationCenter defaultCenter] postNotificationName:DZRequestWillStartNotification object:self]; 51 | }); 52 | 53 | [self requestWillStart]; 54 | } 55 | 56 | - (void)start { 57 | [self requestWillStartTag]; 58 | [[DZRequestManager shareManager] startRequest:self]; 59 | } 60 | 61 | - (void)startWithRequestSuccessBlock:(void(^)(DZBaseRequest *request))success failureBlock:(void(^)(DZBaseRequest *request))failure { 62 | [self setRequestSuccessBlock:success failureBlock:failure]; 63 | [self start]; 64 | } 65 | 66 | - (void)setRequestSuccessBlock:(void(^)(DZBaseRequest *request))success failureBlock:(void(^)(DZBaseRequest *request))failure { 67 | self.requestSuccessBlock = success; 68 | self.requestFailureBlock = failure; 69 | } 70 | 71 | - (void)stop { 72 | [[DZRequestManager shareManager] cancelRequest:self]; 73 | } 74 | 75 | - (void)requestWillStart { 76 | 77 | } 78 | 79 | - (void)requestCompleteSuccess { 80 | 81 | } 82 | 83 | - (void)requestCompleteFailure { 84 | 85 | } 86 | 87 | //- (void)clearRequestBlock { 88 | // self.requestStartBlock = nil; 89 | // self.requestSuccessBlock = nil; 90 | // self.requestFailureBlock = nil; 91 | // self.uploadProgress = nil; 92 | //} 93 | 94 | - (void)dealloc { 95 | DZDebugLog(@"%@ dealloc", [self class]); 96 | } 97 | @end 98 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZCacheRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // DZCacheRequest.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/13/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DZBaseRequest.h" 10 | 11 | @interface DZCacheRequest : DZBaseRequest 12 | 13 | // flag - whether load data from cache. default `YES` 14 | @property (nonatomic, assign) BOOL useCache; 15 | 16 | // cache data 17 | @property (nonatomic, strong, readonly) id cacheData; 18 | 19 | // cache time interval, origin `60` second 20 | @property (nonatomic, assign) NSTimeInterval cacheTimeInterval; 21 | 22 | // start ignore cache. `[super start]`will toggle 23 | - (void)startWithoutCache; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZCacheRequest.m: -------------------------------------------------------------------------------- 1 | // 2 | // DZCacheRequest.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/13/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DZCacheRequest.h" 10 | 11 | @interface DZCacheRequest () 12 | 13 | @property (nonatomic, strong) id cacheData; 14 | 15 | @end 16 | 17 | @implementation DZCacheRequest 18 | 19 | - (instancetype)init { 20 | self = [super init]; 21 | if (self) { 22 | self.useCache = YES; 23 | self.cacheTimeInterval = 60; 24 | } 25 | return self; 26 | } 27 | 28 | - (id)cacheData { 29 | if (!_cacheData) { 30 | NSFileManager *fileManager = [NSFileManager defaultManager]; 31 | NSString *path = [self cacheFilePath]; 32 | if ([fileManager fileExistsAtPath:path]) { 33 | _cacheData = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; 34 | } 35 | } 36 | return _cacheData; 37 | } 38 | 39 | - (void)createPath:(NSString *)path { 40 | NSFileManager *fileManager = [NSFileManager defaultManager]; 41 | NSError *error = nil; 42 | [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]; 43 | if (error) { 44 | DZDebugLog(@"error in creating cache folder:%@", error.localizedDescription); 45 | } else { 46 | [DZRequestTool addDoNotBackupAttribute:path]; 47 | } 48 | } 49 | 50 | - (void)checkPath:(NSString *)path { 51 | NSFileManager *fileManager = [NSFileManager defaultManager]; 52 | BOOL isDir; 53 | if (![fileManager fileExistsAtPath:path isDirectory:&isDir]) { 54 | [self createPath:path]; 55 | } else { 56 | if (!isDir) { 57 | NSError *error = nil; 58 | [fileManager removeItemAtPath:path error:&error]; 59 | if (error) { 60 | DZDebugLog(@"error in removing file:%@", error.localizedDescription); 61 | } 62 | [self createPath:path]; 63 | } 64 | } 65 | } 66 | 67 | - (NSString *)cacheBasePath { 68 | NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; 69 | NSString *path = [cachePath stringByAppendingPathComponent:@"DZRequestCache"]; 70 | 71 | [self checkPath:path]; 72 | 73 | return path; 74 | } 75 | 76 | - (NSString *)cacheFileName { 77 | DZRequestMethod method = [self requestMethod]; 78 | 79 | NSString *baseURL = [self requestBaseURL]; 80 | NSString *requestURL = [self requestURL]; 81 | 82 | NSString *fileName = [NSString stringWithFormat:@"method-%d_host-%@_url:%@", method, baseURL, requestURL]; 83 | 84 | return [DZRequestTool md5String:fileName]; 85 | } 86 | 87 | - (NSString *)cacheFilePath { 88 | NSString *cacheBathPath = [self cacheBasePath]; 89 | NSString *cacheFileName = [self cacheFileName]; 90 | NSString *path = [cacheBathPath stringByAppendingPathComponent:cacheFileName]; 91 | return path; 92 | } 93 | 94 | - (NSInteger)cacheFileTimeInterval:(NSString *)path { 95 | NSFileManager *fileManager = [NSFileManager defaultManager]; 96 | NSError *error = nil; 97 | NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:&error]; 98 | if (error) { 99 | return -1; 100 | } 101 | NSTimeInterval timeInterval = -[[attributes fileModificationDate] timeIntervalSinceNow]; 102 | return timeInterval; 103 | } 104 | 105 | - (void)start { 106 | if (!self.useCache) { 107 | [super start]; 108 | return; 109 | } 110 | 111 | NSFileManager *fileManager = [NSFileManager defaultManager]; 112 | if (![fileManager fileExistsAtPath:[self cacheFilePath]]) { 113 | [super start]; 114 | return; 115 | } 116 | 117 | 118 | NSTimeInterval fileTimeInterval = [self cacheFileTimeInterval:[self cacheFilePath]]; 119 | NSTimeInterval cacheTimeInterval = self.cacheTimeInterval; 120 | if (cacheTimeInterval <= 0 || cacheTimeInterval < fileTimeInterval) { 121 | [super start]; 122 | return; 123 | } 124 | 125 | [self requestDidFinishTag]; 126 | } 127 | 128 | - (void)startWithoutCache { 129 | [super start]; 130 | 131 | 132 | } 133 | 134 | - (void)requestDidFinishTag { 135 | self.responseObject = self.cacheData; 136 | 137 | if (self.error) { 138 | if (self.requestFailureBlock) { 139 | self.requestFailureBlock(self); 140 | } 141 | 142 | if ([self.delegate respondsToSelector:@selector(requestDidFailure:)]) { 143 | [self.delegate requestDidFailure:self]; 144 | } 145 | } else { 146 | if (self.requestSuccessBlock) { 147 | self.requestSuccessBlock(self); 148 | } 149 | 150 | if ([self.delegate respondsToSelector:@selector(requestDidSuccess:)]) { 151 | [self.delegate requestDidSuccess:self]; 152 | } 153 | } 154 | // [self clearRequestBlock]; 155 | 156 | dispatch_async(dispatch_get_main_queue(), ^{ 157 | [[NSNotificationCenter defaultCenter] postNotificationName:DZRequestDidFinishNotification object:self]; 158 | }); 159 | 160 | } 161 | 162 | - (void)saveData:(id)responseObject { 163 | if (responseObject) { 164 | [NSKeyedArchiver archiveRootObject:responseObject toFile:[self cacheFilePath]]; 165 | } 166 | } 167 | 168 | - (void)requestCompleteSuccess { 169 | [super requestCompleteSuccess]; 170 | [self saveData:self.responseObject]; 171 | } 172 | 173 | @end 174 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // DZRequest.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/11/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #ifndef DZRequest_h 10 | #define DZRequest_h 11 | 12 | #import "DZBaseRequest.h" 13 | #import "DZCacheRequest.h" 14 | #import "DZRequestManager.h" 15 | 16 | #endif /* DZRequest_h */ 17 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZRequestConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // DZRequestConfig.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/11/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #ifndef DZRequestConfig_h 10 | #define DZRequestConfig_h 11 | 12 | #import 13 | #import "DZRequestTool.h" 14 | #import 15 | 16 | /** 17 | * 基类URL的定义 18 | */ 19 | #define DZ_ENVIRONMENT_TEST 0 20 | #define DZ_ENVIRONMENT_DEVELOPMENT 1 21 | 22 | #define DZ_ENVIRONMENT DZ_ENVIRONMENT_TEST 23 | 24 | #if DZ_ENVIRONMENT == DZ_ENVIRONMENT_TEST 25 | #define DZ_BASE_URL @"TEST_API" 26 | #elif DZ_ENVIRONMENT == DZ_ENVIRONMENT_DEVELOPMENT 27 | #define DZ_BASE_URL @"DEVELOPMENT_API" 28 | #else 29 | #define DZ_BASE_URL @"NO_API" 30 | #endif 31 | 32 | 33 | #ifdef DEBUG 34 | #define DZDebugLog(...) NSLog(__VA_ARGS__) 35 | #define DZDebugMethod() NSLog(@"%s", __func__) 36 | #define DZDebugError() NSLog(@"Error at %s Line:%d", __func__, __LINE__) 37 | #else 38 | #define DZDebugLog(...) 39 | #define DZDebugMethod() 40 | #define DZDebugError() 41 | #endif 42 | 43 | 44 | #endif /* DZRequestConfig_h */ 45 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZRequestManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // DZRequestManager.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/11/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DZBaseRequest.h" 11 | #import "DZRequestTool.h" 12 | 13 | typedef NS_ENUM(NSInteger, DZRequestReachabilityStatus) { 14 | DZRequestReachabilityStatusUnknow = 0, 15 | DZRequestReachabilityStatusNotReachable, 16 | DZRequestReachabilityStatusViaWWAN, 17 | DZRequestReachabilityStatusViaWiFi 18 | }; 19 | 20 | @interface DZRequestManager : NSObject 21 | 22 | + (instancetype)shareManager; 23 | 24 | // default 5 25 | @property (nonatomic, assign) NSInteger maxConcurrentRequestCount; 26 | 27 | @property (nonatomic, assign, readonly) DZRequestReachabilityStatus reachabilityStatus; 28 | 29 | - (void)startRequest:(DZBaseRequest *)request; 30 | - (void)cancelRequest:(DZBaseRequest *)request; 31 | - (void)cancelAllRequests; 32 | 33 | // start monitor network status 34 | - (void)startNetworkStateMonitoring; 35 | 36 | @end 37 | 38 | FOUNDATION_EXPORT NSString * const DZRequestOutOfNetwork; -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZRequestTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // DZRequestTool.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/12/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DZRequestConfig.h" 11 | 12 | @interface DZRequestTool : NSObject 13 | 14 | + (BOOL)validateUrl:(NSString *)url; 15 | 16 | + (NSString *)md5String:(NSString *)string; 17 | 18 | + (void)addDoNotBackupAttribute:(NSString *)path; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /NetworkByYala/NetworkClient/DZRequestTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // DZRequestTool.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/12/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "DZRequestTool.h" 10 | #import 11 | 12 | @implementation DZRequestTool 13 | 14 | + (BOOL)validateUrl:(NSString *)url { 15 | NSString *urlRegEx = @"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+"; 16 | NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx]; 17 | return [urlTest evaluateWithObject:url]; 18 | } 19 | 20 | + (NSString *)md5String:(NSString *)string { 21 | if (string.length <= 0) { 22 | return nil; 23 | } 24 | 25 | const char *value = [string UTF8String]; 26 | unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH]; 27 | CC_MD5(value, (CC_LONG)strlen(value), outputBuffer); 28 | 29 | NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; 30 | for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){ 31 | [outputString appendFormat:@"%02x",outputBuffer[count]]; 32 | } 33 | 34 | return outputString; 35 | } 36 | 37 | + (void)addDoNotBackupAttribute:(NSString *)path { 38 | NSURL *url = [NSURL fileURLWithPath:path]; 39 | NSError *error = nil; 40 | [url setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:&error]; 41 | if (error) { 42 | DZDebugLog(@"error in set back up attribute: %@", error.localizedDescription); 43 | } 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /NetworkByYala/Resources/NetworkByYala-PCH.pch: -------------------------------------------------------------------------------- 1 | // 2 | // NetworkByYala-PCH.pch 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/8/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #ifndef NetworkByYala_PCH_pch 10 | #define NetworkByYala_PCH_pch 11 | 12 | #import "DZRequest.h" 13 | 14 | 15 | #endif /* NetworkByYala_PCH_pch */ 16 | -------------------------------------------------------------------------------- /NetworkByYala/ResultViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ResultViewController.h 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ResultViewController : UIViewController 12 | 13 | @property (nonatomic, strong) id result; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /NetworkByYala/ResultViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ResultViewController.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/14/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import "ResultViewController.h" 10 | 11 | @interface ResultViewController () 12 | 13 | @property (weak, nonatomic) IBOutlet UITextView *textView; 14 | @end 15 | 16 | @implementation ResultViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | self.textView.text = [NSString stringWithFormat:@"%@", self.result]; 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | /* 29 | #pragma mark - Navigation 30 | 31 | // In a storyboard-based application, you will often want to do a little preparation before navigation 32 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 33 | // Get the new view controller using [segue destinationViewController]. 34 | // Pass the selected object to the new view controller. 35 | } 36 | */ 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /NetworkByYala/images.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wenbingzuo/NetworkByYala/a8287ae2a83aab4bd75ace4fc916ef2d35fa997e/NetworkByYala/images.jpeg -------------------------------------------------------------------------------- /NetworkByYala/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NetworkByYala 4 | // 5 | // Created by 文兵 左 on 12/8/15. 6 | // Copyright © 2015 文兵 左. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NetworkByYala/meinv.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wenbingzuo/NetworkByYala/a8287ae2a83aab4bd75ace4fc916ef2d35fa997e/NetworkByYala/meinv.jpeg -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | platform :ios, '7.0' 3 | 4 | pod 'AFNetworking', '~> 3.0.1' 5 | pod 'MJRefresh' -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.0.1): 3 | - AFNetworking/NSURLSession (= 3.0.1) 4 | - AFNetworking/Reachability (= 3.0.1) 5 | - AFNetworking/Security (= 3.0.1) 6 | - AFNetworking/Serialization (= 3.0.1) 7 | - AFNetworking/UIKit (= 3.0.1) 8 | - AFNetworking/NSURLSession (3.0.1): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.0.1) 13 | - AFNetworking/Security (3.0.1) 14 | - AFNetworking/Serialization (3.0.1) 15 | - AFNetworking/UIKit (3.0.1): 16 | - AFNetworking/NSURLSession 17 | - MJRefresh (3.0.7) 18 | 19 | DEPENDENCIES: 20 | - AFNetworking (~> 3.0.1) 21 | - MJRefresh 22 | 23 | SPEC CHECKSUMS: 24 | AFNetworking: 20d8749e03e45f1e5c046ad0b647e0b07bcdd91f 25 | MJRefresh: f3e1228ec3d38c7ba5208d58032631a52f39f495 26 | 27 | COCOAPODS: 0.39.0 28 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | #import 26 | 27 | #ifndef _AFNETWORKING_ 28 | #define _AFNETWORKING_ 29 | 30 | #import "AFURLRequestSerialization.h" 31 | #import "AFURLResponseSerialization.h" 32 | #import "AFSecurityPolicy.h" 33 | 34 | #if !TARGET_OS_WATCH 35 | #import "AFNetworkReachabilityManager.h" 36 | #endif 37 | 38 | #import "AFURLSessionManager.h" 39 | #import "AFHTTPSessionManager.h" 40 | 41 | #endif /* _AFNETWORKING_ */ 42 | -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 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 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all 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 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. 34 | 35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: 36 | 37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 38 | 39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 40 | 41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 43 | */ 44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") 45 | @interface AFNetworkActivityIndicatorManager : NSObject 46 | 47 | /** 48 | A Boolean value indicating whether the manager is enabled. 49 | 50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 51 | */ 52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 53 | 54 | /** 55 | A Boolean value indicating whether the network activity indicator manager is currently active. 56 | */ 57 | @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 58 | 59 | /** 60 | A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. 61 | 62 | Apple's HIG describes the following: 63 | 64 | > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. 65 | 66 | */ 67 | @property (nonatomic, assign) NSTimeInterval activationDelay; 68 | 69 | /** 70 | A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. 71 | */ 72 | 73 | @property (nonatomic, assign) NSTimeInterval completionDelay; 74 | 75 | /** 76 | Returns the shared network activity indicator manager object for the system. 77 | 78 | @return The systemwide network activity indicator manager. 79 | */ 80 | + (instancetype)sharedManager; 81 | 82 | /** 83 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 84 | */ 85 | - (void)incrementActivityCount; 86 | 87 | /** 88 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 89 | */ 90 | - (void)decrementActivityCount; 91 | 92 | /** 93 | Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. 94 | 95 | @param block A block to be executed when the network activity indicator status changes. 96 | */ 97 | - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; 98 | 99 | @end 100 | 101 | NS_ASSUME_NONNULL_END 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | /** 31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. 32 | */ 33 | @interface UIActivityIndicatorView (AFNetworking) 34 | 35 | ///---------------------------------- 36 | /// @name Animating for Session Tasks 37 | ///---------------------------------- 38 | 39 | /** 40 | Binds the animating state to the state of the specified task. 41 | 42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 43 | */ 44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; 45 | 46 | @end 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIActivityIndicatorView+AFNetworking.h" 23 | #import 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import "AFURLSessionManager.h" 28 | 29 | @interface AFActivityIndicatorViewNotificationObserver : NSObject 30 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; 31 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; 32 | 33 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 34 | 35 | @end 36 | 37 | @implementation UIActivityIndicatorView (AFNetworking) 38 | 39 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { 40 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 41 | if (notificationObserver == nil) { 42 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; 43 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | return notificationObserver; 46 | } 47 | 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 49 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; 50 | } 51 | 52 | @end 53 | 54 | @implementation AFActivityIndicatorViewNotificationObserver 55 | 56 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 57 | { 58 | self = [super init]; 59 | if (self) { 60 | _activityIndicatorView = activityIndicatorView; 61 | } 62 | return self; 63 | } 64 | 65 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 66 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 67 | 68 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 71 | 72 | if (task) { 73 | if (task.state != NSURLSessionTaskStateCompleted) { 74 | 75 | #pragma clang diagnostic push 76 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 77 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 78 | if (task.state == NSURLSessionTaskStateRunning) { 79 | [self.activityIndicatorView startAnimating]; 80 | } else { 81 | [self.activityIndicatorView stopAnimating]; 82 | } 83 | #pragma clang diagnostic pop 84 | 85 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 86 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 87 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 88 | } 89 | } 90 | } 91 | 92 | #pragma mark - 93 | 94 | - (void)af_startAnimating { 95 | dispatch_async(dispatch_get_main_queue(), ^{ 96 | #pragma clang diagnostic push 97 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 98 | [self.activityIndicatorView startAnimating]; 99 | #pragma clang diagnostic pop 100 | }); 101 | } 102 | 103 | - (void)af_stopAnimating { 104 | dispatch_async(dispatch_get_main_queue(), ^{ 105 | #pragma clang diagnostic push 106 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 107 | [self.activityIndicatorView stopAnimating]; 108 | #pragma clang diagnostic pop 109 | }); 110 | } 111 | 112 | #pragma mark - 113 | 114 | - (void)dealloc { 115 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 116 | 117 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 118 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 119 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 120 | } 121 | 122 | @end 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AFNetworking.h 3 | // 4 | // 5 | // Created by Paulo Ferreira on 08/07/15. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import 28 | 29 | @interface UIImage (AFNetworking) 30 | 31 | + (UIImage*) safeImageWithData:(NSData*)data; 32 | 33 | @end 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFImageDownloader; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. 36 | */ 37 | @interface UIImageView (AFNetworking) 38 | 39 | ///------------------------------------ 40 | /// @name Accessing the Image Downloader 41 | ///------------------------------------ 42 | 43 | /** 44 | Set the shared image downloader used to download images. 45 | 46 | @param imageDownloader The shared image downloader used to download images. 47 | */ 48 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; 49 | 50 | /** 51 | The shared image downloader used to download images. 52 | */ 53 | + (AFImageDownloader *)sharedImageDownloader; 54 | 55 | ///-------------------- 56 | /// @name Setting Image 57 | ///-------------------- 58 | 59 | /** 60 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 61 | 62 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 63 | 64 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 65 | 66 | @param url The URL used for the image request. 67 | */ 68 | - (void)setImageWithURL:(NSURL *)url; 69 | 70 | /** 71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 72 | 73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 74 | 75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 76 | 77 | @param url The URL used for the image request. 78 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 79 | */ 80 | - (void)setImageWithURL:(NSURL *)url 81 | placeholderImage:(nullable UIImage *)placeholderImage; 82 | 83 | /** 84 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 85 | 86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 87 | 88 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. 89 | 90 | @param urlRequest The URL request used for the image request. 91 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 92 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 93 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. 94 | */ 95 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 96 | placeholderImage:(nullable UIImage *)placeholderImage 97 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success 98 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 99 | 100 | /** 101 | Cancels any executing image operation for the receiver, if one exists. 102 | */ 103 | - (void)cancelImageDownloadTask; 104 | 105 | @end 106 | 107 | NS_ASSUME_NONNULL_END 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #if TARGET_OS_IOS || TARGET_OS_TV 24 | #import 25 | 26 | #ifndef _UIKIT_AFNETWORKING_ 27 | #define _UIKIT_AFNETWORKING_ 28 | 29 | #if TARGET_OS_IOS 30 | #import "AFAutoPurgingImageCache.h" 31 | #import "AFImageDownloader.h" 32 | #import "AFNetworkActivityIndicatorManager.h" 33 | #import "UIRefreshControl+AFNetworking.h" 34 | #import "UIWebView+AFNetworking.h" 35 | #endif 36 | 37 | #import "UIActivityIndicatorView+AFNetworking.h" 38 | #import "UIButton+AFNetworking.h" 39 | #import "UIImageView+AFNetworking.h" 40 | #import "UIProgressView+AFNetworking.h" 41 | #endif /* _UIKIT_AFNETWORKING_ */ 42 | #endif 43 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 49 | animated:(BOOL)animated; 50 | 51 | /** 52 | Binds the progress to the download progress of the specified session task. 53 | 54 | @param task The session task. 55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 56 | */ 57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 58 | animated:(BOOL)animated; 59 | 60 | @end 61 | 62 | NS_ASSUME_NONNULL_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIProgressView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; 31 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; 32 | 33 | #pragma mark - 34 | 35 | @implementation UIProgressView (AFNetworking) 36 | 37 | - (BOOL)af_uploadProgressAnimated { 38 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; 39 | } 40 | 41 | - (void)af_setUploadProgressAnimated:(BOOL)animated { 42 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 43 | } 44 | 45 | - (BOOL)af_downloadProgressAnimated { 46 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; 47 | } 48 | 49 | - (void)af_setDownloadProgressAnimated:(BOOL)animated { 50 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 51 | } 52 | 53 | #pragma mark - 54 | 55 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 56 | animated:(BOOL)animated 57 | { 58 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 59 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 60 | 61 | [self af_setUploadProgressAnimated:animated]; 62 | } 63 | 64 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 65 | animated:(BOOL)animated 66 | { 67 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 68 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 69 | 70 | [self af_setDownloadProgressAnimated:animated]; 71 | } 72 | 73 | #pragma mark - NSKeyValueObserving 74 | 75 | - (void)observeValueForKeyPath:(NSString *)keyPath 76 | ofObject:(id)object 77 | change:(__unused NSDictionary *)change 78 | context:(void *)context 79 | { 80 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { 81 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { 82 | if ([object countOfBytesExpectedToSend] > 0) { 83 | dispatch_async(dispatch_get_main_queue(), ^{ 84 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; 85 | }); 86 | } 87 | } 88 | 89 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { 90 | if ([object countOfBytesExpectedToReceive] > 0) { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; 93 | }); 94 | } 95 | } 96 | 97 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { 98 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { 99 | @try { 100 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; 101 | 102 | if (context == AFTaskCountOfBytesSentContext) { 103 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; 104 | } 105 | 106 | if (context == AFTaskCountOfBytesReceivedContext) { 107 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; 108 | } 109 | } 110 | @catch (NSException * __unused exception) {} 111 | } 112 | } 113 | } 114 | } 115 | 116 | @end 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if TARGET_OS_IOS 28 | 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIRefreshControl+AFNetworking.h" 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | @interface AFRefreshControlNotificationObserver : NSObject 31 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; 32 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; 33 | 34 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 35 | 36 | @end 37 | 38 | @implementation UIRefreshControl (AFNetworking) 39 | 40 | - (AFRefreshControlNotificationObserver *)af_notificationObserver { 41 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 42 | if (notificationObserver == nil) { 43 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; 44 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | return notificationObserver; 47 | } 48 | 49 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 50 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; 51 | } 52 | 53 | @end 54 | 55 | @implementation AFRefreshControlNotificationObserver 56 | 57 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl 58 | { 59 | self = [super init]; 60 | if (self) { 61 | _refreshControl = refreshControl; 62 | } 63 | return self; 64 | } 65 | 66 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 67 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 68 | 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 71 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 72 | 73 | if (task) { 74 | #pragma clang diagnostic push 75 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 76 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 77 | if (task.state == NSURLSessionTaskStateRunning) { 78 | [self.refreshControl beginRefreshing]; 79 | 80 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 81 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 82 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 83 | } else { 84 | [self.refreshControl endRefreshing]; 85 | } 86 | #pragma clang diagnostic pop 87 | } 88 | } 89 | 90 | #pragma mark - 91 | 92 | - (void)af_beginRefreshing { 93 | dispatch_async(dispatch_get_main_queue(), ^{ 94 | #pragma clang diagnostic push 95 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 96 | [self.refreshControl beginRefreshing]; 97 | #pragma clang diagnostic pop 98 | }); 99 | } 100 | 101 | - (void)af_endRefreshing { 102 | dispatch_async(dispatch_get_main_queue(), ^{ 103 | #pragma clang diagnostic push 104 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 105 | [self.refreshControl endRefreshing]; 106 | #pragma clang diagnostic pop 107 | }); 108 | } 109 | 110 | #pragma mark - 111 | 112 | - (void)dealloc { 113 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 114 | 115 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 116 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 117 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 118 | } 119 | 120 | @end 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFHTTPSessionManager; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. 36 | 37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. 38 | */ 39 | @interface UIWebView (AFNetworking) 40 | 41 | /** 42 | The session manager used to download all requests. 43 | */ 44 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager; 45 | 46 | /** 47 | Asynchronously loads the specified request. 48 | 49 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 50 | @param progress A progress object monitoring the current download progress. 51 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 52 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 53 | */ 54 | - (void)loadRequest:(NSURLRequest *)request 55 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 56 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 57 | failure:(nullable void (^)(NSError *error))failure; 58 | 59 | /** 60 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 61 | 62 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 63 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 64 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 65 | @param progress A progress object monitoring the current download progress. 66 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 67 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 68 | */ 69 | - (void)loadRequest:(NSURLRequest *)request 70 | MIMEType:(nullable NSString *)MIMEType 71 | textEncodingName:(nullable NSString *)textEncodingName 72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 74 | failure:(nullable void (^)(NSError *error))failure; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefresh.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/MJRefresh.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshAutoFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshAutoGifFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshAutoNormalFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshAutoStateFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshBackFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshBackGifFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshBackNormalFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshBackStateFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshComponent.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshComponent.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshConst.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/MJRefreshConst.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshGifHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshNormalHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/MJRefreshStateHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/UIScrollView+MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/UIScrollView+MJExtension.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/UIScrollView+MJRefresh.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/UIScrollView+MJRefresh.h -------------------------------------------------------------------------------- /Pods/Headers/Private/MJRefresh/UIView+MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/UIView+MJExtension.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefresh.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/MJRefresh.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshAutoFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshAutoGifFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshAutoNormalFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshAutoStateFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshBackFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshBackGifFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshBackNormalFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshBackStateFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshComponent.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshComponent.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshConst.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/MJRefreshConst.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshFooter.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshFooter.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshGifHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Base/MJRefreshHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshNormalHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/MJRefreshStateHeader.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/UIScrollView+MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/UIScrollView+MJExtension.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/UIScrollView+MJRefresh.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/UIScrollView+MJRefresh.h -------------------------------------------------------------------------------- /Pods/Headers/Public/MJRefresh/UIView+MJExtension.h: -------------------------------------------------------------------------------- 1 | ../../../MJRefresh/MJRefresh/UIView+MJExtension.h -------------------------------------------------------------------------------- /Pods/MJRefresh/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 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 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all 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 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshAutoFooter : MJRefreshFooter 12 | /** 是否自动刷新(默认为YES) */ 13 | @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; 14 | 15 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 16 | @property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); 17 | 18 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 19 | @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoFooter() 12 | @end 13 | 14 | @implementation MJRefreshAutoFooter 15 | 16 | #pragma mark - 初始化 17 | - (void)willMoveToSuperview:(UIView *)newSuperview 18 | { 19 | [super willMoveToSuperview:newSuperview]; 20 | 21 | if (newSuperview) { // 新的父控件 22 | if (self.hidden == NO) { 23 | self.scrollView.mj_insetB += self.mj_h; 24 | } 25 | 26 | // 设置位置 27 | self.mj_y = _scrollView.mj_contentH; 28 | } else { // 被移除了 29 | if (self.hidden == NO) { 30 | self.scrollView.mj_insetB -= self.mj_h; 31 | } 32 | } 33 | } 34 | 35 | #pragma mark - 过期方法 36 | - (void)setAppearencePercentTriggerAutoRefresh:(CGFloat)appearencePercentTriggerAutoRefresh 37 | { 38 | self.triggerAutomaticallyRefreshPercent = appearencePercentTriggerAutoRefresh; 39 | } 40 | 41 | - (CGFloat)appearencePercentTriggerAutoRefresh 42 | { 43 | return self.triggerAutomaticallyRefreshPercent; 44 | } 45 | 46 | #pragma mark - 实现父类的方法 47 | - (void)prepare 48 | { 49 | [super prepare]; 50 | 51 | // 默认底部控件100%出现时才会自动刷新 52 | self.triggerAutomaticallyRefreshPercent = 1.0; 53 | 54 | // 设置为默认状态 55 | self.automaticallyRefresh = YES; 56 | } 57 | 58 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change 59 | { 60 | [super scrollViewContentSizeDidChange:change]; 61 | 62 | // 设置位置 63 | self.mj_y = self.scrollView.mj_contentH; 64 | } 65 | 66 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 67 | { 68 | [super scrollViewContentOffsetDidChange:change]; 69 | 70 | if (self.state != MJRefreshStateIdle || !self.automaticallyRefresh || self.mj_y == 0) return; 71 | 72 | if (_scrollView.mj_insetT + _scrollView.mj_contentH > _scrollView.mj_h) { // 内容超过一个屏幕 73 | // 这里的_scrollView.mj_contentH替换掉self.mj_y更为合理 74 | if (_scrollView.mj_offsetY >= _scrollView.mj_contentH - _scrollView.mj_h + self.mj_h * self.triggerAutomaticallyRefreshPercent + _scrollView.mj_insetB - self.mj_h) { 75 | // 防止手松开时连续调用 76 | CGPoint old = [change[@"old"] CGPointValue]; 77 | CGPoint new = [change[@"new"] CGPointValue]; 78 | if (new.y <= old.y) return; 79 | 80 | // 当底部刷新控件完全出现时,才刷新 81 | [self beginRefreshing]; 82 | } 83 | } 84 | } 85 | 86 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change 87 | { 88 | [super scrollViewPanStateDidChange:change]; 89 | 90 | if (self.state != MJRefreshStateIdle) return; 91 | 92 | if (_scrollView.panGestureRecognizer.state == UIGestureRecognizerStateEnded) {// 手松开 93 | if (_scrollView.mj_insetT + _scrollView.mj_contentH <= _scrollView.mj_h) { // 不够一个屏幕 94 | if (_scrollView.mj_offsetY >= - _scrollView.mj_insetT) { // 向上拽 95 | [self beginRefreshing]; 96 | } 97 | } else { // 超出一个屏幕 98 | if (_scrollView.mj_offsetY >= _scrollView.mj_contentH + _scrollView.mj_insetB - _scrollView.mj_h) { 99 | [self beginRefreshing]; 100 | } 101 | } 102 | } 103 | } 104 | 105 | - (void)setState:(MJRefreshState)state 106 | { 107 | MJRefreshCheckState 108 | 109 | if (state == MJRefreshStateRefreshing) { 110 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 111 | [self executeRefreshingCallback]; 112 | }); 113 | } 114 | } 115 | 116 | - (void)setHidden:(BOOL)hidden 117 | { 118 | BOOL lastHidden = self.isHidden; 119 | 120 | [super setHidden:hidden]; 121 | 122 | if (!lastHidden && hidden) { 123 | self.state = MJRefreshStateIdle; 124 | 125 | self.scrollView.mj_insetB -= self.mj_h; 126 | } else if (lastHidden && !hidden) { 127 | self.scrollView.mj_insetB += self.mj_h; 128 | 129 | // 设置位置 130 | self.mj_y = _scrollView.mj_contentH; 131 | } 132 | } 133 | @end 134 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshBackFooter : MJRefreshFooter 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackFooter.h" 10 | 11 | @interface MJRefreshBackFooter() 12 | @property (assign, nonatomic) NSInteger lastRefreshCount; 13 | @property (assign, nonatomic) CGFloat lastBottomDelta; 14 | @end 15 | 16 | @implementation MJRefreshBackFooter 17 | 18 | #pragma mark - 初始化 19 | - (void)willMoveToSuperview:(UIView *)newSuperview 20 | { 21 | [super willMoveToSuperview:newSuperview]; 22 | 23 | [self scrollViewContentSizeDidChange:nil]; 24 | } 25 | 26 | #pragma mark - 实现父类的方法 27 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 28 | { 29 | [super scrollViewContentOffsetDidChange:change]; 30 | 31 | // 如果正在刷新,直接返回 32 | if (self.state == MJRefreshStateRefreshing) return; 33 | 34 | _scrollViewOriginalInset = self.scrollView.contentInset; 35 | 36 | // 当前的contentOffset 37 | CGFloat currentOffsetY = self.scrollView.mj_offsetY; 38 | // 尾部控件刚好出现的offsetY 39 | CGFloat happenOffsetY = [self happenOffsetY]; 40 | // 如果是向下滚动到看不见尾部控件,直接返回 41 | if (currentOffsetY <= happenOffsetY) return; 42 | 43 | CGFloat pullingPercent = (currentOffsetY - happenOffsetY) / self.mj_h; 44 | 45 | // 如果已全部加载,仅设置pullingPercent,然后返回 46 | if (self.state == MJRefreshStateNoMoreData) { 47 | self.pullingPercent = pullingPercent; 48 | return; 49 | } 50 | 51 | if (self.scrollView.isDragging) { 52 | self.pullingPercent = pullingPercent; 53 | // 普通 和 即将刷新 的临界点 54 | CGFloat normal2pullingOffsetY = happenOffsetY + self.mj_h; 55 | 56 | if (self.state == MJRefreshStateIdle && currentOffsetY > normal2pullingOffsetY) { 57 | // 转为即将刷新状态 58 | self.state = MJRefreshStatePulling; 59 | } else if (self.state == MJRefreshStatePulling && currentOffsetY <= normal2pullingOffsetY) { 60 | // 转为普通状态 61 | self.state = MJRefreshStateIdle; 62 | } 63 | } else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开 64 | // 开始刷新 65 | [self beginRefreshing]; 66 | } else if (pullingPercent < 1) { 67 | self.pullingPercent = pullingPercent; 68 | } 69 | } 70 | 71 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change 72 | { 73 | [super scrollViewContentSizeDidChange:change]; 74 | 75 | // 内容的高度 76 | CGFloat contentHeight = self.scrollView.mj_contentH + self.ignoredScrollViewContentInsetBottom; 77 | // 表格的高度 78 | CGFloat scrollHeight = self.scrollView.mj_h - self.scrollViewOriginalInset.top - self.scrollViewOriginalInset.bottom + self.ignoredScrollViewContentInsetBottom; 79 | // 设置位置和尺寸 80 | self.mj_y = MAX(contentHeight, scrollHeight); 81 | } 82 | 83 | - (void)setState:(MJRefreshState)state 84 | { 85 | MJRefreshCheckState 86 | 87 | // 根据状态来设置属性 88 | if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 89 | // 刷新完毕 90 | if (MJRefreshStateRefreshing == oldState) { 91 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 92 | self.scrollView.mj_insetB -= self.lastBottomDelta; 93 | 94 | // 自动调整透明度 95 | if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; 96 | } completion:^(BOOL finished) { 97 | self.pullingPercent = 0.0; 98 | }]; 99 | } 100 | 101 | CGFloat deltaH = [self heightForContentBreakView]; 102 | // 刚刷新完毕 103 | if (MJRefreshStateRefreshing == oldState && deltaH > 0 && self.scrollView.mj_totalDataCount != self.lastRefreshCount) { 104 | self.scrollView.mj_offsetY = self.scrollView.mj_offsetY; 105 | } 106 | } else if (state == MJRefreshStateRefreshing) { 107 | // 记录刷新前的数量 108 | self.lastRefreshCount = self.scrollView.mj_totalDataCount; 109 | 110 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 111 | CGFloat bottom = self.mj_h + self.scrollViewOriginalInset.bottom; 112 | CGFloat deltaH = [self heightForContentBreakView]; 113 | if (deltaH < 0) { // 如果内容高度小于view的高度 114 | bottom -= deltaH; 115 | } 116 | self.lastBottomDelta = bottom - self.scrollView.mj_insetB; 117 | self.scrollView.mj_insetB = bottom; 118 | self.scrollView.mj_offsetY = [self happenOffsetY] + self.mj_h; 119 | } completion:^(BOOL finished) { 120 | [self executeRefreshingCallback]; 121 | }]; 122 | } 123 | } 124 | 125 | #pragma mark - 公共方法 126 | - (void)endRefreshing 127 | { 128 | if ([self.scrollView isKindOfClass:[UICollectionView class]]) { 129 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 130 | [super endRefreshing]; 131 | }); 132 | } else { 133 | [super endRefreshing]; 134 | } 135 | } 136 | 137 | - (void)noticeNoMoreData 138 | { 139 | if ([self.scrollView isKindOfClass:[UICollectionView class]]) { 140 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 141 | [super noticeNoMoreData]; 142 | }); 143 | } else { 144 | [super noticeNoMoreData]; 145 | } 146 | } 147 | 148 | #pragma mark - 私有方法 149 | #pragma mark 获得scrollView的内容 超出 view 的高度 150 | - (CGFloat)heightForContentBreakView 151 | { 152 | CGFloat h = self.scrollView.frame.size.height - self.scrollViewOriginalInset.bottom - self.scrollViewOriginalInset.top; 153 | return self.scrollView.contentSize.height - h; 154 | } 155 | 156 | #pragma mark 刚好看到上拉刷新控件时的contentOffset.y 157 | - (CGFloat)happenOffsetY 158 | { 159 | CGFloat deltaH = [self heightForContentBreakView]; 160 | if (deltaH > 0) { 161 | return deltaH - self.scrollViewOriginalInset.top; 162 | } else { 163 | return - self.scrollViewOriginalInset.top; 164 | } 165 | } 166 | @end 167 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshComponent.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 刷新控件的基类 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | #import "UIView+MJExtension.h" 13 | #import "UIScrollView+MJExtension.h" 14 | #import "UIScrollView+MJRefresh.h" 15 | 16 | /** 刷新控件的状态 */ 17 | typedef NS_ENUM(NSInteger, MJRefreshState) { 18 | /** 普通闲置状态 */ 19 | MJRefreshStateIdle = 1, 20 | /** 松开就可以进行刷新的状态 */ 21 | MJRefreshStatePulling, 22 | /** 正在刷新中的状态 */ 23 | MJRefreshStateRefreshing, 24 | /** 即将刷新的状态 */ 25 | MJRefreshStateWillRefresh, 26 | /** 所有数据加载完毕,没有更多的数据了 */ 27 | MJRefreshStateNoMoreData 28 | }; 29 | 30 | /** 进入刷新状态的回调 */ 31 | typedef void (^MJRefreshComponentRefreshingBlock)(); 32 | 33 | /** 刷新控件的基类 */ 34 | @interface MJRefreshComponent : UIView 35 | { 36 | /** 记录scrollView刚开始的inset */ 37 | UIEdgeInsets _scrollViewOriginalInset; 38 | /** 父控件 */ 39 | __weak UIScrollView *_scrollView; 40 | } 41 | #pragma mark - 刷新回调 42 | /** 正在刷新的回调 */ 43 | @property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; 44 | /** 设置回调对象和回调方法 */ 45 | - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; 46 | /** 回调对象 */ 47 | @property (weak, nonatomic) id refreshingTarget; 48 | /** 回调方法 */ 49 | @property (assign, nonatomic) SEL refreshingAction; 50 | /** 触发回调(交给子类去调用) */ 51 | - (void)executeRefreshingCallback; 52 | 53 | #pragma mark - 刷新状态控制 54 | /** 进入刷新状态 */ 55 | - (void)beginRefreshing; 56 | /** 结束刷新状态 */ 57 | - (void)endRefreshing; 58 | /** 是否正在刷新 */ 59 | - (BOOL)isRefreshing; 60 | /** 刷新状态 一般交给子类内部实现 */ 61 | @property (assign, nonatomic) MJRefreshState state; 62 | 63 | #pragma mark - 交给子类去访问 64 | /** 记录scrollView刚开始的inset */ 65 | @property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; 66 | /** 父控件 */ 67 | @property (weak, nonatomic, readonly) UIScrollView *scrollView; 68 | 69 | #pragma mark - 交给子类们去实现 70 | /** 初始化 */ 71 | - (void)prepare NS_REQUIRES_SUPER; 72 | /** 摆放子控件frame */ 73 | - (void)placeSubviews NS_REQUIRES_SUPER; 74 | /** 当scrollView的contentOffset发生改变的时候调用 */ 75 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 76 | /** 当scrollView的contentSize发生改变的时候调用 */ 77 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 78 | /** 当scrollView的拖拽状态发生改变的时候调用 */ 79 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 80 | 81 | 82 | #pragma mark - 其他 83 | /** 拉拽的百分比(交给子类重写) */ 84 | @property (assign, nonatomic) CGFloat pullingPercent; 85 | /** 根据拖拽比例自动切换透明度 */ 86 | @property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); 87 | /** 根据拖拽比例自动切换透明度 */ 88 | @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; 89 | @end 90 | 91 | @interface UILabel(MJRefresh) 92 | + (instancetype)label; 93 | @end 94 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 上拉刷新控件 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshFooter : MJRefreshComponent 13 | /** 创建footer */ 14 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建footer */ 16 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 提示没有更多的数据 */ 19 | - (void)endRefreshingWithNoMoreData; 20 | - (void)noticeNoMoreData MJRefreshDeprecated("使用endRefreshingWithNoMoreData"); 21 | 22 | /** 重置没有更多的数据(消除没有更多数据的状态) */ 23 | - (void)resetNoMoreData; 24 | 25 | /** 忽略多少scrollView的contentInset的bottom */ 26 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; 27 | 28 | /** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏) */ 29 | @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden; 30 | @end 31 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshFooter.h" 11 | 12 | @interface MJRefreshFooter() 13 | 14 | @end 15 | 16 | @implementation MJRefreshFooter 17 | #pragma mark - 构造方法 18 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock 19 | { 20 | MJRefreshFooter *cmp = [[self alloc] init]; 21 | cmp.refreshingBlock = refreshingBlock; 22 | return cmp; 23 | } 24 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action 25 | { 26 | MJRefreshFooter *cmp = [[self alloc] init]; 27 | [cmp setRefreshingTarget:target refreshingAction:action]; 28 | return cmp; 29 | } 30 | 31 | #pragma mark - 重写父类的方法 32 | - (void)prepare 33 | { 34 | [super prepare]; 35 | 36 | // 设置自己的高度 37 | self.mj_h = MJRefreshFooterHeight; 38 | 39 | // 默认是自动隐藏 40 | self.automaticallyHidden = YES; 41 | } 42 | 43 | - (void)willMoveToSuperview:(UIView *)newSuperview 44 | { 45 | [super willMoveToSuperview:newSuperview]; 46 | 47 | if (newSuperview) { 48 | // 监听scrollView数据的变化 49 | if ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) { 50 | [self.scrollView setMj_reloadDataBlock:^(NSInteger totalDataCount) { 51 | if (self.isAutomaticallyHidden) { 52 | self.hidden = (totalDataCount == 0); 53 | } 54 | }]; 55 | } 56 | } 57 | } 58 | 59 | #pragma mark - 公共方法 60 | - (void)endRefreshingWithNoMoreData 61 | { 62 | self.state = MJRefreshStateNoMoreData; 63 | } 64 | 65 | - (void)noticeNoMoreData 66 | { 67 | [self endRefreshingWithNoMoreData]; 68 | } 69 | 70 | - (void)resetNoMoreData 71 | { 72 | self.state = MJRefreshStateIdle; 73 | } 74 | @end 75 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshHeader.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 下拉刷新控件:负责监控用户下拉的状态 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshHeader : MJRefreshComponent 13 | /** 创建header */ 14 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建header */ 16 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 这个key用来存储上一次下拉刷新成功的时间 */ 19 | @property (copy, nonatomic) NSString *lastUpdatedTimeKey; 20 | /** 上一次下拉刷新成功的时间 */ 21 | @property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; 22 | 23 | /** 忽略多少scrollView的contentInset的top */ 24 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; 25 | @end 26 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshHeader.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshHeader.h" 11 | 12 | @interface MJRefreshHeader() 13 | @property (assign, nonatomic) CGFloat insetTDelta; 14 | @end 15 | 16 | @implementation MJRefreshHeader 17 | #pragma mark - 构造方法 18 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock 19 | { 20 | MJRefreshHeader *cmp = [[self alloc] init]; 21 | cmp.refreshingBlock = refreshingBlock; 22 | return cmp; 23 | } 24 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action 25 | { 26 | MJRefreshHeader *cmp = [[self alloc] init]; 27 | [cmp setRefreshingTarget:target refreshingAction:action]; 28 | return cmp; 29 | } 30 | 31 | #pragma mark - 覆盖父类的方法 32 | - (void)prepare 33 | { 34 | [super prepare]; 35 | 36 | // 设置key 37 | self.lastUpdatedTimeKey = MJRefreshHeaderLastUpdatedTimeKey; 38 | 39 | // 设置高度 40 | self.mj_h = MJRefreshHeaderHeight; 41 | } 42 | 43 | - (void)placeSubviews 44 | { 45 | [super placeSubviews]; 46 | 47 | // 设置y值(当自己的高度发生改变了,肯定要重新调整Y值,所以放到placeSubviews方法中设置y值) 48 | self.mj_y = - self.mj_h - self.ignoredScrollViewContentInsetTop; 49 | } 50 | 51 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 52 | { 53 | [super scrollViewContentOffsetDidChange:change]; 54 | 55 | // 在刷新的refreshing状态 56 | if (self.state == MJRefreshStateRefreshing) { 57 | if (self.window == nil) return; 58 | 59 | // sectionheader停留解决 60 | CGFloat insetT = - self.scrollView.mj_offsetY > _scrollViewOriginalInset.top ? - self.scrollView.mj_offsetY : _scrollViewOriginalInset.top; 61 | insetT = insetT > self.mj_h + _scrollViewOriginalInset.top ? self.mj_h + _scrollViewOriginalInset.top : insetT; 62 | self.scrollView.mj_insetT = insetT; 63 | 64 | self.insetTDelta = _scrollViewOriginalInset.top - insetT; 65 | return; 66 | } 67 | 68 | // 跳转到下一个控制器时,contentInset可能会变 69 | _scrollViewOriginalInset = self.scrollView.contentInset; 70 | 71 | // 当前的contentOffset 72 | CGFloat offsetY = self.scrollView.mj_offsetY; 73 | // 头部控件刚好出现的offsetY 74 | CGFloat happenOffsetY = - self.scrollViewOriginalInset.top; 75 | 76 | // 如果是向上滚动到看不见头部控件,直接返回 77 | // >= -> > 78 | if (offsetY > happenOffsetY) return; 79 | 80 | // 普通 和 即将刷新 的临界点 81 | CGFloat normal2pullingOffsetY = happenOffsetY - self.mj_h; 82 | CGFloat pullingPercent = (happenOffsetY - offsetY) / self.mj_h; 83 | 84 | if (self.scrollView.isDragging) { // 如果正在拖拽 85 | self.pullingPercent = pullingPercent; 86 | if (self.state == MJRefreshStateIdle && offsetY < normal2pullingOffsetY) { 87 | // 转为即将刷新状态 88 | self.state = MJRefreshStatePulling; 89 | } else if (self.state == MJRefreshStatePulling && offsetY >= normal2pullingOffsetY) { 90 | // 转为普通状态 91 | self.state = MJRefreshStateIdle; 92 | } 93 | } else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开 94 | // 开始刷新 95 | [self beginRefreshing]; 96 | } else if (pullingPercent < 1) { 97 | self.pullingPercent = pullingPercent; 98 | } 99 | } 100 | 101 | - (void)setState:(MJRefreshState)state 102 | { 103 | MJRefreshCheckState 104 | 105 | // 根据状态做事情 106 | if (state == MJRefreshStateIdle) { 107 | if (oldState != MJRefreshStateRefreshing) return; 108 | 109 | // 保存刷新时间 110 | [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:self.lastUpdatedTimeKey]; 111 | [[NSUserDefaults standardUserDefaults] synchronize]; 112 | 113 | // 恢复inset和offset 114 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 115 | self.scrollView.mj_insetT += self.insetTDelta; 116 | 117 | // 自动调整透明度 118 | if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; 119 | } completion:^(BOOL finished) { 120 | self.pullingPercent = 0.0; 121 | }]; 122 | } else if (state == MJRefreshStateRefreshing) { 123 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 124 | // 增加滚动区域 125 | CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; 126 | self.scrollView.mj_insetT = top; 127 | 128 | // 设置滚动位置 129 | self.scrollView.mj_offsetY = - top; 130 | } completion:^(BOOL finished) { 131 | [self executeRefreshingCallback]; 132 | }]; 133 | } 134 | } 135 | 136 | - (void)drawRect:(CGRect)rect 137 | { 138 | [super drawRect:rect]; 139 | 140 | 141 | } 142 | 143 | #pragma mark - 公共方法 144 | - (void)endRefreshing 145 | { 146 | if ([self.scrollView isKindOfClass:[UICollectionView class]]) { 147 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 148 | [super endRefreshing]; 149 | }); 150 | } else { 151 | [super endRefreshing]; 152 | } 153 | } 154 | 155 | - (NSDate *)lastUpdatedTime 156 | { 157 | return [[NSUserDefaults standardUserDefaults] objectForKey:self.lastUpdatedTimeKey]; 158 | } 159 | @end 160 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter 12 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 13 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 14 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoGifFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter() 12 | @property (weak, nonatomic) UIImageView *gifView; 13 | /** 所有状态对应的动画图片 */ 14 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 15 | /** 所有状态对应的动画时间 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 17 | @end 18 | 19 | @implementation MJRefreshAutoGifFooter 20 | #pragma mark - 懒加载 21 | - (UIImageView *)gifView 22 | { 23 | if (!_gifView) { 24 | UIImageView *gifView = [[UIImageView alloc] init]; 25 | [self addSubview:_gifView = gifView]; 26 | } 27 | return _gifView; 28 | } 29 | 30 | - (NSMutableDictionary *)stateImages 31 | { 32 | if (!_stateImages) { 33 | self.stateImages = [NSMutableDictionary dictionary]; 34 | } 35 | return _stateImages; 36 | } 37 | 38 | - (NSMutableDictionary *)stateDurations 39 | { 40 | if (!_stateDurations) { 41 | self.stateDurations = [NSMutableDictionary dictionary]; 42 | } 43 | return _stateDurations; 44 | } 45 | 46 | #pragma mark - 公共方法 47 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 48 | { 49 | if (images == nil) return; 50 | 51 | self.stateImages[@(state)] = images; 52 | self.stateDurations[@(state)] = @(duration); 53 | 54 | /* 根据图片设置控件的高度 */ 55 | UIImage *image = [images firstObject]; 56 | if (image.size.height > self.mj_h) { 57 | self.mj_h = image.size.height; 58 | } 59 | } 60 | 61 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 62 | { 63 | [self setImages:images duration:images.count * 0.1 forState:state]; 64 | } 65 | 66 | #pragma mark - 实现父类的方法 67 | - (void)placeSubviews 68 | { 69 | [super placeSubviews]; 70 | 71 | if (self.gifView.constraints.count) return; 72 | 73 | self.gifView.frame = self.bounds; 74 | if (self.isRefreshingTitleHidden) { 75 | self.gifView.contentMode = UIViewContentModeCenter; 76 | } else { 77 | self.gifView.contentMode = UIViewContentModeRight; 78 | self.gifView.mj_w = self.mj_w * 0.5 - 90; 79 | } 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | // 根据状态做事情 87 | if (state == MJRefreshStateRefreshing) { 88 | NSArray *images = self.stateImages[@(state)]; 89 | if (images.count == 0) return; 90 | [self.gifView stopAnimating]; 91 | 92 | self.gifView.hidden = NO; 93 | if (images.count == 1) { // 单张图片 94 | self.gifView.image = [images lastObject]; 95 | } else { // 多张图片 96 | self.gifView.animationImages = images; 97 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 98 | [self.gifView startAnimating]; 99 | } 100 | } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 101 | [self.gifView stopAnimating]; 102 | self.gifView.hidden = YES; 103 | } 104 | } 105 | @end 106 | 107 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter 12 | /** 菊花的样式 */ 13 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 14 | @end 15 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoNormalFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter() 12 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 13 | @end 14 | 15 | @implementation MJRefreshAutoNormalFooter 16 | #pragma mark - 懒加载子控件 17 | - (UIActivityIndicatorView *)loadingView 18 | { 19 | if (!_loadingView) { 20 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 21 | loadingView.hidesWhenStopped = YES; 22 | [self addSubview:_loadingView = loadingView]; 23 | } 24 | return _loadingView; 25 | } 26 | 27 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 28 | { 29 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 30 | 31 | self.loadingView = nil; 32 | [self setNeedsLayout]; 33 | } 34 | #pragma makr - 重写父类的方法 35 | - (void)prepare 36 | { 37 | [super prepare]; 38 | 39 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 40 | } 41 | 42 | - (void)placeSubviews 43 | { 44 | [super placeSubviews]; 45 | 46 | if (self.loadingView.constraints.count) return; 47 | 48 | // 圈圈 49 | CGFloat loadingCenterX = self.mj_w * 0.5; 50 | if (!self.isRefreshingTitleHidden) { 51 | loadingCenterX -= 100; 52 | } 53 | CGFloat loadingCenterY = self.mj_h * 0.5; 54 | self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); 55 | } 56 | 57 | - (void)setState:(MJRefreshState)state 58 | { 59 | MJRefreshCheckState 60 | 61 | // 根据状态做事情 62 | if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 63 | [self.loadingView stopAnimating]; 64 | } else if (state == MJRefreshStateRefreshing) { 65 | [self.loadingView startAnimating]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter 12 | /** 显示刷新状态的label */ 13 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 14 | 15 | /** 设置state状态下的文字 */ 16 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 17 | 18 | /** 隐藏刷新状态的文字 */ 19 | @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; 20 | @end 21 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshAutoStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | #pragma mark - 私有方法 47 | - (void)stateLabelClick 48 | { 49 | if (self.state == MJRefreshStateIdle) { 50 | [self beginRefreshing]; 51 | } 52 | } 53 | 54 | #pragma mark - 重写父类的方法 55 | - (void)prepare 56 | { 57 | [super prepare]; 58 | 59 | // 初始化文字 60 | [self setTitle:MJRefreshAutoFooterIdleText forState:MJRefreshStateIdle]; 61 | [self setTitle:MJRefreshAutoFooterRefreshingText forState:MJRefreshStateRefreshing]; 62 | [self setTitle:MJRefreshAutoFooterNoMoreDataText forState:MJRefreshStateNoMoreData]; 63 | 64 | // 监听label 65 | self.stateLabel.userInteractionEnabled = YES; 66 | [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; 67 | } 68 | 69 | - (void)placeSubviews 70 | { 71 | [super placeSubviews]; 72 | 73 | if (self.stateLabel.constraints.count) return; 74 | 75 | // 状态标签 76 | self.stateLabel.frame = self.bounds; 77 | } 78 | 79 | - (void)setState:(MJRefreshState)state 80 | { 81 | MJRefreshCheckState 82 | 83 | if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { 84 | self.stateLabel.text = nil; 85 | } else { 86 | self.stateLabel.text = self.stateTitles[@(state)]; 87 | } 88 | } 89 | @end -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter 12 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 13 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 14 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackGifFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter() 12 | @property (weak, nonatomic) UIImageView *gifView; 13 | /** 所有状态对应的动画图片 */ 14 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 15 | /** 所有状态对应的动画时间 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 17 | @end 18 | 19 | @implementation MJRefreshBackGifFooter 20 | #pragma mark - 懒加载 21 | - (UIImageView *)gifView 22 | { 23 | if (!_gifView) { 24 | UIImageView *gifView = [[UIImageView alloc] init]; 25 | [self addSubview:_gifView = gifView]; 26 | } 27 | return _gifView; 28 | } 29 | 30 | - (NSMutableDictionary *)stateImages 31 | { 32 | if (!_stateImages) { 33 | self.stateImages = [NSMutableDictionary dictionary]; 34 | } 35 | return _stateImages; 36 | } 37 | 38 | - (NSMutableDictionary *)stateDurations 39 | { 40 | if (!_stateDurations) { 41 | self.stateDurations = [NSMutableDictionary dictionary]; 42 | } 43 | return _stateDurations; 44 | } 45 | 46 | #pragma mark - 公共方法 47 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 48 | { 49 | if (images == nil) return; 50 | 51 | self.stateImages[@(state)] = images; 52 | self.stateDurations[@(state)] = @(duration); 53 | 54 | /* 根据图片设置控件的高度 */ 55 | UIImage *image = [images firstObject]; 56 | if (image.size.height > self.mj_h) { 57 | self.mj_h = image.size.height; 58 | } 59 | } 60 | 61 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 62 | { 63 | [self setImages:images duration:images.count * 0.1 forState:state]; 64 | } 65 | 66 | #pragma mark - 实现父类的方法 67 | - (void)setPullingPercent:(CGFloat)pullingPercent 68 | { 69 | [super setPullingPercent:pullingPercent]; 70 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 71 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 72 | [self.gifView stopAnimating]; 73 | NSUInteger index = images.count * pullingPercent; 74 | if (index >= images.count) index = images.count - 1; 75 | self.gifView.image = images[index]; 76 | } 77 | 78 | - (void)placeSubviews 79 | { 80 | [super placeSubviews]; 81 | 82 | if (self.gifView.constraints.count) return; 83 | 84 | self.gifView.frame = self.bounds; 85 | if (self.stateLabel.hidden) { 86 | self.gifView.contentMode = UIViewContentModeCenter; 87 | } else { 88 | self.gifView.contentMode = UIViewContentModeRight; 89 | self.gifView.mj_w = self.mj_w * 0.5 - 90; 90 | } 91 | } 92 | 93 | - (void)setState:(MJRefreshState)state 94 | { 95 | MJRefreshCheckState 96 | 97 | // 根据状态做事情 98 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 99 | NSArray *images = self.stateImages[@(state)]; 100 | if (images.count == 0) return; 101 | 102 | self.gifView.hidden = NO; 103 | [self.gifView stopAnimating]; 104 | if (images.count == 1) { // 单张图片 105 | self.gifView.image = [images lastObject]; 106 | } else { // 多张图片 107 | self.gifView.animationImages = images; 108 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 109 | [self.gifView startAnimating]; 110 | } 111 | } else if (state == MJRefreshStateIdle) { 112 | self.gifView.hidden = NO; 113 | } else if (state == MJRefreshStateNoMoreData) { 114 | self.gifView.hidden = YES; 115 | } 116 | } 117 | @end 118 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackNormalFooter.h" 10 | 11 | @interface MJRefreshBackNormalFooter() 12 | { 13 | __unsafe_unretained UIImageView *_arrowView; 14 | } 15 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 16 | @end 17 | 18 | @implementation MJRefreshBackNormalFooter 19 | #pragma mark - 懒加载子控件 20 | - (UIImageView *)arrowView 21 | { 22 | if (!_arrowView) { 23 | UIImage *image = [UIImage imageNamed:MJRefreshSrcName(@"arrow.png")] ?: [UIImage imageNamed:MJRefreshFrameworkSrcName(@"arrow.png")]; 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:image]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | 31 | - (UIActivityIndicatorView *)loadingView 32 | { 33 | if (!_loadingView) { 34 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 35 | loadingView.hidesWhenStopped = YES; 36 | [self addSubview:_loadingView = loadingView]; 37 | } 38 | return _loadingView; 39 | } 40 | 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | #pragma makr - 重写父类的方法 49 | - (void)prepare 50 | { 51 | [super prepare]; 52 | 53 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 54 | } 55 | 56 | - (void)placeSubviews 57 | { 58 | [super placeSubviews]; 59 | 60 | // 箭头的中心点 61 | CGFloat arrowCenterX = self.mj_w * 0.5; 62 | if (!self.stateLabel.hidden) { 63 | arrowCenterX -= 100; 64 | } 65 | CGFloat arrowCenterY = self.mj_h * 0.5; 66 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 67 | 68 | // 箭头 69 | if (self.arrowView.constraints.count == 0) { 70 | self.arrowView.mj_size = self.arrowView.image.size; 71 | self.arrowView.center = arrowCenter; 72 | } 73 | 74 | // 圈圈 75 | if (self.loadingView.constraints.count == 0) { 76 | self.loadingView.center = arrowCenter; 77 | } 78 | } 79 | 80 | - (void)setState:(MJRefreshState)state 81 | { 82 | MJRefreshCheckState 83 | 84 | // 根据状态做事情 85 | if (state == MJRefreshStateIdle) { 86 | if (oldState == MJRefreshStateRefreshing) { 87 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 88 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 89 | self.loadingView.alpha = 0.0; 90 | } completion:^(BOOL finished) { 91 | self.loadingView.alpha = 1.0; 92 | [self.loadingView stopAnimating]; 93 | 94 | self.arrowView.hidden = NO; 95 | }]; 96 | } else { 97 | self.arrowView.hidden = NO; 98 | [self.loadingView stopAnimating]; 99 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 100 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 101 | }]; 102 | } 103 | } else if (state == MJRefreshStatePulling) { 104 | self.arrowView.hidden = NO; 105 | [self.loadingView stopAnimating]; 106 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 107 | self.arrowView.transform = CGAffineTransformIdentity; 108 | }]; 109 | } else if (state == MJRefreshStateRefreshing) { 110 | self.arrowView.hidden = YES; 111 | [self.loadingView startAnimating]; 112 | } else if (state == MJRefreshStateNoMoreData) { 113 | self.arrowView.hidden = YES; 114 | [self.loadingView stopAnimating]; 115 | } 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter : MJRefreshBackFooter 12 | /** 显示刷新状态的label */ 13 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 14 | /** 设置state状态下的文字 */ 15 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 16 | 17 | /** 获取state状态下的title */ 18 | - (NSString *)titleForState:(MJRefreshState)state; 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshBackStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | - (NSString *)titleForState:(MJRefreshState)state { 47 | return self.stateTitles[@(state)]; 48 | } 49 | 50 | #pragma mark - 重写父类的方法 51 | - (void)prepare 52 | { 53 | [super prepare]; 54 | 55 | // 初始化文字 56 | [self setTitle:MJRefreshBackFooterIdleText forState:MJRefreshStateIdle]; 57 | [self setTitle:MJRefreshBackFooterPullingText forState:MJRefreshStatePulling]; 58 | [self setTitle:MJRefreshBackFooterRefreshingText forState:MJRefreshStateRefreshing]; 59 | [self setTitle:MJRefreshBackFooterNoMoreDataText forState:MJRefreshStateNoMoreData]; 60 | } 61 | 62 | - (void)placeSubviews 63 | { 64 | [super placeSubviews]; 65 | 66 | if (self.stateLabel.constraints.count) return; 67 | 68 | // 状态标签 69 | self.stateLabel.frame = self.bounds; 70 | } 71 | 72 | - (void)setState:(MJRefreshState)state 73 | { 74 | MJRefreshCheckState 75 | 76 | // 设置状态文字 77 | self.stateLabel.text = self.stateTitles[@(state)]; 78 | } 79 | @end 80 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshGifHeader : MJRefreshStateHeader 12 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 13 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 14 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshGifHeader.h" 10 | 11 | @interface MJRefreshGifHeader() 12 | @property (weak, nonatomic) UIImageView *gifView; 13 | /** 所有状态对应的动画图片 */ 14 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 15 | /** 所有状态对应的动画时间 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 17 | @end 18 | 19 | @implementation MJRefreshGifHeader 20 | #pragma mark - 懒加载 21 | - (UIImageView *)gifView 22 | { 23 | if (!_gifView) { 24 | UIImageView *gifView = [[UIImageView alloc] init]; 25 | [self addSubview:_gifView = gifView]; 26 | } 27 | return _gifView; 28 | } 29 | 30 | - (NSMutableDictionary *)stateImages 31 | { 32 | if (!_stateImages) { 33 | self.stateImages = [NSMutableDictionary dictionary]; 34 | } 35 | return _stateImages; 36 | } 37 | 38 | - (NSMutableDictionary *)stateDurations 39 | { 40 | if (!_stateDurations) { 41 | self.stateDurations = [NSMutableDictionary dictionary]; 42 | } 43 | return _stateDurations; 44 | } 45 | 46 | #pragma mark - 公共方法 47 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 48 | { 49 | if (images == nil) return; 50 | 51 | self.stateImages[@(state)] = images; 52 | self.stateDurations[@(state)] = @(duration); 53 | 54 | /* 根据图片设置控件的高度 */ 55 | UIImage *image = [images firstObject]; 56 | if (image.size.height > self.mj_h) { 57 | self.mj_h = image.size.height; 58 | } 59 | } 60 | 61 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 62 | { 63 | [self setImages:images duration:images.count * 0.1 forState:state]; 64 | } 65 | 66 | #pragma mark - 实现父类的方法 67 | - (void)setPullingPercent:(CGFloat)pullingPercent 68 | { 69 | [super setPullingPercent:pullingPercent]; 70 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 71 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 72 | // 停止动画 73 | [self.gifView stopAnimating]; 74 | // 设置当前需要显示的图片 75 | NSUInteger index = images.count * pullingPercent; 76 | if (index >= images.count) index = images.count - 1; 77 | self.gifView.image = images[index]; 78 | } 79 | 80 | - (void)placeSubviews 81 | { 82 | [super placeSubviews]; 83 | 84 | if (self.gifView.constraints.count) return; 85 | 86 | self.gifView.frame = self.bounds; 87 | if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { 88 | self.gifView.contentMode = UIViewContentModeCenter; 89 | } else { 90 | self.gifView.contentMode = UIViewContentModeRight; 91 | self.gifView.mj_w = self.mj_w * 0.5 - 90; 92 | } 93 | } 94 | 95 | - (void)setState:(MJRefreshState)state 96 | { 97 | MJRefreshCheckState 98 | 99 | // 根据状态做事情 100 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 101 | NSArray *images = self.stateImages[@(state)]; 102 | if (images.count == 0) return; 103 | 104 | [self.gifView stopAnimating]; 105 | if (images.count == 1) { // 单张图片 106 | self.gifView.image = [images lastObject]; 107 | } else { // 多张图片 108 | self.gifView.animationImages = images; 109 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 110 | [self.gifView startAnimating]; 111 | } 112 | } else if (state == MJRefreshStateIdle) { 113 | [self.gifView stopAnimating]; 114 | } 115 | } 116 | @end 117 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshNormalHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshNormalHeader.h" 10 | 11 | @interface MJRefreshNormalHeader() 12 | { 13 | __unsafe_unretained UIImageView *_arrowView; 14 | } 15 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 16 | @end 17 | 18 | @implementation MJRefreshNormalHeader 19 | #pragma mark - 懒加载子控件 20 | - (UIImageView *)arrowView 21 | { 22 | if (!_arrowView) { 23 | UIImage *image = [UIImage imageNamed:MJRefreshSrcName(@"arrow.png")] ?: [UIImage imageNamed:MJRefreshFrameworkSrcName(@"arrow.png")]; 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:image]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | - (UIActivityIndicatorView *)loadingView 31 | { 32 | if (!_loadingView) { 33 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 34 | loadingView.hidesWhenStopped = YES; 35 | [self addSubview:_loadingView = loadingView]; 36 | } 37 | return _loadingView; 38 | } 39 | 40 | #pragma mark - 公共方法 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | 49 | #pragma makr - 重写父类的方法 50 | - (void)prepare 51 | { 52 | [super prepare]; 53 | 54 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 55 | } 56 | 57 | - (void)placeSubviews 58 | { 59 | [super placeSubviews]; 60 | 61 | // 箭头的中心点 62 | CGFloat arrowCenterX = self.mj_w * 0.5; 63 | if (!self.stateLabel.hidden) { 64 | arrowCenterX -= 100; 65 | } 66 | CGFloat arrowCenterY = self.mj_h * 0.5; 67 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 68 | 69 | // 箭头 70 | if (self.arrowView.constraints.count == 0) { 71 | self.arrowView.mj_size = self.arrowView.image.size; 72 | self.arrowView.center = arrowCenter; 73 | } 74 | 75 | // 圈圈 76 | if (self.loadingView.constraints.count == 0) { 77 | self.loadingView.center = arrowCenter; 78 | } 79 | } 80 | 81 | - (void)setState:(MJRefreshState)state 82 | { 83 | MJRefreshCheckState 84 | 85 | // 根据状态做事情 86 | if (state == MJRefreshStateIdle) { 87 | if (oldState == MJRefreshStateRefreshing) { 88 | self.arrowView.transform = CGAffineTransformIdentity; 89 | 90 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 91 | self.loadingView.alpha = 0.0; 92 | } completion:^(BOOL finished) { 93 | // 如果执行完动画发现不是idle状态,就直接返回,进入其他状态 94 | if (self.state != MJRefreshStateIdle) return; 95 | 96 | self.loadingView.alpha = 1.0; 97 | [self.loadingView stopAnimating]; 98 | self.arrowView.hidden = NO; 99 | }]; 100 | } else { 101 | [self.loadingView stopAnimating]; 102 | self.arrowView.hidden = NO; 103 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 104 | self.arrowView.transform = CGAffineTransformIdentity; 105 | }]; 106 | } 107 | } else if (state == MJRefreshStatePulling) { 108 | [self.loadingView stopAnimating]; 109 | self.arrowView.hidden = NO; 110 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 111 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 112 | }]; 113 | } else if (state == MJRefreshStateRefreshing) { 114 | self.loadingView.alpha = 1.0; // 防止refreshing -> idle的动画完毕动作没有被执行 115 | [self.loadingView startAnimating]; 116 | self.arrowView.hidden = YES; 117 | } 118 | } 119 | @end 120 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshStateHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshHeader.h" 10 | 11 | @interface MJRefreshStateHeader : MJRefreshHeader 12 | #pragma mark - 刷新时间相关 13 | /** 利用这个block来决定显示的更新时间文字 */ 14 | @property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime); 15 | /** 显示上一次刷新时间的label */ 16 | @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; 17 | 18 | #pragma mark - 状态相关 19 | /** 显示刷新状态的label */ 20 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 21 | /** 设置state状态下的文字 */ 22 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 23 | @end 24 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshStateHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshStateHeader() 12 | { 13 | /** 显示上一次刷新时间的label */ 14 | __unsafe_unretained UILabel *_lastUpdatedTimeLabel; 15 | /** 显示刷新状态的label */ 16 | __unsafe_unretained UILabel *_stateLabel; 17 | } 18 | /** 所有状态对应的文字 */ 19 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 20 | @end 21 | 22 | @implementation MJRefreshStateHeader 23 | #pragma mark - 懒加载 24 | - (NSMutableDictionary *)stateTitles 25 | { 26 | if (!_stateTitles) { 27 | self.stateTitles = [NSMutableDictionary dictionary]; 28 | } 29 | return _stateTitles; 30 | } 31 | 32 | - (UILabel *)stateLabel 33 | { 34 | if (!_stateLabel) { 35 | [self addSubview:_stateLabel = [UILabel label]]; 36 | } 37 | return _stateLabel; 38 | } 39 | 40 | - (UILabel *)lastUpdatedTimeLabel 41 | { 42 | if (!_lastUpdatedTimeLabel) { 43 | [self addSubview:_lastUpdatedTimeLabel = [UILabel label]]; 44 | } 45 | return _lastUpdatedTimeLabel; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 50 | { 51 | if (title == nil) return; 52 | self.stateTitles[@(state)] = title; 53 | self.stateLabel.text = self.stateTitles[@(self.state)]; 54 | } 55 | 56 | #pragma mark - 日历获取在9.x之后的系统使用currentCalendar会出异常。在8.0之后使用系统新API。 57 | - (NSCalendar *)currentCalendar { 58 | if ([NSCalendar respondsToSelector:@selector(calendarWithIdentifier:)]) { 59 | return [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian]; 60 | } 61 | return [NSCalendar currentCalendar]; 62 | } 63 | 64 | #pragma mark key的处理 65 | - (void)setLastUpdatedTimeKey:(NSString *)lastUpdatedTimeKey 66 | { 67 | [super setLastUpdatedTimeKey:lastUpdatedTimeKey]; 68 | 69 | // 如果label隐藏了,就不用再处理 70 | if (self.lastUpdatedTimeLabel.hidden) return; 71 | 72 | NSDate *lastUpdatedTime = [[NSUserDefaults standardUserDefaults] objectForKey:lastUpdatedTimeKey]; 73 | 74 | // 如果有block 75 | if (self.lastUpdatedTimeText) { 76 | self.lastUpdatedTimeLabel.text = self.lastUpdatedTimeText(lastUpdatedTime); 77 | return; 78 | } 79 | 80 | if (lastUpdatedTime) { 81 | // 1.获得年月日 82 | NSCalendar *calendar = [self currentCalendar]; 83 | NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour |NSCalendarUnitMinute; 84 | NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:lastUpdatedTime]; 85 | NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]]; 86 | 87 | // 2.格式化日期 88 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 89 | if ([cmp1 day] == [cmp2 day]) { // 今天 90 | formatter.dateFormat = @"今天 HH:mm"; 91 | } else if ([cmp1 year] == [cmp2 year]) { // 今年 92 | formatter.dateFormat = @"MM-dd HH:mm"; 93 | } else { 94 | formatter.dateFormat = @"yyyy-MM-dd HH:mm"; 95 | } 96 | NSString *time = [formatter stringFromDate:lastUpdatedTime]; 97 | 98 | // 3.显示日期 99 | self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"最后更新:%@", time]; 100 | } else { 101 | self.lastUpdatedTimeLabel.text = @"最后更新:无记录"; 102 | } 103 | } 104 | 105 | #pragma mark - 覆盖父类的方法 106 | - (void)prepare 107 | { 108 | [super prepare]; 109 | 110 | // 初始化文字 111 | [self setTitle:MJRefreshHeaderIdleText forState:MJRefreshStateIdle]; 112 | [self setTitle:MJRefreshHeaderPullingText forState:MJRefreshStatePulling]; 113 | [self setTitle:MJRefreshHeaderRefreshingText forState:MJRefreshStateRefreshing]; 114 | } 115 | 116 | - (void)placeSubviews 117 | { 118 | [super placeSubviews]; 119 | 120 | if (self.stateLabel.hidden) return; 121 | 122 | BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0; 123 | 124 | if (self.lastUpdatedTimeLabel.hidden) { 125 | // 状态 126 | if (noConstrainsOnStatusLabel) self.stateLabel.frame = self.bounds; 127 | } else { 128 | CGFloat stateLabelH = self.mj_h * 0.5; 129 | // 状态 130 | if (noConstrainsOnStatusLabel) { 131 | self.stateLabel.mj_x = 0; 132 | self.stateLabel.mj_y = 0; 133 | self.stateLabel.mj_w = self.mj_w; 134 | self.stateLabel.mj_h = stateLabelH; 135 | } 136 | 137 | // 更新时间 138 | if (self.lastUpdatedTimeLabel.constraints.count == 0) { 139 | self.lastUpdatedTimeLabel.mj_x = 0; 140 | self.lastUpdatedTimeLabel.mj_y = stateLabelH; 141 | self.lastUpdatedTimeLabel.mj_w = self.mj_w; 142 | self.lastUpdatedTimeLabel.mj_h = self.mj_h - self.lastUpdatedTimeLabel.mj_y; 143 | } 144 | } 145 | } 146 | 147 | - (void)setState:(MJRefreshState)state 148 | { 149 | MJRefreshCheckState 150 | 151 | // 设置状态文字 152 | self.stateLabel.text = self.stateTitles[@(state)]; 153 | 154 | // 重新设置key(重新显示时间) 155 | self.lastUpdatedTimeKey = self.lastUpdatedTimeKey; 156 | } 157 | @end 158 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wenbingzuo/NetworkByYala/a8287ae2a83aab4bd75ace4fc916ef2d35fa997e/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | 4 | #import "UIScrollView+MJRefresh.h" 5 | #import "UIScrollView+MJExtension.h" 6 | #import "UIView+MJExtension.h" 7 | 8 | #import "MJRefreshNormalHeader.h" 9 | #import "MJRefreshGifHeader.h" 10 | 11 | #import "MJRefreshBackNormalFooter.h" 12 | #import "MJRefreshBackGifFooter.h" 13 | #import "MJRefreshAutoNormalFooter.h" 14 | #import "MJRefreshAutoGifFooter.h" -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/MJRefreshConst.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | #import 5 | 6 | // 弱引用 7 | #define MJWeakSelf __weak typeof(self) weakSelf = self; 8 | 9 | // 日志输出 10 | #ifdef DEBUG 11 | #define MJRefreshLog(...) NSLog(__VA_ARGS__) 12 | #else 13 | #define MJRefreshLog(...) 14 | #endif 15 | 16 | // 过期提醒 17 | #define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) 18 | 19 | // 运行时objc_msgSend 20 | #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) 21 | #define MJRefreshMsgTarget(target) (__bridge void *)(target) 22 | 23 | // RGB颜色 24 | #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] 25 | 26 | // 文字颜色 27 | #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) 28 | 29 | // 字体大小 30 | #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] 31 | 32 | // 图片路径 33 | #define MJRefreshSrcName(file) [@"MJRefresh.bundle" stringByAppendingPathComponent:file] 34 | #define MJRefreshFrameworkSrcName(file) [@"Frameworks/MJRefresh.framework/MJRefresh.bundle" stringByAppendingPathComponent:file] 35 | 36 | // 常量 37 | UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; 38 | UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; 39 | UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; 40 | UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; 41 | 42 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; 43 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; 44 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; 45 | UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; 46 | 47 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; 48 | 49 | UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; 50 | UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; 51 | UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; 52 | 53 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; 54 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; 55 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; 56 | 57 | UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; 58 | UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; 59 | UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; 60 | UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; 61 | 62 | // 状态检查 63 | #define MJRefreshCheckState \ 64 | MJRefreshState oldState = self.state; \ 65 | if (state == oldState) return; \ 66 | [super setState:state]; 67 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/MJRefreshConst.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | 5 | const CGFloat MJRefreshHeaderHeight = 54.0; 6 | const CGFloat MJRefreshFooterHeight = 44.0; 7 | const CGFloat MJRefreshFastAnimationDuration = 0.25; 8 | const CGFloat MJRefreshSlowAnimationDuration = 0.4; 9 | 10 | NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; 11 | NSString *const MJRefreshKeyPathContentInset = @"contentInset"; 12 | NSString *const MJRefreshKeyPathContentSize = @"contentSize"; 13 | NSString *const MJRefreshKeyPathPanState = @"state"; 14 | 15 | NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; 16 | 17 | NSString *const MJRefreshHeaderIdleText = @"下拉可以刷新"; 18 | NSString *const MJRefreshHeaderPullingText = @"松开立即刷新"; 19 | NSString *const MJRefreshHeaderRefreshingText = @"正在刷新数据中..."; 20 | 21 | NSString *const MJRefreshAutoFooterIdleText = @"点击或上拉加载更多"; 22 | NSString *const MJRefreshAutoFooterRefreshingText = @"正在加载更多的数据..."; 23 | NSString *const MJRefreshAutoFooterNoMoreDataText = @"已经全部加载完毕"; 24 | 25 | NSString *const MJRefreshBackFooterIdleText = @"上拉可以加载更多"; 26 | NSString *const MJRefreshBackFooterPullingText = @"松开立即加载更多"; 27 | NSString *const MJRefreshBackFooterRefreshingText = @"正在加载更多的数据..."; 28 | NSString *const MJRefreshBackFooterNoMoreDataText = @"已经全部加载完毕"; -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | @interface UIScrollView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_insetT; 14 | @property (assign, nonatomic) CGFloat mj_insetB; 15 | @property (assign, nonatomic) CGFloat mj_insetL; 16 | @property (assign, nonatomic) CGFloat mj_insetR; 17 | 18 | @property (assign, nonatomic) CGFloat mj_offsetX; 19 | @property (assign, nonatomic) CGFloat mj_offsetY; 20 | 21 | @property (assign, nonatomic) CGFloat mj_contentW; 22 | @property (assign, nonatomic) CGFloat mj_contentH; 23 | @end 24 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJExtension.h" 11 | #import 12 | 13 | @implementation UIScrollView (MJExtension) 14 | 15 | - (void)setMj_insetT:(CGFloat)mj_insetT 16 | { 17 | UIEdgeInsets inset = self.contentInset; 18 | inset.top = mj_insetT; 19 | self.contentInset = inset; 20 | } 21 | 22 | - (CGFloat)mj_insetT 23 | { 24 | return self.contentInset.top; 25 | } 26 | 27 | - (void)setMj_insetB:(CGFloat)mj_insetB 28 | { 29 | UIEdgeInsets inset = self.contentInset; 30 | inset.bottom = mj_insetB; 31 | self.contentInset = inset; 32 | } 33 | 34 | - (CGFloat)mj_insetB 35 | { 36 | return self.contentInset.bottom; 37 | } 38 | 39 | - (void)setMj_insetL:(CGFloat)mj_insetL 40 | { 41 | UIEdgeInsets inset = self.contentInset; 42 | inset.left = mj_insetL; 43 | self.contentInset = inset; 44 | } 45 | 46 | - (CGFloat)mj_insetL 47 | { 48 | return self.contentInset.left; 49 | } 50 | 51 | - (void)setMj_insetR:(CGFloat)mj_insetR 52 | { 53 | UIEdgeInsets inset = self.contentInset; 54 | inset.right = mj_insetR; 55 | self.contentInset = inset; 56 | } 57 | 58 | - (CGFloat)mj_insetR 59 | { 60 | return self.contentInset.right; 61 | } 62 | 63 | - (void)setMj_offsetX:(CGFloat)mj_offsetX 64 | { 65 | CGPoint offset = self.contentOffset; 66 | offset.x = mj_offsetX; 67 | self.contentOffset = offset; 68 | } 69 | 70 | - (CGFloat)mj_offsetX 71 | { 72 | return self.contentOffset.x; 73 | } 74 | 75 | - (void)setMj_offsetY:(CGFloat)mj_offsetY 76 | { 77 | CGPoint offset = self.contentOffset; 78 | offset.y = mj_offsetY; 79 | self.contentOffset = offset; 80 | } 81 | 82 | - (CGFloat)mj_offsetY 83 | { 84 | return self.contentOffset.y; 85 | } 86 | 87 | - (void)setMj_contentW:(CGFloat)mj_contentW 88 | { 89 | CGSize size = self.contentSize; 90 | size.width = mj_contentW; 91 | self.contentSize = size; 92 | } 93 | 94 | - (CGFloat)mj_contentW 95 | { 96 | return self.contentSize.width; 97 | } 98 | 99 | - (void)setMj_contentH:(CGFloat)mj_contentH 100 | { 101 | CGSize size = self.contentSize; 102 | size.height = mj_contentH; 103 | self.contentSize = size; 104 | } 105 | 106 | - (CGFloat)mj_contentH 107 | { 108 | return self.contentSize.height; 109 | } 110 | @end 111 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 给ScrollView增加下拉刷新、上拉刷新的功能 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | 13 | @class MJRefreshHeader, MJRefreshFooter; 14 | 15 | @interface UIScrollView (MJRefresh) 16 | /** 下拉刷新控件 */ 17 | @property (strong, nonatomic) MJRefreshHeader *mj_header; 18 | @property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header"); 19 | /** 上拉刷新控件 */ 20 | @property (strong, nonatomic) MJRefreshFooter *mj_footer; 21 | @property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer"); 22 | 23 | #pragma mark - other 24 | - (NSInteger)mj_totalDataCount; 25 | @property (copy, nonatomic) void (^mj_reloadDataBlock)(NSInteger totalDataCount); 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJRefresh.h" 11 | #import "MJRefreshHeader.h" 12 | #import "MJRefreshFooter.h" 13 | #import 14 | 15 | @implementation NSObject (MJRefresh) 16 | 17 | + (void)exchangeInstanceMethod1:(SEL)method1 method2:(SEL)method2 18 | { 19 | method_exchangeImplementations(class_getInstanceMethod(self, method1), class_getInstanceMethod(self, method2)); 20 | } 21 | 22 | + (void)exchangeClassMethod1:(SEL)method1 method2:(SEL)method2 23 | { 24 | method_exchangeImplementations(class_getClassMethod(self, method1), class_getClassMethod(self, method2)); 25 | } 26 | 27 | @end 28 | 29 | @implementation UIScrollView (MJRefresh) 30 | 31 | #pragma mark - header 32 | static const char MJRefreshHeaderKey = '\0'; 33 | - (void)setMj_header:(MJRefreshHeader *)mj_header 34 | { 35 | if (mj_header != self.mj_header) { 36 | // 删除旧的,添加新的 37 | [self.mj_header removeFromSuperview]; 38 | [self insertSubview:mj_header atIndex:0]; 39 | 40 | // 存储新的 41 | [self willChangeValueForKey:@"mj_header"]; // KVO 42 | objc_setAssociatedObject(self, &MJRefreshHeaderKey, 43 | mj_header, OBJC_ASSOCIATION_ASSIGN); 44 | [self didChangeValueForKey:@"mj_header"]; // KVO 45 | } 46 | } 47 | 48 | - (MJRefreshHeader *)mj_header 49 | { 50 | return objc_getAssociatedObject(self, &MJRefreshHeaderKey); 51 | } 52 | 53 | #pragma mark - footer 54 | static const char MJRefreshFooterKey = '\0'; 55 | - (void)setMj_footer:(MJRefreshFooter *)mj_footer 56 | { 57 | if (mj_footer != self.mj_footer) { 58 | // 删除旧的,添加新的 59 | [self.mj_footer removeFromSuperview]; 60 | [self addSubview:mj_footer]; 61 | 62 | // 存储新的 63 | [self willChangeValueForKey:@"mj_footer"]; // KVO 64 | objc_setAssociatedObject(self, &MJRefreshFooterKey, 65 | mj_footer, OBJC_ASSOCIATION_ASSIGN); 66 | [self didChangeValueForKey:@"mj_footer"]; // KVO 67 | } 68 | } 69 | 70 | - (MJRefreshFooter *)mj_footer 71 | { 72 | return objc_getAssociatedObject(self, &MJRefreshFooterKey); 73 | } 74 | 75 | #pragma mark - 过期 76 | - (void)setFooter:(MJRefreshFooter *)footer 77 | { 78 | self.mj_footer = footer; 79 | } 80 | 81 | - (MJRefreshFooter *)footer 82 | { 83 | return self.mj_footer; 84 | } 85 | 86 | - (void)setHeader:(MJRefreshHeader *)header 87 | { 88 | self.mj_header = header; 89 | } 90 | 91 | - (MJRefreshHeader *)header 92 | { 93 | return self.mj_header; 94 | } 95 | 96 | #pragma mark - other 97 | - (NSInteger)mj_totalDataCount 98 | { 99 | NSInteger totalCount = 0; 100 | if ([self isKindOfClass:[UITableView class]]) { 101 | UITableView *tableView = (UITableView *)self; 102 | 103 | for (NSInteger section = 0; section 11 | 12 | @interface UIView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_x; 14 | @property (assign, nonatomic) CGFloat mj_y; 15 | @property (assign, nonatomic) CGFloat mj_w; 16 | @property (assign, nonatomic) CGFloat mj_h; 17 | @property (assign, nonatomic) CGSize mj_size; 18 | @property (assign, nonatomic) CGPoint mj_origin; 19 | @end 20 | -------------------------------------------------------------------------------- /Pods/MJRefresh/MJRefresh/UIView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIView+MJExtension.h" 11 | 12 | @implementation UIView (MJExtension) 13 | - (void)setMj_x:(CGFloat)mj_x 14 | { 15 | CGRect frame = self.frame; 16 | frame.origin.x = mj_x; 17 | self.frame = frame; 18 | } 19 | 20 | - (CGFloat)mj_x 21 | { 22 | return self.frame.origin.x; 23 | } 24 | 25 | - (void)setMj_y:(CGFloat)mj_y 26 | { 27 | CGRect frame = self.frame; 28 | frame.origin.y = mj_y; 29 | self.frame = frame; 30 | } 31 | 32 | - (CGFloat)mj_y 33 | { 34 | return self.frame.origin.y; 35 | } 36 | 37 | - (void)setMj_w:(CGFloat)mj_w 38 | { 39 | CGRect frame = self.frame; 40 | frame.size.width = mj_w; 41 | self.frame = frame; 42 | } 43 | 44 | - (CGFloat)mj_w 45 | { 46 | return self.frame.size.width; 47 | } 48 | 49 | - (void)setMj_h:(CGFloat)mj_h 50 | { 51 | CGRect frame = self.frame; 52 | frame.size.height = mj_h; 53 | self.frame = frame; 54 | } 55 | 56 | - (CGFloat)mj_h 57 | { 58 | return self.frame.size.height; 59 | } 60 | 61 | - (void)setMj_size:(CGSize)mj_size 62 | { 63 | CGRect frame = self.frame; 64 | frame.size = mj_size; 65 | self.frame = frame; 66 | } 67 | 68 | - (CGSize)mj_size 69 | { 70 | return self.frame.size; 71 | } 72 | 73 | - (void)setMj_origin:(CGPoint)mj_origin 74 | { 75 | CGRect frame = self.frame; 76 | frame.origin = mj_origin; 77 | self.frame = frame; 78 | } 79 | 80 | - (CGPoint)mj_origin 81 | { 82 | return self.frame.origin; 83 | } 84 | @end 85 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.0.1): 3 | - AFNetworking/NSURLSession (= 3.0.1) 4 | - AFNetworking/Reachability (= 3.0.1) 5 | - AFNetworking/Security (= 3.0.1) 6 | - AFNetworking/Serialization (= 3.0.1) 7 | - AFNetworking/UIKit (= 3.0.1) 8 | - AFNetworking/NSURLSession (3.0.1): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.0.1) 13 | - AFNetworking/Security (3.0.1) 14 | - AFNetworking/Serialization (3.0.1) 15 | - AFNetworking/UIKit (3.0.1): 16 | - AFNetworking/NSURLSession 17 | - MJRefresh (3.0.7) 18 | 19 | DEPENDENCIES: 20 | - AFNetworking (~> 3.0.1) 21 | - MJRefresh 22 | 23 | SPEC CHECKSUMS: 24 | AFNetworking: 20d8749e03e45f1e5c046ad0b647e0b07bcdd91f 25 | MJRefresh: f3e1228ec3d38c7ba5208d58032631a52f39f495 26 | 27 | COCOAPODS: 0.39.0 28 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/DaZuo.xcuserdatad/xcschemes/AFNetworking.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/DaZuo.xcuserdatad/xcschemes/Pods.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/DaZuo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | 12 | MJRefresh.xcscheme 13 | 14 | isShown 15 | 16 | 17 | Pods.xcscheme 18 | 19 | isShown 20 | 21 | 22 | 23 | SuppressBuildableAutocreation 24 | 25 | 8F74D9EA91F4C43190670066BAC37D44 26 | 27 | primary 28 | 29 | 30 | 928353533005A4198EBDA5B700D37B64 31 | 32 | primary 33 | 34 | 35 | F849236A7E253E981131C345B30297E8 36 | 37 | primary 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #ifndef TARGET_OS_IOS 6 | #define TARGET_OS_IOS TARGET_OS_IPHONE 7 | #endif 8 | 9 | #ifndef TARGET_OS_WATCH 10 | #define TARGET_OS_WATCH 0 11 | #endif 12 | 13 | #ifndef TARGET_OS_TV 14 | #define TARGET_OS_TV 0 15 | #endif 16 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" 3 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 4 | PODS_ROOT = ${SRCROOT} 5 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/MJRefresh/MJRefresh-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MJRefresh : NSObject 3 | @end 4 | @implementation PodsDummy_MJRefresh 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MJRefresh/MJRefresh-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/MJRefresh/MJRefresh.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MJRefresh" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" 3 | PODS_ROOT = ${SRCROOT} 4 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 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 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all 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 | ## MJRefresh 28 | 29 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | 49 | Generated by CocoaPods - http://cocoapods.org 50 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-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) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 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 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all 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 | Title 38 | AFNetworking 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 45 | 46 | Permission is hereby granted, free of charge, to any person obtaining a copy 47 | of this software and associated documentation files (the "Software"), to deal 48 | in the Software without restriction, including without limitation the rights 49 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 50 | copies of the Software, and to permit persons to whom the Software is 51 | furnished to do so, subject to the following conditions: 52 | 53 | The above copyright notice and this permission notice shall be included in 54 | all copies or substantial portions of the Software. 55 | 56 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 57 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 58 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 59 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 60 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 61 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 62 | THE SOFTWARE. 63 | 64 | Title 65 | MJRefresh 66 | Type 67 | PSGroupSpecifier 68 | 69 | 70 | FooterText 71 | Generated by CocoaPods - http://cocoapods.org 72 | Title 73 | 74 | Type 75 | PSGroupSpecifier 76 | 77 | 78 | StringsTable 79 | Acknowledgements 80 | Title 81 | Acknowledgements 82 | 83 | 84 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-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="${CONFIGURATION_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} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --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 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_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 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | if [[ "$CONFIGURATION" == "Debug" ]]; then 61 | install_resource "MJRefresh/MJRefresh/MJRefresh.bundle" 62 | fi 63 | if [[ "$CONFIGURATION" == "Release" ]]; then 64 | install_resource "MJRefresh/MJRefresh/MJRefresh.bundle" 65 | fi 66 | 67 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 68 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 69 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 70 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 71 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 72 | fi 73 | rm -f "$RESOURCES_TO_COPY" 74 | 75 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 76 | then 77 | case "${TARGETED_DEVICE_FAMILY}" in 78 | 1,2) 79 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 80 | ;; 81 | 1) 82 | TARGET_DEVICE_ARGS="--target-device iphone" 83 | ;; 84 | 2) 85 | TARGET_DEVICE_ARGS="--target-device ipad" 86 | ;; 87 | *) 88 | TARGET_DEVICE_ARGS="--target-device mac" 89 | ;; 90 | esac 91 | 92 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 93 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 94 | while read line; do 95 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 96 | XCASSET_FILES+=("$line") 97 | fi 98 | done <<<"$OTHER_XCASSETS" 99 | 100 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 101 | fi 102 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/MJRefresh" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"MJRefresh" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/MJRefresh" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"MJRefresh" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | PODS_ROOT = ${SRCROOT}/Pods --------------------------------------------------------------------------------