Commit 6f9c6634686f4c9072cc6bb9e92dcb349157aaaf
1 parent
3729e923
提取节日图片下载
Showing
36 changed files
with
4191 additions
and
17 deletions
Too many changes to show.
To preserve performance only 36 of 796 files are displayed.
CNLiveBaseTools.podspec
| 1 | 1 | ||
| 2 | Pod::Spec.new do |s| | 2 | Pod::Spec.new do |s| |
| 3 | s.name = 'CNLiveBaseTools' | 3 | s.name = 'CNLiveBaseTools' |
| 4 | - s.version = '0.0.3' | 4 | + s.version = '0.0.4' |
| 5 | s.summary = '基础工具库时间声音等工具' | 5 | s.summary = '基础工具库时间声音等工具' |
| 6 | 6 | ||
| 7 | s.description = <<-DESC | 7 | s.description = <<-DESC |
| @@ -15,10 +15,10 @@ TODO: Add long description of the pod here. | @@ -15,10 +15,10 @@ TODO: Add long description of the pod here. | ||
| 15 | s.source = { :git => 'http://bj.gitlab.cnlive.com/ios-team/CNLiveBaseTools.git', :tag => s.version.to_s } | 15 | s.source = { :git => 'http://bj.gitlab.cnlive.com/ios-team/CNLiveBaseTools.git', :tag => s.version.to_s } |
| 16 | # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' | 16 | # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' |
| 17 | 17 | ||
| 18 | - s.ios.deployment_target = '9.0' | 18 | + s.ios.deployment_target = '10.0' |
| 19 | 19 | ||
| 20 | - s.source_files = 'CNLiveBaseTools/Classes/**/*' | ||
| 21 | - | 20 | + s.source_files = 'CNLiveBaseTools/Classes/**/**/*' |
| 21 | + s.prefix_header_contents = '#import "CNLiveBaseTools.h"' | ||
| 22 | # s.resource_bundles = { | 22 | # s.resource_bundles = { |
| 23 | # 'CNLiveBaseTools' => ['CNLiveBaseTools/Assets/*.png'] | 23 | # 'CNLiveBaseTools' => ['CNLiveBaseTools/Assets/*.png'] |
| 24 | # } | 24 | # } |
| @@ -26,4 +26,11 @@ TODO: Add long description of the pod here. | @@ -26,4 +26,11 @@ TODO: Add long description of the pod here. | ||
| 26 | # s.public_header_files = 'Pod/Classes/**/*.h' | 26 | # s.public_header_files = 'Pod/Classes/**/*.h' |
| 27 | s.frameworks = 'UIKit', 'Foundation' | 27 | s.frameworks = 'UIKit', 'Foundation' |
| 28 | # s.dependency 'AFNetworking', '~> 2.3' | 28 | # s.dependency 'AFNetworking', '~> 2.3' |
| 29 | + s.dependency 'CNLiveNewTripartiteManagement/SSZipArchive' | ||
| 30 | + s.dependency 'CNLiveNewTripartiteManagement/YYImage' | ||
| 31 | + s.dependency 'CNLiveNewTripartiteManagement/SDWebImage' | ||
| 32 | + s.dependency 'CNLiveNewTripartiteManagement/YYCategories' | ||
| 33 | + s.dependency 'CNLiveNewTripartiteManagement/QMUIKit' | ||
| 34 | + s.dependency 'CNLiveBaseKit' | ||
| 35 | + s.dependency 'CNLiveBeeHive' | ||
| 29 | end | 36 | end |
CNLiveBaseTools/Classes/TabBarEditIcon/CNEditAppIconModel.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNEditAppIconModel.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/26. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | +@class CNEditAppIconDetailModel; | ||
| 11 | + | ||
| 12 | +NS_ASSUME_NONNULL_BEGIN | ||
| 13 | + | ||
| 14 | +@interface CNEditAppIconModel : NSObject | ||
| 15 | + | ||
| 16 | +/*** 详情 ***/ | ||
| 17 | +@property (nonatomic, strong) CNEditAppIconDetailModel *holidayTheme; | ||
| 18 | +/*** isShow 0:显示 1:不显示 ***/ | ||
| 19 | +@property (nonatomic, strong) NSString *isShow; | ||
| 20 | +/*** 安卓参数 ***/ | ||
| 21 | +@property (nonatomic, strong) NSString *androidIsShow; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +@end | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +NS_ASSUME_NONNULL_END | ||
| 28 | + | ||
| 29 | +NS_ASSUME_NONNULL_BEGIN | ||
| 30 | + | ||
| 31 | +@interface CNEditAppIconDetailModel : NSObject | ||
| 32 | + | ||
| 33 | +/*** 头 ***/ | ||
| 34 | +@property (nonatomic, strong) NSString *title; | ||
| 35 | +/*** 建立时间 ***/ | ||
| 36 | +@property (nonatomic, strong) NSString *create_time; | ||
| 37 | +///*** 未知 ***/ | ||
| 38 | +//@property (nonatomic, strong) NSString *extension; | ||
| 39 | +/*** 图片数组(不用) ***/ | ||
| 40 | +@property (nonatomic, strong) NSMutableArray *themeIcon; | ||
| 41 | + | ||
| 42 | +/*** iOS ***/ | ||
| 43 | + | ||
| 44 | +/*** iOS安卓节日ID ***/ | ||
| 45 | +@property (nonatomic, strong) NSString *detailId; | ||
| 46 | +/*** iOS点击前颜色 ***/ | ||
| 47 | +@property (nonatomic, strong) NSString *clickBefore; | ||
| 48 | +/*** iOS点击后颜色 ***/ | ||
| 49 | +@property (nonatomic, strong) NSString *clickAfter; | ||
| 50 | +/*** iOS ID(根据资源包变化) ***/ | ||
| 51 | +@property (nonatomic, strong) NSString *iosId; | ||
| 52 | +/*** iOS图片包路径 ***/ | ||
| 53 | +@property (nonatomic, strong) NSString *ios_imagePackage; | ||
| 54 | +/*** showSource": 0:本地 1 本地节日,2网络节日 ***/ | ||
| 55 | +@property (nonatomic, strong) NSString *showSource; | ||
| 56 | +/*** iOS文字,颜色,更变 ***/ | ||
| 57 | +@property (nonatomic, strong) NSString *updateType; | ||
| 58 | +/*** iOS(安卓)总开关 ***/ | ||
| 59 | +@property (nonatomic, strong) NSString *holidayThemeStatus; | ||
| 60 | +/*** iOS开关 ***/ | ||
| 61 | +@property (nonatomic, strong) NSString *status; | ||
| 62 | +/*** 用于(本地节日)版本对比 ***/ | ||
| 63 | +@property (nonatomic, strong) NSString *iosThemeIdentify; | ||
| 64 | + | ||
| 65 | + | ||
| 66 | +/*** 安卓参数 ***/ | ||
| 67 | +/*** 安卓点击后颜色 ***/ | ||
| 68 | +@property (nonatomic, strong) NSString *androidClickAfter; | ||
| 69 | +/*** 安卓点击前颜色 ***/ | ||
| 70 | +@property (nonatomic, strong) NSString *androidClickBefore; | ||
| 71 | +/*** 安卓变化id 根据资源包变化 ***/ | ||
| 72 | +@property (nonatomic, strong) NSString *androidThemeId; | ||
| 73 | +/*** 安卓资源包路径 ***/ | ||
| 74 | +@property (nonatomic, strong) NSString *androidImagePackage; | ||
| 75 | +/*** 安卓androidShowSource": 0:本地 1 本地节日,2网络节日 ***/ | ||
| 76 | +@property (nonatomic, strong) NSString *androidShowSource; | ||
| 77 | +/*** 安卓开关 ***/ | ||
| 78 | +@property (nonatomic, strong) NSString *androidStatus; | ||
| 79 | +/*** 安卓防止版本问题(新旧对比) ***/ | ||
| 80 | +@property (nonatomic, strong) NSString *androidThemeIdentify; | ||
| 81 | +/*** 安卓(更变颜色,文字更新状态) ***/ | ||
| 82 | +@property (nonatomic, strong) NSString *androidUpdateType; | ||
| 83 | + | ||
| 84 | + | ||
| 85 | +@end | ||
| 86 | + | ||
| 87 | +NS_ASSUME_NONNULL_END | ||
| 88 | + |
CNLiveBaseTools/Classes/TabBarEditIcon/CNEditAppIconModel.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNEditAppIconModel.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/26. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNEditAppIconModel.h" | ||
| 10 | + | ||
| 11 | +@implementation CNEditAppIconModel | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +@end | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +@implementation CNEditAppIconDetailModel | ||
| 19 | + | ||
| 20 | ++(NSDictionary *)mj_replacedKeyFromPropertyName | ||
| 21 | +{ | ||
| 22 | + return @{@"detailId":@"id"}; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/CNLiveBaseTools.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveBaseTools.h | ||
| 3 | +// Pods | ||
| 4 | +// | ||
| 5 | +// Created by CNLive on 2022/1/27. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +#ifndef CNLiveBaseTools_h | ||
| 9 | +#define CNLiveBaseTools_h | ||
| 10 | +//存放要下载的 生活圈,订阅号,优选库 gif图 URL 地址 | ||
| 11 | +static NSString *const CNHomePageGifUrlData = @"CNHomePageGifUrlData"; | ||
| 12 | +//生活圈gif名称 | ||
| 13 | +static NSString *const CNMomentGitName = @"CNMomentGitName"; | ||
| 14 | +//订阅号gif名称 | ||
| 15 | +static NSString *const CNSubscribeGitName = @"CNSubscribeGitName"; | ||
| 16 | +//优选库gif名称 | ||
| 17 | +static NSString *const CNYouxuanGitName = @"CNYouxuanGitName"; | ||
| 18 | +#pragma mark - APP皮肤 | ||
| 19 | +/*** 皮肤dic ***/ | ||
| 20 | +static NSString *const kHolidayThemeMap = @"holidayThemeMap"; | ||
| 21 | + | ||
| 22 | +/*** 皮肤userDefult ***/ | ||
| 23 | +static NSString *const kHolidayKey = @"HolidayKey"; | ||
| 24 | + | ||
| 25 | +/*** 皮肤新皮肤 ***/ | ||
| 26 | +static NSString *const kHolidayKey_New = @"HolidayKey_New"; | ||
| 27 | + | ||
| 28 | +/*** 皮肤新皮肤 ***/ | ||
| 29 | +static NSString *const kIosThemeIdentify = @"IosThemeIdentify"; | ||
| 30 | +#pragma mark - 注意:每次发版更改这个key和web绑定 | ||
| 31 | +/*** 节日key用于新老版本判断(写死) ***/ | ||
| 32 | +static NSString *const kNew_OldHolidayVersion = @"DragonBoatFestival"; | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +#endif /* CNLiveBaseTools_h */ |
CNLiveBaseTools/Classes/TabBarEditIcon/CNLiveEditAPPIconController.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveEditAPPIconController.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/8/20. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <UIKit/UIKit.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | + | ||
| 13 | +@interface CNLiveEditAPPIconController : UIViewController | ||
| 14 | + | ||
| 15 | +@end | ||
| 16 | + | ||
| 17 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/CNLiveEditAPPIconController.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveEditAPPIconController.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/8/20. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveEditAPPIconController.h" | ||
| 10 | +//#import "CNTabBar.h" | ||
| 11 | +#import "CNLiveEditAppIconManager.h" | ||
| 12 | +#import "CNLiveWebImageManager.h" | ||
| 13 | +#import "CNLiveWebDownLoadManager.h" | ||
| 14 | +#import "CNEditAppIconModel.h" | ||
| 15 | +#import "CNLiveWebZipManager.h" | ||
| 16 | +#import "NSFileManager+ImgPath.h" | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +@interface CNLiveEditAPPIconController () | ||
| 21 | + | ||
| 22 | +@property (strong, nonatomic) NSMutableDictionary *holidayDic; | ||
| 23 | + | ||
| 24 | +@end | ||
| 25 | + | ||
| 26 | +@implementation CNLiveEditAPPIconController | ||
| 27 | + | ||
| 28 | +- (void)viewDidLoad { | ||
| 29 | + [super viewDidLoad]; | ||
| 30 | + // Do any additional setup after loading the view. | ||
| 31 | + [self.view setBackgroundColor:[UIColor whiteColor]]; | ||
| 32 | + | ||
| 33 | + UIButton *testBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 34 | + [self.view addSubview:testBtn]; | ||
| 35 | + testBtn.frame = CGRectMake(10, 10, 100, 100); | ||
| 36 | + [testBtn setTitle:@"更变" forState:UIControlStateNormal]; | ||
| 37 | + [testBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 38 | + testBtn.backgroundColor = [UIColor yellowColor]; | ||
| 39 | + [testBtn addTarget:self action:@selector(testBtnAction:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 40 | + | ||
| 41 | + UIButton *testBtn1 = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 42 | + [self.view addSubview:testBtn1]; | ||
| 43 | + testBtn1.frame = CGRectMake(10, 120, 100, 100); | ||
| 44 | + [testBtn1 setTitle:@"默认" forState:UIControlStateNormal]; | ||
| 45 | + [testBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 46 | + testBtn1.backgroundColor = [UIColor yellowColor]; | ||
| 47 | + [testBtn1 addTarget:self action:@selector(test1BtnAction:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 48 | + | ||
| 49 | + UIButton *testBtn2 = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 50 | + [self.view addSubview:testBtn2]; | ||
| 51 | + testBtn2.frame = CGRectMake(10, 230, 100, 100); | ||
| 52 | + [testBtn2 setTitle:@"网络" forState:UIControlStateNormal]; | ||
| 53 | + [testBtn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 54 | + testBtn2.backgroundColor = [UIColor yellowColor]; | ||
| 55 | + [testBtn2 addTarget:self action:@selector(test2BtnAction:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 56 | + | ||
| 57 | + UIButton *testBtn3 = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 58 | + [self.view addSubview:testBtn3]; | ||
| 59 | + testBtn3.frame = CGRectMake(10, 340, 100, 100); | ||
| 60 | + [testBtn3 setTitle:@"存储默认参数" forState:UIControlStateNormal]; | ||
| 61 | + [testBtn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 62 | + testBtn3.backgroundColor = [UIColor yellowColor]; | ||
| 63 | + [testBtn3 addTarget:self action:@selector(test3BtnAction:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 64 | + | ||
| 65 | + UIButton *testBtn4 = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 66 | + [self.view addSubview:testBtn4]; | ||
| 67 | + testBtn4.frame = CGRectMake(10, 340, 100, 100); | ||
| 68 | + [testBtn4 setTitle:@"更改默认参数" forState:UIControlStateNormal]; | ||
| 69 | + [testBtn4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 70 | + testBtn4.backgroundColor = [UIColor yellowColor]; | ||
| 71 | + [testBtn4 addTarget:self action:@selector(test4BtnAction:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 72 | + | ||
| 73 | + UIButton *testBtn5 = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 74 | + [self.view addSubview:testBtn5]; | ||
| 75 | + testBtn5.frame = CGRectMake(120, 10, 100, 100); | ||
| 76 | + [testBtn5 setTitle:@"下载" forState:UIControlStateNormal]; | ||
| 77 | + [testBtn5 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | ||
| 78 | + testBtn5.backgroundColor = [UIColor yellowColor]; | ||
| 79 | + [testBtn5 addTarget:self action:@selector(testBtn5Action:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +#pragma mark - 更变 | ||
| 88 | +- (void)testBtnAction:(UIButton *)sender { | ||
| 89 | + [CNLiveEditAppIconManager startDownLoadZip]; | ||
| 90 | + | ||
| 91 | + | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +#pragma mark - 还原 | ||
| 95 | +- (void)test1BtnAction:(UIButton *)sender { | ||
| 96 | + | ||
| 97 | + | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +- (void)test2BtnAction:(UIButton *)sender { | ||
| 101 | + | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + | ||
| 105 | +} | ||
| 106 | + | ||
| 107 | + | ||
| 108 | +/*** 1. 先存储 ***/ | ||
| 109 | +- (void)test3BtnAction:(UIButton *)sender { | ||
| 110 | + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | ||
| 111 | + [userDefaults setObject:self.holidayDic forKey:@"holidayDic"]; | ||
| 112 | + | ||
| 113 | + | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +- (void)test4BtnAction:(UIButton *)sender { | ||
| 117 | + | ||
| 118 | + // UIImage *image = [UIImage imageNamed:@"tabbar_fuwu_selectedq@3x"]; | ||
| 119 | + // NSData *imgData = UIImagePNGRepresentation(image); | ||
| 120 | + // | ||
| 121 | + // /*** 创建缓存路径 ***/ | ||
| 122 | + // NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"tabbar_fuwu_selectedq@3x"]; | ||
| 123 | + // | ||
| 124 | + // BOOL isSuccess = [imgData writeToFile:cachePath atomically:YES]; | ||
| 125 | + // if (isSuccess) { | ||
| 126 | + // NSLog(@"写入成功"); | ||
| 127 | + // }else { | ||
| 128 | + // NSLog(@"未写入成功"); | ||
| 129 | + // } | ||
| 130 | + // | ||
| 131 | + // __block CNTabBarViewController *tabBarVC = nil; | ||
| 132 | + // NSArray *windows = [UIApplication sharedApplication].windows; | ||
| 133 | + // [windows enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 134 | + // UIWindow *window = obj; | ||
| 135 | + // if (window) { | ||
| 136 | + // UIViewController *rootVC = window.rootViewController; | ||
| 137 | + // if (rootVC) { | ||
| 138 | + // if ([rootVC isKindOfClass:[CNTabBarViewController class]]) {//是主TabBarVC | ||
| 139 | + // CNTabBarViewController *barVC = (CNTabBarViewController *)rootVC; | ||
| 140 | + // tabBarVC = barVC; | ||
| 141 | + // } | ||
| 142 | + // } | ||
| 143 | + // } | ||
| 144 | + // | ||
| 145 | + // }]; | ||
| 146 | + // /*** 没有返回 ***/ | ||
| 147 | + // if (!tabBarVC) { | ||
| 148 | + // return; | ||
| 149 | + // } | ||
| 150 | + // UIImage *showImg = [UIImage imageWithContentsOfFile:cachePath]; | ||
| 151 | + // UITabBarItem *tabBarItem = tabBarVC.tabBar.items[0]; | ||
| 152 | + // tabBarItem.image = [showImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | ||
| 153 | + // tabBarItem.imageInsets = UIEdgeInsetsZero; | ||
| 154 | + | ||
| 155 | + | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +- (void)testBtn5Action:(UIButton *)sender { | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + | ||
| 162 | + | ||
| 163 | + | ||
| 164 | + | ||
| 165 | +#pragma mark - 下载 | ||
| 166 | + | ||
| 167 | + NSString *str = [NSString stringWithFormat:@"%@",@"http://test.qnvod.cnlive.com/802/img/2019/1127/1574855309684.zip"]; | ||
| 168 | + | ||
| 169 | + if ([[CNLiveWebDownLoadManager sharedInstance] checkLoadedWithDownloadUrl:str]) { | ||
| 170 | + | ||
| 171 | + NSString *zipPath = [[CNLiveWebDownLoadManager sharedInstance] getLoadZipPathWithDownloadUrl:str]; | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + NSLog(@"已经下载过了 路径 = %@",zipPath); | ||
| 175 | +#pragma mark - TODO:取得文件解压 | ||
| 176 | + | ||
| 177 | + [[CNLiveWebZipManager sharedInstance]unZipWithZipPath:zipPath downloadUrl:str resultBlock:^(Boolean isSuccess, NSString * _Nonnull hostPath, NSArray * _Nonnull array, Boolean isUnpack) { | ||
| 178 | + | ||
| 179 | + //解压结束储存地址 | ||
| 180 | + NSLog(@"是否成功-----%d, hostPath----%@,目录下文件-----%@,是否解压过-------%d",isSuccess,hostPath,array,isUnpack); | ||
| 181 | + | ||
| 182 | + __block UITabBarController *tabBarVC = nil; | ||
| 183 | + NSArray *windows = [UIApplication sharedApplication].windows; | ||
| 184 | + [windows enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 185 | + UIWindow *window = obj; | ||
| 186 | + if (window) { | ||
| 187 | + UIViewController *rootVC = window.rootViewController; | ||
| 188 | + if (rootVC) { | ||
| 189 | + if ([rootVC isKindOfClass:NSClassFromString(@"CNTabBarViewController")]) {//是主TabBarVC | ||
| 190 | + UITabBarController *barVC = (UITabBarController *)rootVC; | ||
| 191 | + tabBarVC = barVC; | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + }]; | ||
| 197 | + /*** 没有返回 ***/ | ||
| 198 | + if (!tabBarVC) { | ||
| 199 | + return; | ||
| 200 | + } | ||
| 201 | + NSString *cachePath = [[CNLiveWebZipManager sharedInstance] getImagePathWithLoadUrl:str name:@"APPICON" key:@"tabbar_fuwu_selected@3x"]; | ||
| 202 | + UIImage *showImg = [UIImage imageWithContentsOfFile:cachePath]; | ||
| 203 | + UITabBarItem *tabBarItem = tabBarVC.tabBar.items[0]; | ||
| 204 | + tabBarItem.image = [showImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | ||
| 205 | + tabBarItem.imageInsets = UIEdgeInsetsZero; | ||
| 206 | + | ||
| 207 | + }]; | ||
| 208 | + | ||
| 209 | + | ||
| 210 | + | ||
| 211 | + | ||
| 212 | + | ||
| 213 | + return; | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + [[CNLiveWebDownLoadManager sharedInstance] downLoadWithURL:str progress:^(NSString * _Nonnull url, float progress) { | ||
| 217 | + | ||
| 218 | + | ||
| 219 | + | ||
| 220 | + } success:^(NSString * _Nonnull url, NSString * _Nonnull fileStorePath) { | ||
| 221 | + | ||
| 222 | + NSLog(@"下载成功"); | ||
| 223 | + | ||
| 224 | + | ||
| 225 | + } faile:^(NSString * _Nonnull url, NSError * _Nonnull error) { | ||
| 226 | + | ||
| 227 | + | ||
| 228 | + | ||
| 229 | + | ||
| 230 | + }]; | ||
| 231 | + | ||
| 232 | + | ||
| 233 | +} | ||
| 234 | + | ||
| 235 | + | ||
| 236 | + | ||
| 237 | + | ||
| 238 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/CNLiveEditAppIconManager.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveEditAppIcon.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/8/22. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | +#import "UIImage+EditIcon.h" | ||
| 11 | +#import "CNEditAppIconModel.h" | ||
| 12 | + | ||
| 13 | +#pragma mark - 更改APPIcon | ||
| 14 | +/*** 状态 ***/ | ||
| 15 | +typedef NS_ENUM(NSUInteger, EditAppIconStatus) { | ||
| 16 | + EditAppIconStatusNormal,//默认 | ||
| 17 | + EditAppIconStatusLocChange,//本地更变 | ||
| 18 | + EditAppIconStatusNet,//网络更变 | ||
| 19 | +}; | ||
| 20 | + | ||
| 21 | +/*** 网络下载状态取得 ***/ | ||
| 22 | +typedef NS_ENUM(NSUInteger, DownLoadAppIconStatus) { | ||
| 23 | + DownLoadAppIconStatusNormal,//未下载 | ||
| 24 | + DownLoadAppIconStatusZipAndUnZip,//已下载zip | ||
| 25 | + EditAppIconStatusSucess,//已下载zip并解压成功 | ||
| 26 | +}; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +NS_ASSUME_NONNULL_BEGIN | ||
| 30 | + | ||
| 31 | +@interface CNLiveEditAppIconManager : NSObject | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +/*** 用于本地版本节日判断 ***/ | ||
| 35 | ++ (BOOL)saveFirstHolidayWithDic:(NSDictionary *)holidayDic; | ||
| 36 | + | ||
| 37 | +/*** 获取最新图标信息 ***/ | ||
| 38 | ++ (void)editNewiconMsgWithDic:(NSDictionary *)holidayDic; | ||
| 39 | + | ||
| 40 | +/*** 新数据替换旧数据,使用在tabbaar创建之前,在获取最新参数之前 ***/ | ||
| 41 | ++ (void)iconMsgNewReplaceOld; | ||
| 42 | + | ||
| 43 | +/*** 下载zip并解压(只用于新数据) ***/ | ||
| 44 | ++ (void)startDownLoadZip; | ||
| 45 | + | ||
| 46 | +/*** 获取状态只用于旧数据 ***/ | ||
| 47 | ++ (EditAppIconStatus)getEditAppIconStatus; | ||
| 48 | + | ||
| 49 | +/*** 只对网络进行判断 kHolidayKey或kHolidayKey_new ***/ | ||
| 50 | ++ (DownLoadAppIconStatus)editNetAppIconDownloadWithKey:(NSString *)key; | ||
| 51 | + | ||
| 52 | +/*** 取得旧数据路径图片 ***/ | ||
| 53 | ++ (NSString *)getPathWithKey:(NSString *)key; | ||
| 54 | + | ||
| 55 | +/*** 根据数据更变颜色 ***/ | ||
| 56 | ++ (void)editItemTitleColor; | ||
| 57 | + | ||
| 58 | +/*** 删除所有zip包及所有解压文件 ***/ | ||
| 59 | ++ (void)removeAllZipAndDownLoad; | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + | ||
| 63 | +@end | ||
| 64 | + | ||
| 65 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/CNLiveEditAppIconManager.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveEditAppIcon.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/8/22. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveEditAppIconManager.h" | ||
| 10 | +#import "CNLiveWebDownLoadManager.h" | ||
| 11 | +#import "CNLiveWebZipManager.h" | ||
| 12 | +#import <MJExtension/MJExtension.h> | ||
| 13 | +#import <QMUIKit/QMUIKit.h> | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +@implementation CNLiveEditAppIconManager | ||
| 17 | + | ||
| 18 | +/*** 用于本地版本节日判断 ***/ | ||
| 19 | ++ (BOOL)saveFirstHolidayWithDic:(NSDictionary *)holidayDic{ | ||
| 20 | + | ||
| 21 | + if (!holidayDic || holidayDic.count <= 0) { | ||
| 22 | + return NO; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:holidayDic]; | ||
| 26 | + CNEditAppIconDetailModel *detailModel = iconModel.holidayTheme; | ||
| 27 | + if (!detailModel) { | ||
| 28 | + NSString *iosThemeIdentify = [NSString stringWithFormat:@"%@",detailModel.iosThemeIdentify ? detailModel.iosThemeIdentify : @""]; | ||
| 29 | + if ([iosThemeIdentify isEqualToString:kNew_OldHolidayVersion]) { | ||
| 30 | + return YES; | ||
| 31 | + }else { | ||
| 32 | + return NO; | ||
| 33 | + } | ||
| 34 | + }else { | ||
| 35 | + return NO; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +/*** 获取最新图标信息 ***/ | ||
| 41 | ++ (void)editNewiconMsgWithDic:(NSDictionary *)holidayDic { | ||
| 42 | + | ||
| 43 | + if (!holidayDic || holidayDic.count <= 0) { | ||
| 44 | + return; | ||
| 45 | + } | ||
| 46 | + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | ||
| 47 | + /*** 将新数据存入新key中 ***/ | ||
| 48 | + [userDefaults setObject:holidayDic forKey:kHolidayKey_New]; | ||
| 49 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | + | ||
| 53 | +/*** 新数据替换旧数据,使用在tabbaar创建之前,在获取最新参数之前 ***/ | ||
| 54 | ++ (void)iconMsgNewReplaceOld { | ||
| 55 | + | ||
| 56 | + /*** ***/ | ||
| 57 | + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | ||
| 58 | + /*** 取得旧数据,存在存入旧key中,不存在清空旧key ***/ | ||
| 59 | + NSDictionary *oldHolidyDic = [userDefaults objectForKey:kHolidayKey_New]; | ||
| 60 | + if (oldHolidyDic && oldHolidyDic.count > 0) { | ||
| 61 | + [userDefaults setObject:oldHolidyDic forKey:kHolidayKey]; | ||
| 62 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 63 | + }else { | ||
| 64 | + [userDefaults removeObjectForKey:kHolidayKey]; | ||
| 65 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | + | ||
| 71 | +/*** 下载zip并解压(只用于新数据) ***/ | ||
| 72 | ++ (void)startDownLoadZip { | ||
| 73 | + dispatch_async(dispatch_get_global_queue(0,0), ^{ | ||
| 74 | +#pragma mark - TODO: 新数据和旧数据对比更改就删除旧数据(暂时不做逻辑受限,后期优化逻辑) | ||
| 75 | + EditAppIconStatus iconStatus = [CNLiveEditAppIconManager getEditAppIconStatusWithKey:kHolidayKey_New]; | ||
| 76 | + if (iconStatus != EditAppIconStatusNet) { | ||
| 77 | + return; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + DownLoadAppIconStatus downLoadStatus = [CNLiveEditAppIconManager editNetAppIconDownloadWithKey:kHolidayKey_New]; | ||
| 81 | + if (downLoadStatus == DownLoadAppIconStatusNormal) {//没下载没解压 | ||
| 82 | + | ||
| 83 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:kHolidayKey_New]; | ||
| 84 | + if (dic && dic.count > 0) { | ||
| 85 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 86 | + if (iconModel.holidayTheme) { | ||
| 87 | + CNEditAppIconDetailModel *iconDetailModel = iconModel.holidayTheme; | ||
| 88 | + NSString *downLoadStr = [NSString stringWithFormat:@"%@",iconDetailModel.ios_imagePackage ? iconDetailModel.ios_imagePackage : @""]; | ||
| 89 | + if (!downLoadStr || downLoadStr.length == 0) { | ||
| 90 | + return; | ||
| 91 | + } | ||
| 92 | + [[CNLiveWebDownLoadManager sharedInstance] downLoadWithURL:downLoadStr progress:^(NSString * _Nonnull url, float progress) { | ||
| 93 | + | ||
| 94 | + } success:^(NSString * _Nonnull url, NSString * _Nonnull fileStorePath) { | ||
| 95 | + | ||
| 96 | + NSString *fileStorePathStr = [NSString stringWithFormat:@"%@",fileStorePath ? fileStorePath : @""]; | ||
| 97 | + if (!downLoadStr || downLoadStr.length == 0 || !fileStorePathStr || fileStorePathStr.length == 0) { | ||
| 98 | + return; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + [[CNLiveWebZipManager sharedInstance] unZipWithZipPath:fileStorePathStr downloadUrl:downLoadStr resultBlock:^(Boolean isSuccess, NSString * _Nonnull hostPath, NSArray * _Nonnull array, Boolean isUnpack) { | ||
| 102 | + | ||
| 103 | + //解压结束储存地址 | ||
| 104 | + NSLog(@"是否成功-----%d, hostPath----%@,目录下文件-----%@,是否解压过-------%d",isSuccess,hostPath,array,isUnpack); | ||
| 105 | + | ||
| 106 | + | ||
| 107 | + }]; | ||
| 108 | + | ||
| 109 | + | ||
| 110 | + } faile:^(NSString * _Nonnull url, NSError * _Nonnull error) { | ||
| 111 | + | ||
| 112 | + }]; | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + }else if (downLoadStatus == DownLoadAppIconStatusZipAndUnZip) {//下载并解压 | ||
| 117 | + | ||
| 118 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:kHolidayKey_New]; | ||
| 119 | + if (dic && dic.count > 0) { | ||
| 120 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 121 | + if (iconModel.holidayTheme) { | ||
| 122 | + CNEditAppIconDetailModel *iconDetailModel = iconModel.holidayTheme; | ||
| 123 | + NSString *downLoadStr = [NSString stringWithFormat:@"%@",iconDetailModel.ios_imagePackage ? iconDetailModel.ios_imagePackage : @"" ]; | ||
| 124 | + NSString *zipPath = [[CNLiveWebDownLoadManager sharedInstance] getLoadZipPathWithDownloadUrl:downLoadStr]; | ||
| 125 | + if (!downLoadStr || downLoadStr.length == 0 || !zipPath || zipPath.length == 0) { | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + [[CNLiveWebZipManager sharedInstance] unZipWithZipPath:zipPath downloadUrl:downLoadStr resultBlock:^(Boolean isSuccess, NSString * _Nonnull hostPath, NSArray * _Nonnull array, Boolean isUnpack) { | ||
| 129 | + | ||
| 130 | + //解压结束储存地址 | ||
| 131 | + NSLog(@"是否成功-----%d, hostPath----%@,目录下文件-----%@,是否解压过-------%d",isSuccess,hostPath,array,isUnpack); | ||
| 132 | + | ||
| 133 | + | ||
| 134 | + }]; | ||
| 135 | + | ||
| 136 | + | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + }else {//下载并解压 | ||
| 142 | + | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + }); | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | + | ||
| 149 | +/*** 只对网络进行判断 ***/ | ||
| 150 | ++ (DownLoadAppIconStatus)editNetAppIconDownloadWithKey:(NSString *)key { | ||
| 151 | + | ||
| 152 | + /*** 默认 ***/ | ||
| 153 | + DownLoadAppIconStatus status = DownLoadAppIconStatusNormal; | ||
| 154 | + | ||
| 155 | + EditAppIconStatus iconStatus = [CNLiveEditAppIconManager getEditAppIconStatusWithKey:key]; | ||
| 156 | + if (iconStatus == EditAppIconStatusNet) { | ||
| 157 | + | ||
| 158 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:key]; | ||
| 159 | + if (dic && dic.count > 0) { | ||
| 160 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 161 | + if (iconModel.holidayTheme) { | ||
| 162 | + CNEditAppIconDetailModel *iconDetailModel = iconModel.holidayTheme; | ||
| 163 | + NSString *loadUrl = [NSString stringWithFormat:@"%@",iconDetailModel.ios_imagePackage]; | ||
| 164 | + if ([[CNLiveWebDownLoadManager sharedInstance] checkLoadedWithDownloadUrl:loadUrl]) {//zip已下载 | ||
| 165 | + status = DownLoadAppIconStatusZipAndUnZip; | ||
| 166 | + | ||
| 167 | + if ([[CNLiveWebZipManager sharedInstance] isUnzipWithLoadUrl:loadUrl]) {//已解压 | ||
| 168 | + status = EditAppIconStatusSucess; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + return status; | ||
| 180 | + | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | +/*** 取得旧数据路径图片 ***/ | ||
| 184 | ++ (NSString *)getPathWithKey:(NSString *)key { | ||
| 185 | + | ||
| 186 | + if (!key || key.length == 0) { | ||
| 187 | + return @""; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + NSString *imagePath = @""; | ||
| 191 | + | ||
| 192 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:kHolidayKey]; | ||
| 193 | + if (dic && dic.count > 0) { | ||
| 194 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 195 | + if (iconModel.holidayTheme) { | ||
| 196 | + CNEditAppIconDetailModel *iconDetailModel = iconModel.holidayTheme; | ||
| 197 | + NSString *loadUrl = [NSString stringWithFormat:@"%@",iconDetailModel.ios_imagePackage]; | ||
| 198 | + imagePath = [[CNLiveWebZipManager sharedInstance] getImagePathWithLoadUrl:loadUrl name:@"" key:key]; | ||
| 199 | + | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + return imagePath; | ||
| 204 | + | ||
| 205 | +} | ||
| 206 | + | ||
| 207 | +/*** 获取状态 ***/ | ||
| 208 | ++ (EditAppIconStatus)getEditAppIconStatus { | ||
| 209 | + /*** 使用上一次的key ***/ | ||
| 210 | + return [CNLiveEditAppIconManager getEditAppIconStatusWithKey:kHolidayKey]; | ||
| 211 | + | ||
| 212 | +} | ||
| 213 | + | ||
| 214 | +/*** 获取状态 ***/ | ||
| 215 | ++ (EditAppIconStatus)getEditAppIconStatusWithKey:(NSString *)key { | ||
| 216 | + | ||
| 217 | + /*** 默认 ***/ | ||
| 218 | + EditAppIconStatus status = EditAppIconStatusNormal; | ||
| 219 | + | ||
| 220 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:key]; | ||
| 221 | + if (dic && dic.count > 0) { | ||
| 222 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 223 | + if ([iconModel.isShow isEqualToString:@"1"]) {//不显示 1为不显示 0为显示 | ||
| 224 | + status = EditAppIconStatusNormal; | ||
| 225 | + }else {//显示 | ||
| 226 | + CNEditAppIconDetailModel *detailModel = iconModel.holidayTheme; | ||
| 227 | + if (!detailModel) {//默认r | ||
| 228 | + status = EditAppIconStatusNormal; | ||
| 229 | + }else { | ||
| 230 | + | ||
| 231 | + if ([detailModel.holidayThemeStatus isEqualToString:@"0"]) {//总开关启用 | ||
| 232 | + if ([detailModel.status isEqualToString:@"0"]) {//IOS开关启用 | ||
| 233 | + if ([detailModel.showSource isEqualToString:@"1"]) {//本地节日 | ||
| 234 | + NSString *iosThemeIdentify = [NSString stringWithFormat:@"%@",detailModel.iosThemeIdentify ? detailModel.iosThemeIdentify : @""]; | ||
| 235 | + if ([iosThemeIdentify isEqualToString:kNew_OldHolidayVersion]) {//是否对应版本 | ||
| 236 | + status = EditAppIconStatusLocChange; | ||
| 237 | + }else { | ||
| 238 | + status = EditAppIconStatusNormal; | ||
| 239 | + } | ||
| 240 | + }else if([detailModel.showSource isEqualToString:@"2"]) {//网络 | ||
| 241 | + status = EditAppIconStatusNet; | ||
| 242 | + }else{//默认 | ||
| 243 | + status = EditAppIconStatusNormal; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + }else { | ||
| 247 | + status = EditAppIconStatusNormal; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + }else { | ||
| 251 | + status = EditAppIconStatusNormal; | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + }else { | ||
| 258 | + status = EditAppIconStatusNormal; | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + return status; | ||
| 262 | + | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | + | ||
| 266 | + | ||
| 267 | +/*** 根据数据更变颜色 ***/ | ||
| 268 | ++ (void)editItemTitleColor{ | ||
| 269 | + | ||
| 270 | + EditAppIconStatus status = [CNLiveEditAppIconManager getEditAppIconStatus]; | ||
| 271 | + | ||
| 272 | + if (status == EditAppIconStatusNet) { | ||
| 273 | + | ||
| 274 | + DownLoadAppIconStatus downloadStatus = [CNLiveEditAppIconManager editNetAppIconDownloadWithKey:kHolidayKey]; | ||
| 275 | + if (downloadStatus == EditAppIconStatusSucess) {//下载成功 | ||
| 276 | + | ||
| 277 | + /*** 默认 ***/ | ||
| 278 | + UIColor *normalColor = UIColorMake(147, 155, 164); | ||
| 279 | + UIColor *selectedColor = UIColorMake(26, 173, 25); | ||
| 280 | + /*** 根据信息更变 ***/ | ||
| 281 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:kHolidayKey]; | ||
| 282 | + if (dic && dic.count > 0) { | ||
| 283 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 284 | + CNEditAppIconDetailModel *detailModel = iconModel.holidayTheme; | ||
| 285 | + if (detailModel) { | ||
| 286 | + NSString *normalColorStr = [NSString stringWithFormat:@"%@",detailModel.clickBefore ? detailModel.clickBefore : @"1BC217"]; | ||
| 287 | + normalColor = [UIColor qmui_colorWithHexString:normalColorStr]; | ||
| 288 | + | ||
| 289 | + NSString *selectedColorStr = [NSString stringWithFormat:@"%@",detailModel.clickAfter ? detailModel.clickAfter : @"999999"]; | ||
| 290 | + selectedColor = [UIColor qmui_colorWithHexString:selectedColorStr]; | ||
| 291 | + } | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + QMUICMI.tabBarItemTitleColor = normalColor; | ||
| 295 | + QMUICMI.tabBarItemTitleColorSelected = selectedColor; | ||
| 296 | + QMUICMI.tabBarItemTitleFont = [UIFont systemFontOfSize:12.0]; | ||
| 297 | + | ||
| 298 | + }else { | ||
| 299 | + QMUICMI.tabBarItemTitleColor = UIColorMake(147, 155, 164); | ||
| 300 | + QMUICMI.tabBarItemTitleColorSelected = UIColorMake(26, 173, 25); | ||
| 301 | + QMUICMI.tabBarItemTitleFont = [UIFont systemFontOfSize:12.0]; | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + | ||
| 305 | + }else if (status == EditAppIconStatusLocChange) { | ||
| 306 | + /*** 默认 ***/ | ||
| 307 | + UIColor *normalColor = UIColorMake(147, 155, 164); | ||
| 308 | + UIColor *selectedColor = UIColorMake(26, 173, 25); | ||
| 309 | + /*** 根据信息更变 ***/ | ||
| 310 | + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:kHolidayKey]; | ||
| 311 | + if (dic && dic.count > 0) { | ||
| 312 | + CNEditAppIconModel *iconModel = [CNEditAppIconModel mj_objectWithKeyValues:dic]; | ||
| 313 | + CNEditAppIconDetailModel *detailModel = iconModel.holidayTheme; | ||
| 314 | + if (detailModel) { | ||
| 315 | + NSString *normalColorStr = [NSString stringWithFormat:@"%@",detailModel.clickBefore ? detailModel.clickBefore : @"1BC217"]; | ||
| 316 | + normalColor = [UIColor qmui_colorWithHexString:normalColorStr]; | ||
| 317 | + | ||
| 318 | + NSString *selectedColorStr = [NSString stringWithFormat:@"%@",detailModel.clickAfter ? detailModel.clickAfter : @"999999"]; | ||
| 319 | + selectedColor = [UIColor qmui_colorWithHexString:selectedColorStr]; | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + QMUICMI.tabBarItemTitleColor = normalColor; | ||
| 324 | + QMUICMI.tabBarItemTitleColorSelected = selectedColor; | ||
| 325 | + QMUICMI.tabBarItemTitleFont = [UIFont systemFontOfSize:12.0]; | ||
| 326 | + | ||
| 327 | + }else { | ||
| 328 | + QMUICMI.tabBarItemTitleColor = UIColorMake(147, 155, 164); | ||
| 329 | + QMUICMI.tabBarItemTitleColorSelected = UIColorMake(26, 173, 25); | ||
| 330 | + QMUICMI.tabBarItemTitleFont = [UIFont systemFontOfSize:12.0]; | ||
| 331 | + } | ||
| 332 | + | ||
| 333 | + | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | +/*** 删除所有zip包及所有解压文件 ***/ | ||
| 337 | ++ (void)removeAllZipAndDownLoad { | ||
| 338 | + | ||
| 339 | + [[CNLiveWebDownLoadManager sharedInstance] removeAllFile]; | ||
| 340 | + [[CNLiveWebZipManager sharedInstance] removeZipSuccessFile]; | ||
| 341 | + | ||
| 342 | +} | ||
| 343 | + | ||
| 344 | + | ||
| 345 | + | ||
| 346 | + | ||
| 347 | + | ||
| 348 | + | ||
| 349 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/FileManager/CNLiveWebImageCacheManager.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebImageDownLoadManager.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/22. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +///缓存是否成功 | ||
| 12 | +typedef void(^CacheIsSuccess)(BOOL isSuccess); | ||
| 13 | +///从缓存中获取图片data | ||
| 14 | +typedef void(^ReturnCachaData)(NSData * _Nullable data, NSString * _Nullable filePath); | ||
| 15 | +///清除缓存回调 | ||
| 16 | +typedef void(^ClearCacheBlock)(void); | ||
| 17 | + | ||
| 18 | +NS_ASSUME_NONNULL_BEGIN | ||
| 19 | + | ||
| 20 | +@interface CNLiveWebImageCacheManager : NSObject | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +/// 单例 | ||
| 24 | ++ (instancetype)share; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +#pragma mark -获取相关路径 | ||
| 28 | + | ||
| 29 | +/// 返回图片中间层文件夹(默认定死的) | ||
| 30 | +- (NSString *)getMidFilePath; | ||
| 31 | + | ||
| 32 | +///返回默认图片缓存路径文件夹 | ||
| 33 | +- (NSString *)getImageCachePath; | ||
| 34 | + | ||
| 35 | +#pragma mark -创建文件夹 | ||
| 36 | +- (void)createFileAtPath:(NSString *)path; | ||
| 37 | + | ||
| 38 | +#pragma mark -查看缓存是否存在 | ||
| 39 | +///默认路径下,是否已缓存某图片 | ||
| 40 | +- (BOOL)isExistsCacheWithKey:(NSString *)key; | ||
| 41 | + | ||
| 42 | +///自定义路径下,是否已缓存某图片 | ||
| 43 | +- (BOOL)isExistsCacheWithKey:(NSString *)key path:(NSString *)path; | ||
| 44 | + | ||
| 45 | +#pragma mark -获取缓存内容 | ||
| 46 | +///从默认路径获取某一图片data | ||
| 47 | +- (void)getCacheDataWithKey:(NSString *)key complete:(ReturnCachaData)complete; | ||
| 48 | + | ||
| 49 | +///从指定路径下获取某一图片data | ||
| 50 | +- (void)getCacheDataWithKey:(NSString *)key path:(NSString *)path complete:(ReturnCachaData)complete; | ||
| 51 | + | ||
| 52 | +///获取默认路径下的所有图片文件 | ||
| 53 | +- (NSArray *)getCacheImageFileArray; | ||
| 54 | + | ||
| 55 | +///获取指定路径下的所有图片文件 | ||
| 56 | +- (NSArray *)getCacheImageFileArrayWithPath:(NSString *)path; | ||
| 57 | + | ||
| 58 | +///获取默认路径下某一图片的属性信息 | ||
| 59 | +- (NSDictionary *)getCacheImageInfoWithKey:(NSString *)key; | ||
| 60 | + | ||
| 61 | +///获取指定路径下某一图片的属性信息 | ||
| 62 | +- (NSDictionary *)getCacheImageInfoWithKey:(NSString *)key path:(NSString *)path; | ||
| 63 | + | ||
| 64 | +#pragma mark -计算缓存大小与个数 | ||
| 65 | +///获取沙盒总空间大小 | ||
| 66 | +- (NSUInteger)getAllSandboxSpace; | ||
| 67 | + | ||
| 68 | +///获取沙盒总空间剩余大小 | ||
| 69 | +- (NSUInteger)getFreeSandboxSpace; | ||
| 70 | + | ||
| 71 | +///获取默认路径下缓存图片的数量 | ||
| 72 | +- (NSUInteger)getImageCountInCache; | ||
| 73 | + | ||
| 74 | +///获取指定路径下缓存图片的数量 | ||
| 75 | +- (NSUInteger)getImageCountWithCachePath:(NSString *)path; | ||
| 76 | + | ||
| 77 | +///获取默认路径下缓存图片的总大小 | ||
| 78 | +- (unsigned long long)getImageSizeInCache; | ||
| 79 | + | ||
| 80 | +///获取指定路径下缓存图片的总大小 | ||
| 81 | +- (unsigned long long)getImageSizeWithCachePath:(NSString *)path; | ||
| 82 | + | ||
| 83 | +///大小单位换算 | ||
| 84 | +- (NSString *)imageUnitWithSize:(float)size; | ||
| 85 | + | ||
| 86 | +#pragma mark -超过最大缓存时间,清除缓存 | ||
| 87 | +///自动清除默认路径下的所有过期图片 | ||
| 88 | +- (void)automaticClearCache; | ||
| 89 | + | ||
| 90 | +///设置过期时间,清除默认路径下的所有过期图片 | ||
| 91 | +- (void)clearCacheWithTime:(NSTimeInterval)time complete:(ClearCacheBlock)complete; | ||
| 92 | + | ||
| 93 | +///设置过期时间,清除指定路径下的所有过期图片 | ||
| 94 | +- (void)clearCacheWithTime:(NSTimeInterval)time path:(NSString *)path complete:(ClearCacheBlock)complete; | ||
| 95 | + | ||
| 96 | +///设置过期时间,清除默认路径下的某个过期图片,无回调 | ||
| 97 | +- (void)cleanSingleImageWithTime:(NSTimeInterval)time key:(NSString *)key; | ||
| 98 | + | ||
| 99 | +///设置过期时间,清除默认路径下的某个过期图片 | ||
| 100 | +- (void)cleanSingleImageWithTime:(NSTimeInterval)time key:(NSString *)key complete:(ClearCacheBlock)complete; | ||
| 101 | + | ||
| 102 | +///设置过期时间,清除指定路径下的某个过期图片 | ||
| 103 | +- (void)cleanSingleImageWithTime:(NSTimeInterval)time key:(NSString *)key path:(NSString *)path complete:(ClearCacheBlock)complete; | ||
| 104 | + | ||
| 105 | +///接收到进入后台通知,后台清理缓存方法 | ||
| 106 | +- (void)cleanCacheInBackgroundWith:(NSString *)path; | ||
| 107 | + | ||
| 108 | +#pragma mark -清除缓存 | ||
| 109 | +///清除默认路径下的缓存,无回调 | ||
| 110 | +- (void)clearCache; | ||
| 111 | + | ||
| 112 | +///清除默认路径下的缓存,有回调 | ||
| 113 | +- (void)clearCacheComplete:(ClearCacheBlock)complete; | ||
| 114 | + | ||
| 115 | +///清除指定路径下的缓存,无回调 | ||
| 116 | +- (void)clearCacheWithPath:(NSString *)path; | ||
| 117 | + | ||
| 118 | +///清除指定路径下的缓存,有回调 | ||
| 119 | +- (void)clearCacheWithPath:(NSString *)path complete:(ClearCacheBlock)complete; | ||
| 120 | + | ||
| 121 | +///清除默认路径下某一个图片的缓存,无回调 | ||
| 122 | +- (void)clearSingleImageWithKey:(NSString *)key; | ||
| 123 | + | ||
| 124 | +///清除默认路径下某一个图片的缓存,有回调 | ||
| 125 | +- (void)clearSingleImageWithKey:(NSString *)key complete:(ClearCacheBlock)complete; | ||
| 126 | + | ||
| 127 | +///清除指定路径下某一个图片的缓存,无回调 | ||
| 128 | +- (void)clearSingleImageWithKey:(NSString *)key path:(NSString *)path; | ||
| 129 | + | ||
| 130 | +///清除指定路径下某一个图片的缓存,有回调 | ||
| 131 | +- (void)clearSingleImageWithKey:(NSString *)key path:(NSString *)path complete:(ClearCacheBlock)complete; | ||
| 132 | + | ||
| 133 | +#pragma mark -获取相关路径 | ||
| 134 | +///获取一张图片的完整路径 | ||
| 135 | +- (NSString *)getCachePath:(NSString *)path md5Key:(NSString *)key; | ||
| 136 | + | ||
| 137 | +#pragma mark -缓存 | ||
| 138 | +///缓存机制:把imageurl作为唯一key,并加密作为图片存储文件路径 | ||
| 139 | +- (void)cacheContent:(NSData *)content key:(NSString *)key path:(NSString *)path completion:(CacheIsSuccess)completion; | ||
| 140 | + | ||
| 141 | +@end | ||
| 142 | + | ||
| 143 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/FileManager/CNLiveWebImageCacheManager.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebImageDownLoadManager.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/22. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveWebImageCacheManager.h" | ||
| 10 | +#import "NSFileManager+ImgPath.h" | ||
| 11 | +#import "NSString+CNLiveExtension.h" | ||
| 12 | + | ||
| 13 | +//中间层文件夹 | ||
| 14 | +NSString *const midPath =@"CNLiveWebImgFile"; | ||
| 15 | +//默认图片缓存路径文件夹 | ||
| 16 | +NSString *const defaultCachePath = @"ImageCache"; | ||
| 17 | +//单位转换 | ||
| 18 | +static const CGFloat unit = 1024.0; | ||
| 19 | +//缓存文件最大存储时间 | ||
| 20 | +static const NSInteger defauleMaxCacheTime = 60*60*24*7; | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +@interface CNLiveWebImageCacheManager() | ||
| 24 | + | ||
| 25 | +//默认缓存路径 | ||
| 26 | +@property (nonatomic ,copy) NSString *cachePath; | ||
| 27 | +@property (nonatomic ,strong) dispatch_queue_t operationQueue; | ||
| 28 | + | ||
| 29 | +@end | ||
| 30 | + | ||
| 31 | +@implementation CNLiveWebImageCacheManager | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +/// 单例 | ||
| 35 | ++ (instancetype)share{ | ||
| 36 | + static CNLiveWebImageCacheManager *instance = nil; | ||
| 37 | + static dispatch_once_t onceToken; | ||
| 38 | + dispatch_once(&onceToken, ^{ | ||
| 39 | + instance = [[CNLiveWebImageCacheManager alloc] init]; | ||
| 40 | + }); | ||
| 41 | + return instance; | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | + | ||
| 45 | +#pragma mark -初始化 | ||
| 46 | +-(instancetype)init{ | ||
| 47 | + self = [super init]; | ||
| 48 | + if (self) { | ||
| 49 | + //创建缓存文件夹 | ||
| 50 | + [self createFileAtPath:self.cachePath]; | ||
| 51 | + | ||
| 52 | + /* | ||
| 53 | + UIApplicationWillTerminateNotification | ||
| 54 | + 应用在前台,双击 Home 键 ,终止应用时调用 | ||
| 55 | + 应用在前台,单击 Home 键,进入桌面 , 再终止应用时不会调用 | ||
| 56 | + | ||
| 57 | + UIApplicationDidEnterBackgroundNotification | ||
| 58 | + 应用进入后台的时候调用 | ||
| 59 | + */ | ||
| 60 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(automaticClearCache) name:UIApplicationWillTerminateNotification object:nil]; | ||
| 61 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cleanCacheInBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; | ||
| 62 | + | ||
| 63 | + } | ||
| 64 | + return self; | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +#pragma mark -获取相关路径 | ||
| 68 | +/// 返回图片中间层文件夹(默认定死的) | ||
| 69 | +- (NSString *)getMidFilePath{ | ||
| 70 | + NSString *path = [[NSFileManager cachesPath] stringByAppendingPathComponent:midPath]; | ||
| 71 | + return path; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +///返回默认图片缓存路径文件夹 | ||
| 75 | +- (NSString *)getImageCachePath{ | ||
| 76 | + return self.cachePath; | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +///获取一张图片的完整路径 | ||
| 80 | +- (NSString *)getCachePath:(NSString *)path md5Key:(NSString *)key{ | ||
| 81 | + //图片的url作为key,加密 | ||
| 82 | + NSString *md5Key = [self getMD5String:key]; | ||
| 83 | + NSString *filePath = [path stringByAppendingPathComponent:md5Key]; | ||
| 84 | + return filePath; | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +#pragma mark -加密 | ||
| 88 | +- (NSString *)getMD5String:(NSString *)key{ | ||
| 89 | + return [key md5]; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +#pragma mark -创建文件夹 | ||
| 93 | +- (void)createFileAtPath:(NSString *)path{ | ||
| 94 | + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { | ||
| 95 | + //不存在,创建 | ||
| 96 | + [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; | ||
| 97 | + }else{ | ||
| 98 | + //已存在 | ||
| 99 | + } | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +#pragma mark -查看缓存是否存在 | ||
| 103 | +///默认路径下,是否已缓存某图片 | ||
| 104 | +- (BOOL)isExistsCacheWithKey:(NSString *)key{ | ||
| 105 | + | ||
| 106 | + NSString *imagePath = [[self getCachePath:self.cachePath md5Key:key] stringByDeletingPathExtension]; | ||
| 107 | + BOOL isExist = [[NSFileManager defaultManager] fileExistsAtPath:imagePath]; | ||
| 108 | + return isExist; | ||
| 109 | +} | ||
| 110 | +///自定义路径下,是否已缓存某图片 | ||
| 111 | +- (BOOL)isExistsCacheWithKey:(NSString *)key path:(NSString *)path{ | ||
| 112 | + | ||
| 113 | + NSString *imagePath = [[self getCachePath:path md5Key:key] stringByDeletingPathExtension]; | ||
| 114 | + BOOL isExist = [[NSFileManager defaultManager] fileExistsAtPath:imagePath]; | ||
| 115 | + return isExist; | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +#pragma mark -获取缓存内容 | ||
| 119 | +///从默认路径获取图片data | ||
| 120 | +- (void)getCacheDataWithKey:(NSString *)key complete:(ReturnCachaData)complete{ | ||
| 121 | + | ||
| 122 | + [self getCacheDataWithKey:key path:self.cachePath complete:complete]; | ||
| 123 | +} | ||
| 124 | +///从指定路径下获取图片data | ||
| 125 | +- (void)getCacheDataWithKey:(NSString *)key path:(NSString *)path complete:(ReturnCachaData)complete{ | ||
| 126 | + | ||
| 127 | + if (!key || key.length == 0) { | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + dispatch_async(self.operationQueue, ^{ | ||
| 131 | + | ||
| 132 | + @autoreleasepool { | ||
| 133 | + NSString *imagePath = [[self getCachePath:path md5Key:key] stringByDeletingPathExtension]; | ||
| 134 | + NSData *cacheData = [NSData dataWithContentsOfFile:imagePath]; | ||
| 135 | + | ||
| 136 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 137 | + if (complete) { | ||
| 138 | + complete(cacheData, imagePath); | ||
| 139 | + } | ||
| 140 | + }); | ||
| 141 | + } | ||
| 142 | + }); | ||
| 143 | +} | ||
| 144 | + | ||
| 145 | +///获取默认路径下的所有图片文件 | ||
| 146 | +- (NSArray *)getCacheImageFileArray{ | ||
| 147 | + return [self getCacheImageFileArrayWithPath:self.cachePath]; | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +///获取指定路径下的所有图片文件路径 | ||
| 151 | +- (NSArray *)getCacheImageFileArrayWithPath:(NSString *)path{ | ||
| 152 | + | ||
| 153 | + NSMutableArray *arr = [[NSMutableArray alloc] init]; | ||
| 154 | + NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; | ||
| 155 | + for (NSString *fileName in enumerator) { | ||
| 156 | + if (fileName.length == 32) { | ||
| 157 | + NSString *filePath = [path stringByAppendingPathComponent:fileName]; | ||
| 158 | + [arr addObject:filePath]; | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + return arr; | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +///获取默认路径下某一图片的属性信息 | ||
| 165 | +- (NSDictionary *)getCacheImageInfoWithKey:(NSString *)key{ | ||
| 166 | + return [self getCacheImageInfoWithKey:key path:self.cachePath]; | ||
| 167 | +} | ||
| 168 | + | ||
| 169 | +///获取指定路径下某一图片的属性信息 | ||
| 170 | +- (NSDictionary *)getCacheImageInfoWithKey:(NSString *)key path:(NSString *)path{ | ||
| 171 | + | ||
| 172 | + if (!key || !path) { | ||
| 173 | + return nil; | ||
| 174 | + } | ||
| 175 | + NSString *filePath = [[self getCachePath:path md5Key:key] stringByDeletingPathExtension]; | ||
| 176 | + NSDictionary *infoDic = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; | ||
| 177 | + return infoDic; | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +#pragma mark -计算缓存大小与个数 | ||
| 181 | +///获取沙盒总空间大小 | ||
| 182 | +- (NSUInteger)getAllSandboxSpace{ | ||
| 183 | + NSUInteger size = 0; | ||
| 184 | + NSString *homePath = [NSFileManager homePath]; | ||
| 185 | + NSError *error = nil; | ||
| 186 | + NSDictionary *info = [[NSFileManager defaultManager] attributesOfFileSystemForPath:homePath error:&error]; | ||
| 187 | + if (error) { | ||
| 188 | + NSLog(@"获取沙盒总空间大小error: %@", error.localizedDescription); | ||
| 189 | + }else{ | ||
| 190 | + size = [[info valueForKey:NSFileSystemSize] floatValue]; | ||
| 191 | + } | ||
| 192 | + return size; | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +///获取沙盒总空间剩余大小 | ||
| 196 | +- (NSUInteger)getFreeSandboxSpace{ | ||
| 197 | + NSUInteger size = 0; | ||
| 198 | + NSString *homePath = [NSFileManager homePath]; | ||
| 199 | + NSError *error = nil; | ||
| 200 | + NSDictionary *info = [[NSFileManager defaultManager] attributesOfFileSystemForPath:homePath error:&error]; | ||
| 201 | + if (error) { | ||
| 202 | + NSLog(@"获取沙盒总空间剩余大小error: %@", error.localizedDescription); | ||
| 203 | + }else{ | ||
| 204 | + size = [[info valueForKey:NSFileSystemFreeSize] floatValue]; | ||
| 205 | + } | ||
| 206 | + return size; | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +///获取默认路径下缓存图片的数量 | ||
| 210 | +- (NSUInteger)getImageCountInCache{ | ||
| 211 | + NSUInteger count = [self getImageCountWithCachePath:self.cachePath]; | ||
| 212 | + return count; | ||
| 213 | +} | ||
| 214 | + | ||
| 215 | +///获取指定路径下缓存图片的数量 | ||
| 216 | +- (NSUInteger)getImageCountWithCachePath:(NSString *)path{ | ||
| 217 | + __block NSUInteger count = 0; | ||
| 218 | + //sync | ||
| 219 | + dispatch_sync(self.operationQueue, ^{ | ||
| 220 | + NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; | ||
| 221 | + count = [[fileEnumerator allObjects] count]; | ||
| 222 | + | ||
| 223 | + }); | ||
| 224 | + return count; | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +///获取默认路径下缓存图片的总大小 | ||
| 228 | +- (unsigned long long)getImageSizeInCache{ | ||
| 229 | + NSUInteger size = [self getImageSizeWithCachePath:self.cachePath]; | ||
| 230 | + return size; | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +///获取指定路径下缓存图片的总大小 | ||
| 234 | +- (unsigned long long)getImageSizeWithCachePath:(NSString *)path{ | ||
| 235 | + __block long long size = 0; | ||
| 236 | + //同步任务 | ||
| 237 | + dispatch_sync(self.operationQueue, ^{ | ||
| 238 | + NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; | ||
| 239 | + for (NSString *fileName in fileEnumerator) { | ||
| 240 | + NSString *filePath = [path stringByAppendingPathComponent:fileName]; | ||
| 241 | + | ||
| 242 | + NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; | ||
| 243 | + size += [attrs fileSize]; | ||
| 244 | + } | ||
| 245 | + }); | ||
| 246 | + return size; | ||
| 247 | +} | ||
| 248 | + | ||
| 249 | +///大小单位换算 | ||
| 250 | +- (NSString *)imageUnitWithSize:(float)size{ | ||
| 251 | + if (size >= unit * unit * unit) { // >= 1GB | ||
| 252 | + return [NSString stringWithFormat:@"%.2fGB", size / unit / unit / unit]; | ||
| 253 | + } else if (size >= unit * unit) { // >= 1MB | ||
| 254 | + return [NSString stringWithFormat:@"%.2fMB", size / unit / unit]; | ||
| 255 | + } else { // >= 1KB | ||
| 256 | + return [NSString stringWithFormat:@"%.2fKB", size / unit]; | ||
| 257 | + } | ||
| 258 | +} | ||
| 259 | + | ||
| 260 | +#pragma mark -超过最大缓存时间,清除缓存 | ||
| 261 | +///自动清除默认路径下的所有过期图片 | ||
| 262 | +- (void)automaticClearCache{ | ||
| 263 | + NSLog(@"UIApplicationWillTerminateNotification,自动清理默认路径下所有过期图片"); | ||
| 264 | + [self clearCacheWithTime:defauleMaxCacheTime complete:nil]; | ||
| 265 | +} | ||
| 266 | + | ||
| 267 | +///设置过期时间,清除默认路径下的所有过期图片 | ||
| 268 | +- (void)clearCacheWithTime:(NSTimeInterval)time complete:(ClearCacheBlock)complete{ | ||
| 269 | + | ||
| 270 | + [self clearCacheWithTime:time path:self.cachePath complete:complete]; | ||
| 271 | +} | ||
| 272 | + | ||
| 273 | +///设置过期时间,清除指定路径下的所有过期图片 | ||
| 274 | +- (void)clearCacheWithTime:(NSTimeInterval)time path:(NSString *)path complete:(ClearCacheBlock)complete{ | ||
| 275 | + NSLog(@"超时,准备清除所有过期图片"); | ||
| 276 | + if (!path || !time) { | ||
| 277 | + return; | ||
| 278 | + } | ||
| 279 | + dispatch_async(self.operationQueue, ^{ | ||
| 280 | + NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-time]; | ||
| 281 | + | ||
| 282 | + NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; | ||
| 283 | + | ||
| 284 | + for (NSString *fileName in fileEnumerator) { | ||
| 285 | + NSString *filePath = [path stringByAppendingPathComponent:fileName]; | ||
| 286 | + NSDictionary *info = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; | ||
| 287 | + | ||
| 288 | + NSDate *currentDate = [info valueForKey:NSFileModificationDate]; | ||
| 289 | + | ||
| 290 | + if ([[currentDate laterDate:expirationDate] isEqualToDate:expirationDate]) { | ||
| 291 | + //更晚的时间是截止时间,图片的时间在截止时间前 | ||
| 292 | + [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; | ||
| 293 | + } | ||
| 294 | + } | ||
| 295 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 296 | + NSLog(@"清除所有过期图片完成"); | ||
| 297 | + if (complete) { | ||
| 298 | + complete(); | ||
| 299 | + } | ||
| 300 | + }); | ||
| 301 | + }); | ||
| 302 | +} | ||
| 303 | + | ||
| 304 | +///设置过期时间,清除默认路径下的某个过期图片,无回调 | ||
| 305 | +- (void)cleanSingleImageWithTime:(NSTimeInterval)time key:(NSString *)key{ | ||
| 306 | + | ||
| 307 | + [self cleanSingleImageWithTime:time key:key path:self.cachePath complete:nil]; | ||
| 308 | +} | ||
| 309 | + | ||
| 310 | +///设置过期时间,清除默认路径下的某个过期图片 | ||
| 311 | +- (void)cleanSingleImageWithTime:(NSTimeInterval)time key:(NSString *)key complete:(ClearCacheBlock)complete{ | ||
| 312 | + | ||
| 313 | + [self cleanSingleImageWithTime:time key:key path:self.cachePath complete:complete]; | ||
| 314 | +} | ||
| 315 | + | ||
| 316 | +////设置过期时间,清除指定路径下的某个过期图片 | ||
| 317 | +- (void)cleanSingleImageWithTime:(NSTimeInterval)time key:(NSString *)key path:(NSString *)path complete:(ClearCacheBlock)complete{ | ||
| 318 | + | ||
| 319 | + if (!time||!key||!path){ | ||
| 320 | + return; | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + dispatch_async(self.operationQueue, ^{ | ||
| 324 | + | ||
| 325 | + NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-time]; | ||
| 326 | + NSString *filePath = [[self getCachePath:path md5Key:key] stringByDeletingPathExtension]; | ||
| 327 | + NSDictionary *info = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; | ||
| 328 | + | ||
| 329 | + NSDate *currentDate = [info objectForKey:NSFileModificationDate]; | ||
| 330 | + | ||
| 331 | + if ([[currentDate laterDate:expirationDate] isEqualToDate:expirationDate]){ | ||
| 332 | + [[NSFileManager defaultManager]removeItemAtPath:filePath error:nil]; | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 336 | + if (complete) { | ||
| 337 | + complete(); | ||
| 338 | + } | ||
| 339 | + }); | ||
| 340 | + }); | ||
| 341 | +} | ||
| 342 | + | ||
| 343 | +///接收到进入后台通知,后台清理缓存方法 | ||
| 344 | +- (void)cleanCacheInBackgroundWith:(NSString *)path{ | ||
| 345 | + Class UIApplicationClass = NSClassFromString(@"UIApplication"); | ||
| 346 | + if (!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { | ||
| 347 | + return; | ||
| 348 | + } | ||
| 349 | + UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; | ||
| 350 | + __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ | ||
| 351 | + // Clean up any unfinished task business by marking where you | ||
| 352 | + // stopped or ending the task outright. | ||
| 353 | + [application endBackgroundTask:bgTask]; | ||
| 354 | + bgTask = UIBackgroundTaskInvalid; | ||
| 355 | + }]; | ||
| 356 | + // Start the long-running task and return immediately. | ||
| 357 | + [self clearCacheWithTime:defauleMaxCacheTime path:path complete:^{ | ||
| 358 | + [application endBackgroundTask:bgTask]; | ||
| 359 | + bgTask = UIBackgroundTaskInvalid; | ||
| 360 | + }]; | ||
| 361 | +} | ||
| 362 | + | ||
| 363 | +- (void)cleanCacheInBackground{ | ||
| 364 | + NSLog(@"UIApplicationDidEnterBackgroundNotification,自动清理默认路径下所有过期图片"); | ||
| 365 | + [self cleanCacheInBackgroundWith:self.cachePath]; | ||
| 366 | +} | ||
| 367 | + | ||
| 368 | +#pragma mark -清除缓存 | ||
| 369 | +///清除默认路径下的缓存,无回调 | ||
| 370 | +- (void)clearCache{ | ||
| 371 | + | ||
| 372 | + [self clearCacheWithPath:self.cachePath complete:nil]; | ||
| 373 | +} | ||
| 374 | + | ||
| 375 | +///清除默认路径下的缓存,有回调 | ||
| 376 | +- (void)clearCacheComplete:(ClearCacheBlock)complete{ | ||
| 377 | + | ||
| 378 | + [self clearCacheWithPath:self.cachePath complete:complete]; | ||
| 379 | +} | ||
| 380 | + | ||
| 381 | +///清除指定路径下的缓存,无回调 | ||
| 382 | +- (void)clearCacheWithPath:(NSString *)path{ | ||
| 383 | + [self clearCacheWithPath:path complete:nil]; | ||
| 384 | +} | ||
| 385 | +///清除指定路径下的缓存,有回调 | ||
| 386 | +- (void)clearCacheWithPath:(NSString *)path complete:(ClearCacheBlock)complete{ | ||
| 387 | + if (!path) { | ||
| 388 | + return; | ||
| 389 | + } | ||
| 390 | + dispatch_async(self.operationQueue, ^{ | ||
| 391 | + | ||
| 392 | + NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; | ||
| 393 | + for (NSString *fileName in enumerator) { | ||
| 394 | + NSString *filePath = [path stringByAppendingPathComponent:fileName]; | ||
| 395 | + [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; | ||
| 396 | + } | ||
| 397 | + }); | ||
| 398 | + | ||
| 399 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 400 | + NSLog(@"----清除缓存成功"); | ||
| 401 | + if (complete) { | ||
| 402 | + complete(); | ||
| 403 | + } | ||
| 404 | + }); | ||
| 405 | +} | ||
| 406 | + | ||
| 407 | +///清除默认路径下某一个图片的缓存,无回调 | ||
| 408 | +- (void)clearSingleImageWithKey:(NSString *)key{ | ||
| 409 | + | ||
| 410 | + [self clearSingleImageWithKey:key path:self.cachePath complete:nil]; | ||
| 411 | +} | ||
| 412 | + | ||
| 413 | +///清除默认路径下某一个图片的缓存,有回调 | ||
| 414 | +- (void)clearSingleImageWithKey:(NSString *)key complete:(ClearCacheBlock)complete{ | ||
| 415 | + | ||
| 416 | + [self clearSingleImageWithKey:key path:self.cachePath complete:complete]; | ||
| 417 | +} | ||
| 418 | + | ||
| 419 | +///清除指定路径下某一个图片的缓存,无回调 | ||
| 420 | +- (void)clearSingleImageWithKey:(NSString *)key path:(NSString *)path{ | ||
| 421 | + | ||
| 422 | + [self clearSingleImageWithKey:key path:path complete:nil]; | ||
| 423 | +} | ||
| 424 | + | ||
| 425 | +///清除指定路径下某一个图片的缓存,有回调 | ||
| 426 | +- (void)clearSingleImageWithKey:(NSString *)key path:(NSString *)path complete:(ClearCacheBlock)complete{ | ||
| 427 | + if (!key || !path ) { | ||
| 428 | + return; | ||
| 429 | + } | ||
| 430 | + | ||
| 431 | + dispatch_async(self.operationQueue, ^{ | ||
| 432 | + | ||
| 433 | + NSString *filePath = [[self getCachePath:path md5Key:key] stringByDeletingPathExtension]; | ||
| 434 | + [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; | ||
| 435 | + }); | ||
| 436 | + | ||
| 437 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 438 | + | ||
| 439 | + NSLog(@"----清除某一个图片的缓存成功"); | ||
| 440 | + if (complete) { | ||
| 441 | + complete(); | ||
| 442 | + } | ||
| 443 | + }); | ||
| 444 | +} | ||
| 445 | + | ||
| 446 | +#pragma mark -缓存 | ||
| 447 | +///缓存机制:把imageurl作为唯一key,并加密作为图片存储文件路径 | ||
| 448 | +- (void)cacheContent:(NSData *)content key:(NSString *)key path:(NSString *)path completion:(CacheIsSuccess)completion{ | ||
| 449 | + | ||
| 450 | + dispatch_async(self.operationQueue, ^{ | ||
| 451 | + //新文件夹? 创建 | ||
| 452 | + [self createFileAtPath:path]; | ||
| 453 | + NSString *imagePath = [[self getCachePath:path md5Key:key] stringByDeletingPathExtension]; | ||
| 454 | + BOOL isSuccess = [self content:content writeToFile:imagePath]; | ||
| 455 | + NSLog(@"----缓存%@", isSuccess?@"成功":@"失败"); | ||
| 456 | + | ||
| 457 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 458 | + if (completion) { | ||
| 459 | + completion(isSuccess); | ||
| 460 | + } | ||
| 461 | + }); | ||
| 462 | + | ||
| 463 | + }); | ||
| 464 | +} | ||
| 465 | +///把图片data写入文件 | ||
| 466 | +- (BOOL)content:(NSData *)content writeToFile:(NSString *)path{ | ||
| 467 | + | ||
| 468 | + if (!content||!path){ | ||
| 469 | + return NO; | ||
| 470 | + } | ||
| 471 | + | ||
| 472 | + if ([content isKindOfClass:[NSData class]]) { | ||
| 473 | + return [(NSData *)content writeToFile:path atomically:YES]; | ||
| 474 | + }else { | ||
| 475 | + [NSException raise:@"非法的文件内容" format:@"文件类型%@异常。", NSStringFromClass([content class])]; | ||
| 476 | + return NO; | ||
| 477 | + } | ||
| 478 | + return NO; | ||
| 479 | +} | ||
| 480 | + | ||
| 481 | +#pragma mark -懒加载 | ||
| 482 | +-(NSString *)cachePath{ | ||
| 483 | + if (!_cachePath) { | ||
| 484 | + _cachePath = [[self getMidFilePath] stringByAppendingPathComponent:defaultCachePath]; | ||
| 485 | + } | ||
| 486 | + return _cachePath; | ||
| 487 | +} | ||
| 488 | + | ||
| 489 | +- (dispatch_queue_t)operationQueue{ | ||
| 490 | + if (!_operationQueue) { | ||
| 491 | + _operationQueue = dispatch_queue_create("com.CNLive.CacheManager", DISPATCH_QUEUE_SERIAL); | ||
| 492 | + } | ||
| 493 | + return _operationQueue; | ||
| 494 | +} | ||
| 495 | + | ||
| 496 | + | ||
| 497 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/NSFileManager+ImgPath.h
0 → 100644
| 1 | +// | ||
| 2 | +// NSFileManager+ImgPath.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/21. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | + | ||
| 13 | +@interface NSFileManager (ImgPath) | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +#pragma mark - 各种路径 | ||
| 17 | + | ||
| 18 | +/// 获取Documents目录路径 | ||
| 19 | ++ (NSString *)documentsPath; | ||
| 20 | +/// 获取Library目录路径 | ||
| 21 | ++ (NSString *)libraryPath; | ||
| 22 | +/// 获取Cache目录路径 | ||
| 23 | ++ (NSString *)cachesPath; | ||
| 24 | +/// 获取应用沙盒根路径 | ||
| 25 | ++ (NSString *)homePath; | ||
| 26 | +/// 获取Tmp目录路径 | ||
| 27 | ++ (NSString *)tmpPath; | ||
| 28 | + | ||
| 29 | +#pragma 方法 | ||
| 30 | + | ||
| 31 | +/// 判断指定路径下的文件,是否超出规定时间 | ||
| 32 | +/// @param path 文件路径 | ||
| 33 | +/// @param time 毫秒 | ||
| 34 | +- (BOOL)isFile:(NSString *)path timeout:(NSTimeInterval)time; | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +@end | ||
| 38 | + | ||
| 39 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/NSFileManager+ImgPath.m
0 → 100644
| 1 | +// | ||
| 2 | +// NSFileManager+ImgPath.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/21. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +#import "NSFileManager+ImgPath.h" | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +@implementation NSFileManager (ImgPath) | ||
| 14 | + | ||
| 15 | +#pragma mark - 各种路径 | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +/// 获取指定directory的路径 | ||
| 19 | +/// @param directory 指定的directory | ||
| 20 | ++ (NSString *)pathForDirectory:(NSSearchPathDirectory)directory{ | ||
| 21 | + NSArray *arr = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES); | ||
| 22 | + NSString *pathStr = @""; | ||
| 23 | + if (arr.count > 0) { | ||
| 24 | + pathStr = [NSString stringWithFormat:@"%@",arr[0]]; | ||
| 25 | + return pathStr; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + return pathStr; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +/// 获取Documents目录路径 | ||
| 32 | ++ (NSString *)documentsPath { | ||
| 33 | + return [self pathForDirectory:NSDocumentDirectory]; | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +/// 获取Library目录路径 | ||
| 37 | ++ (NSString *)libraryPath { | ||
| 38 | + return [self pathForDirectory:NSLibraryDirectory]; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +/// 获取Cache目录路径 | ||
| 42 | ++ (NSString *)cachesPath { | ||
| 43 | + return [self pathForDirectory:NSCachesDirectory]; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +/// 获取应用沙盒根路径 | ||
| 47 | ++ (NSString *)homePath { | ||
| 48 | + return NSHomeDirectory(); | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +/// 获取Tmp目录路径 | ||
| 52 | ++ (NSString *)tmpPath { | ||
| 53 | + return NSTemporaryDirectory(); | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +#pragma 方法 | ||
| 57 | + | ||
| 58 | +/// 判断指定路径下的文件,是否超出规定时间 | ||
| 59 | +/// @param path 文件路径 | ||
| 60 | +/// @param time 毫秒 | ||
| 61 | +- (BOOL)isFile:(NSString *)path timeout:(NSTimeInterval)time{ | ||
| 62 | + | ||
| 63 | + NSDictionary *info = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil]; | ||
| 64 | + | ||
| 65 | + NSDate *current = [info objectForKey:NSFileModificationDate]; | ||
| 66 | + | ||
| 67 | + NSDate *date = [NSDate date]; | ||
| 68 | + | ||
| 69 | + NSTimeInterval currentTime = [date timeIntervalSinceDate:current]; | ||
| 70 | + | ||
| 71 | + if (currentTime>time) { | ||
| 72 | + | ||
| 73 | + return YES; | ||
| 74 | + }else{ | ||
| 75 | + | ||
| 76 | + return NO; | ||
| 77 | + } | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | + | ||
| 81 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/UIImage+EditIcon.h
0 → 100644
| 1 | +// | ||
| 2 | +// UIImage+EditIcon.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/26. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | +//存放要下载的 生活圈,订阅号,优选库 gif图 URL 地址 | ||
| 9 | + | ||
| 10 | +#import <UIKit/UIKit.h> | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +NS_ASSUME_NONNULL_BEGIN | ||
| 15 | + | ||
| 16 | +@interface UIImage (EditIcon) | ||
| 17 | + | ||
| 18 | +/// 获取图片1 - 默认,获取图片2 - 本地图片,获取图片3 - 网络图片 | ||
| 19 | ++ (UIImage *)getEditIconWithName:(NSString *)name; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +/// 获取图片图片或者gif | ||
| 23 | ++ (UIImage *)getEditGifBgWithName:(NSString *)name; | ||
| 24 | + | ||
| 25 | +@end | ||
| 26 | + | ||
| 27 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/UIImage+EditIcon.m
0 → 100644
| 1 | +// | ||
| 2 | +// UIImage+EditIcon.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/26. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "UIImage+EditIcon.h" | ||
| 10 | +#import "CNLiveEditAppIconManager.h" | ||
| 11 | +#import "CNEditAppIconModel.h" | ||
| 12 | +#import "CNDownLoadGifManager.h" | ||
| 13 | +#import "NSString+CNLiveExtension.h" | ||
| 14 | +#import <YYImage/YYImage.h> | ||
| 15 | +#import <CNLiveBeeHive/CNLiveBeeHive.h> | ||
| 16 | +#import <SDWebImage/SDWebImage.h> | ||
| 17 | + | ||
| 18 | +@implementation UIImage (EditIcon) | ||
| 19 | + | ||
| 20 | +/// 获取图片1 - 默认,获取图片2 - 本地图片,获取图片3 - 网络图片 | ||
| 21 | ++ (UIImage *)getEditIconWithName:(NSString *)name { | ||
| 22 | + | ||
| 23 | + /**如果生活圈,订阅号,优选库 有 gif,则优先显示gif, 没有gif图 走之前的换肤逻辑*/ | ||
| 24 | + | ||
| 25 | + UIImage *gif = [self getGifByFileName:name]; | ||
| 26 | + if (gif) { | ||
| 27 | + /**如果有 gif 返回gif*/ | ||
| 28 | + return gif; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /**########################### 下面是换肤逻辑 ################################*/ | ||
| 32 | + | ||
| 33 | + /*** 默认 ***/ | ||
| 34 | + EditAppIconStatus status = [CNLiveEditAppIconManager getEditAppIconStatus]; | ||
| 35 | + | ||
| 36 | + if (status == EditAppIconStatusNet) { | ||
| 37 | + | ||
| 38 | + DownLoadAppIconStatus downloadStatus = [CNLiveEditAppIconManager editNetAppIconDownloadWithKey:kHolidayKey]; | ||
| 39 | + if (downloadStatus == EditAppIconStatusSucess) {//下载成功 | ||
| 40 | + NSString *nameStr = [NSString stringWithFormat:@"%@@3x",name]; | ||
| 41 | + NSString *imagePath = [CNLiveEditAppIconManager getPathWithKey:nameStr]; | ||
| 42 | + | ||
| 43 | + if (imagePath && imagePath.length > 0) { | ||
| 44 | + UIImage *pahtImage = [UIImage imageWithContentsOfFile:imagePath]; | ||
| 45 | + if (pahtImage) {//网络 | ||
| 46 | + NSLog(@"节日_网络节日_网络皮肤 = %@",imagePath); | ||
| 47 | + return pahtImage; | ||
| 48 | + }else {//本地部分 | ||
| 49 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 50 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 51 | + if (newImage) {//本地节日 | ||
| 52 | + NSLog(@"节日_网络节日_节日未找到_本地节日皮肤 = %@",newNameStr); | ||
| 53 | + return newImage; | ||
| 54 | + }else {//本地 | ||
| 55 | + NSLog(@"节日_网络节日_节日未找到_本地 = %@",name); | ||
| 56 | + return [UIImage imageNamed:name]; | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + }else {//本地部分 | ||
| 61 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 62 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 63 | + if (newImage) {//本地节日 | ||
| 64 | + NSLog(@"节日_网络节日_节日路径空_本地节日 = %@",newNameStr); | ||
| 65 | + return newImage; | ||
| 66 | + }else {//本地 | ||
| 67 | + NSLog(@"节日_网络节日_节日路径空_本地 = %@",name); | ||
| 68 | + return [UIImage imageNamed:name]; | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + }else { | ||
| 74 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 75 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 76 | + if (newImage) {//本地节日 | ||
| 77 | + NSLog(@"节日_网络节日_未下载成功_本地节日 = %@",newNameStr); | ||
| 78 | + return newImage; | ||
| 79 | + }else {//本地 | ||
| 80 | + NSLog(@"节日_网络节日_未下载成功_本地 = %@",name); | ||
| 81 | + return [UIImage imageNamed:name]; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + }else if (status == EditAppIconStatusLocChange) { | ||
| 87 | + NSString *nameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 88 | + NSLog(@"节日_本地节日_图片 = %@",nameStr); | ||
| 89 | + return [UIImage imageNamed:nameStr]; | ||
| 90 | + | ||
| 91 | + }else { | ||
| 92 | + return [UIImage imageNamed:name]; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +/// 获取生活圈,订阅号,优选库 gif 图 | ||
| 98 | +/// @param name gif名称 | ||
| 99 | ++ (UIImage *)getGifByFileName:(NSString *)name | ||
| 100 | +{ | ||
| 101 | + if ([name isEqualToString:@"wjj_lifeCircle"]) { | ||
| 102 | + NSLog(@"[BHConfig get:CNMomentGitName] == %@",[BHConfig get:CNMomentGitName]); | ||
| 103 | + //生活圈 | ||
| 104 | + | ||
| 105 | + NSString *momentGitName =[[NSUserDefaults standardUserDefaults] objectForKey:CNMomentGitName]; | ||
| 106 | + | ||
| 107 | + if (![NSString isEmpty:momentGitName]) { | ||
| 108 | + //服务器返回了生活圈gif | ||
| 109 | + | ||
| 110 | + YYImage *image = [YYImage imageWithData:[NSData dataWithContentsOfFile:[CNDownLoadGifManager filePath:momentGitName]]]; | ||
| 111 | + if (image) { | ||
| 112 | + //本地下载了 生活圈gif,返回下载好的生活圈gif 进行显示 | ||
| 113 | + return image; | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + else if ([name isEqualToString:@"wjj_subscribe"]) | ||
| 118 | + { | ||
| 119 | + //订阅号 | ||
| 120 | + NSString *subscribeGitName =[[NSUserDefaults standardUserDefaults] objectForKey:CNSubscribeGitName]; | ||
| 121 | + | ||
| 122 | + if (![NSString isEmpty:subscribeGitName]) { | ||
| 123 | + //服务器返回了订阅号gif | ||
| 124 | + | ||
| 125 | + YYImage *image = [YYImage imageWithData:[NSData dataWithContentsOfFile:[CNDownLoadGifManager filePath:subscribeGitName]]]; | ||
| 126 | + if (image) { | ||
| 127 | + //本地下载了 订阅号gif,返回下载好的订阅号gif 进行显示 | ||
| 128 | + return image; | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + else if ([name isEqualToString:@"wjj_youxuanku"]) | ||
| 133 | + { | ||
| 134 | + //优选库 | ||
| 135 | + NSString *youxuanGitName =[[NSUserDefaults standardUserDefaults] objectForKey:CNYouxuanGitName]; | ||
| 136 | + if (![NSString isEmpty:youxuanGitName]) { | ||
| 137 | + //服务器返回了优选库gif | ||
| 138 | + | ||
| 139 | + YYImage *image = [YYImage imageWithData:[NSData dataWithContentsOfFile:[CNDownLoadGifManager filePath:youxuanGitName]]]; | ||
| 140 | + if (image) { | ||
| 141 | + //本地下载了 优选库gif,返回下载好的优选库gif 进行显示 | ||
| 142 | + return image; | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + return nil; | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +/// 获取图片图片或者gif | ||
| 151 | ++ (UIImage *)getEditGifBgWithName:(NSString *)name { | ||
| 152 | + | ||
| 153 | + /*** 默认 ***/ | ||
| 154 | + EditAppIconStatus status = [CNLiveEditAppIconManager getEditAppIconStatus]; | ||
| 155 | + | ||
| 156 | + if (status == EditAppIconStatusNet) { | ||
| 157 | + | ||
| 158 | + DownLoadAppIconStatus downloadStatus = [CNLiveEditAppIconManager editNetAppIconDownloadWithKey:kHolidayKey]; | ||
| 159 | + if (downloadStatus == EditAppIconStatusSucess) {//下载成功 | ||
| 160 | + | ||
| 161 | + NSString *nameGifStr = [NSString stringWithFormat:@"%@_gif",name]; | ||
| 162 | + | ||
| 163 | + NSString *imageGifPath = [CNLiveEditAppIconManager getPathWithKey:nameGifStr]; | ||
| 164 | + | ||
| 165 | + if (imageGifPath && imageGifPath.length > 0) { | ||
| 166 | + NSData *loadGifData = [NSData dataWithContentsOfFile:imageGifPath]; | ||
| 167 | + if (loadGifData) {//网络gfi | ||
| 168 | +// SDAnimatedImage *gifImage = [[SDAnimatedImage alloc] initWithData:loadGifData]; | ||
| 169 | + UIImage * gifImage = [UIImage sd_imageWithGIFData:loadGifData]; | ||
| 170 | + NSLog(@"节日_网络节日_网络皮肤_gif = %@",imageGifPath); | ||
| 171 | + return gifImage; | ||
| 172 | + }else { | ||
| 173 | + NSString *nameStr = [NSString stringWithFormat:@"%@@3x",name]; | ||
| 174 | + NSString *imagePath = [CNLiveEditAppIconManager getPathWithKey:nameStr]; | ||
| 175 | + | ||
| 176 | + if (imagePath && imagePath.length > 0) { | ||
| 177 | + UIImage *pahtImage = [UIImage imageWithContentsOfFile:imagePath]; | ||
| 178 | + if (pahtImage) {//网络BG | ||
| 179 | + NSLog(@"节日_网络节日_gif_网络BG = %@",imagePath); | ||
| 180 | + return pahtImage; | ||
| 181 | + }else {//本地BG | ||
| 182 | + | ||
| 183 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 184 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 185 | + if (newImage) {//本地节日BG | ||
| 186 | + NSLog(@"节日_网络节日_gif_图片为空_本地节日 = %@",newNameStr); | ||
| 187 | + return newImage; | ||
| 188 | + }else {//本地 | ||
| 189 | + NSLog(@"节日_网络节日_gif_图片为空_本地 = %@",name); | ||
| 190 | + return [UIImage imageNamed:name]; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + }else {//未找到BG路径 | ||
| 196 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 197 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 198 | + if (newImage) {//本地节日BG | ||
| 199 | + NSLog(@"节日_网络节日_gif_节日BG路径为空_本地节日 = %@",newNameStr); | ||
| 200 | + return newImage; | ||
| 201 | + }else {//本地 | ||
| 202 | + NSLog(@"节日_网络节日_gif_节日BG路径为空_本地 = %@",newNameStr); | ||
| 203 | + return [UIImage imageNamed:name]; | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + }else {//找不到gif | ||
| 209 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 210 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 211 | + if (newImage) {//本地节日BG | ||
| 212 | + NSLog(@"节日_网络节日_gif_节日路径为空_本地节日 = %@",newNameStr); | ||
| 213 | + return newImage; | ||
| 214 | + }else {//本地 | ||
| 215 | + NSLog(@"节日_网络节日_gif_节日路径为空_本地 = %@",name); | ||
| 216 | + return [UIImage imageNamed:name]; | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + }else {//未下载成功 | ||
| 220 | + NSString *newNameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 221 | + UIImage *newImage = [UIImage imageNamed:newNameStr]; | ||
| 222 | + if (newImage) {//本地节日BG | ||
| 223 | + NSLog(@"节日_网络节日_gif_未下载成功_本地节日 = %@",newNameStr); | ||
| 224 | + return newImage; | ||
| 225 | + }else {//本地 | ||
| 226 | + NSLog(@"节日_网络节日_gif_未下载成功_本地 = %@",name); | ||
| 227 | + return [UIImage imageNamed:name]; | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + }else if (status == EditAppIconStatusLocChange) { | ||
| 232 | + NSString *gifNameStr = [NSString stringWithFormat:@"%@_gif",name]; | ||
| 233 | + NSString *gifPath = [[NSBundle mainBundle] pathForResource:gifNameStr ofType:@"gif"]; | ||
| 234 | + NSData *loadGifData = [NSData dataWithContentsOfFile:gifPath]; | ||
| 235 | + if (loadGifData) { | ||
| 236 | + SDAnimatedImage *gifImage = [[SDAnimatedImage alloc] initWithData:loadGifData]; | ||
| 237 | + NSLog(@"节日_本地节日_gif = %@",gifPath); | ||
| 238 | + return gifImage; | ||
| 239 | + }else { | ||
| 240 | + NSString *nameStr = [NSString stringWithFormat:@"%@_new",name]; | ||
| 241 | + NSLog(@"节日_本地节日_图片 = %@",nameStr); | ||
| 242 | + return [UIImage imageNamed:nameStr]; | ||
| 243 | + } | ||
| 244 | + }else { | ||
| 245 | + return [UIImage imageNamed:name]; | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | +} | ||
| 249 | + | ||
| 250 | + | ||
| 251 | + | ||
| 252 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadAndZip/CNLiveWebDownLoadManager.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebDownLoadManager.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/25. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | + | ||
| 13 | +typedef void (^successBlock) (NSString *url, NSString *fileStorePath); | ||
| 14 | +typedef void (^faileBlock) (NSString *url, NSError *error); | ||
| 15 | +typedef void (^progressBlock) (NSString *url, float progress); | ||
| 16 | + | ||
| 17 | +@interface CNLiveWebDownLoadManager : NSObject | ||
| 18 | + | ||
| 19 | +/*** 成功回调 ***/ | ||
| 20 | +@property (nonatomic, copy) successBlock successBlock; | ||
| 21 | +/*** 失败回调 ***/ | ||
| 22 | +@property (nonatomic, copy) faileBlock failedBlock; | ||
| 23 | +/*** 进度 ***/ | ||
| 24 | +@property (nonatomic, copy) progressBlock progressBlock; | ||
| 25 | + | ||
| 26 | +@property (nonatomic, strong) NSMutableArray *downloads; | ||
| 27 | + | ||
| 28 | +//@property (nonatomic, copy) NSString *cachesPath; | ||
| 29 | +//@property (nonatomic, assign) BOOL isDownload; | ||
| 30 | + | ||
| 31 | ++ (instancetype)sharedInstance; | ||
| 32 | + | ||
| 33 | +/*** 获取本地缓存路径 ***/ | ||
| 34 | +- (NSString *)getLoadZipPathWithDownloadUrl:(NSString *)downloadUrl; | ||
| 35 | +/*** 检查是否下载成功 ***/ | ||
| 36 | +- (BOOL)checkLoadedWithDownloadUrl:(NSString *)downloadUrl; | ||
| 37 | +/*** 下载文件 ***/ | ||
| 38 | +- (void)downLoadWithURL:(NSString *)URL progress:(progressBlock)progressBlock success:(successBlock)successBlock faile:(faileBlock)faileBlock; | ||
| 39 | + | ||
| 40 | +- (void)stopTask; | ||
| 41 | + | ||
| 42 | +/*** 停止当前单例任务删除Plist中key 和缓存路径 ***/ | ||
| 43 | +- (void)removeAllFile; | ||
| 44 | + | ||
| 45 | + | ||
| 46 | +@end | ||
| 47 | + | ||
| 48 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadAndZip/CNLiveWebDownLoadManager.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebDownLoadManager.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/25. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveWebDownLoadManager.h" | ||
| 10 | +#import "CNLiveWebImageCacheManager.h" | ||
| 11 | +#import "NSString+CNLiveExtension.h" | ||
| 12 | +#import <YYCategories/YYCategories.h> | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +// 使用plist文件存储文件的总字节数 | ||
| 16 | +#define FileTotalLengthPlist @"file_totalLength.plist" | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +@interface CNLiveWebDownLoadManager ()<NSURLSessionDelegate> | ||
| 21 | + | ||
| 22 | +/*** plist_用于存储文件总大小 ***/ | ||
| 23 | +@property (nonatomic, copy) NSString *totalLengthPlist; | ||
| 24 | +/*** 文件的存放路径(caches) ***/ | ||
| 25 | +@property (nonatomic, copy) NSString *fileStorePath; | ||
| 26 | + | ||
| 27 | +/** 下载任务 */ | ||
| 28 | +@property (nonatomic, strong) NSURLSessionDataTask *task; | ||
| 29 | +/** session */ | ||
| 30 | +@property (nonatomic, strong) NSURLSession *session; | ||
| 31 | +/** 写文件的流对象 */ | ||
| 32 | +@property (nonatomic, strong) NSOutputStream *stream; | ||
| 33 | +/** 文件的总大小 */ | ||
| 34 | +@property (nonatomic, assign) NSInteger totalLength; | ||
| 35 | +/*** 下载 ***/ | ||
| 36 | +@property (nonatomic, strong) NSString *downloadUrl; | ||
| 37 | + | ||
| 38 | +@end | ||
| 39 | + | ||
| 40 | +@implementation CNLiveWebDownLoadManager | ||
| 41 | + | ||
| 42 | + | ||
| 43 | +#pragma mark - 创建单例 | ||
| 44 | +static CNLiveWebDownLoadManager *_instance; | ||
| 45 | + | ||
| 46 | ++ (instancetype)sharedInstance | ||
| 47 | +{ | ||
| 48 | + static dispatch_once_t onceToken; | ||
| 49 | + dispatch_once(&onceToken, ^{ | ||
| 50 | + _instance = [[self alloc] init]; | ||
| 51 | + | ||
| 52 | + }); | ||
| 53 | + return _instance; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +- (instancetype)init | ||
| 57 | +{ | ||
| 58 | + self = [super init]; | ||
| 59 | + if (self) { | ||
| 60 | + /*** 所有下载 ***/ | ||
| 61 | + self.downloads = [NSMutableArray array]; | ||
| 62 | + | ||
| 63 | + } | ||
| 64 | + return self; | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | + | ||
| 68 | +#pragma mark - 公开方法 | ||
| 69 | +/*** 获取下载路径对应的本地缓存路径 ***/ | ||
| 70 | +- (NSString *)getLoadZipPathWithDownloadUrl:(NSString *)downloadUrl { | ||
| 71 | + /*** 创建缓存路径 ***/ | ||
| 72 | +// NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[downloadUrl md5]]; | ||
| 73 | + NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[downloadUrl md5]]; | ||
| 74 | + return cachePath; | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | + | ||
| 78 | +/*** 检查是否下载成功 ***/ | ||
| 79 | +- (BOOL)checkLoadedWithDownloadUrl:(NSString *)downloadUrl { | ||
| 80 | + | ||
| 81 | + if (!downloadUrl || downloadUrl.length == 0) { | ||
| 82 | + return NO; | ||
| 83 | + } | ||
| 84 | + /*** 识别是否创建过下载任务 ***/ | ||
| 85 | + NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:self.totalLengthPlist]; | ||
| 86 | + NSString *key = [downloadUrl md5]; | ||
| 87 | + if (dic && [dic containsObjectForKey:key]) { | ||
| 88 | + NSInteger totalL = [dic[key] integerValue];//获取总大小 | ||
| 89 | + NSInteger downloadL = [self getLengthWithDownloadUrl:downloadUrl]; | ||
| 90 | + if (totalL && downloadL == totalL) {//下载等于总大小 | ||
| 91 | + NSLog(@"######文件已经下载完成了######"); | ||
| 92 | + return YES; | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + return NO; | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +- (NSInteger)getLengthWithDownloadUrl:(NSString *)downloadUrl { | ||
| 99 | + | ||
| 100 | + /*** 创建缓存路径 ***/ | ||
| 101 | +// NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[downloadUrl md5]]; | ||
| 102 | + NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[downloadUrl md5]]; | ||
| 103 | + NSDictionary *infoDic = [[NSFileManager defaultManager] attributesOfItemAtPath:cachePath error:nil]; | ||
| 104 | + if (!infoDic || ![infoDic containsObjectForKey:NSFileSize]) { | ||
| 105 | + return 0; | ||
| 106 | + | ||
| 107 | + } | ||
| 108 | + NSInteger size = [infoDic[NSFileSize] integerValue]; | ||
| 109 | + return size; | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | + | ||
| 113 | +- (void)downLoadWithURL:(NSString *)URL progress:(progressBlock)progressBlock success:(successBlock)successBlock faile:(faileBlock)faileBlock | ||
| 114 | +{ | ||
| 115 | + | ||
| 116 | + self.downloadUrl = URL; | ||
| 117 | + self.progressBlock = progressBlock; | ||
| 118 | + self.successBlock = successBlock; | ||
| 119 | + self.failedBlock = faileBlock; | ||
| 120 | + | ||
| 121 | + /*** 任务开始 ***/ | ||
| 122 | + [self.task resume]; | ||
| 123 | + | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | + | ||
| 127 | +- (void)stopTask{ | ||
| 128 | + [self.task suspend]; | ||
| 129 | + | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +- (void)removeAllFile { | ||
| 133 | + | ||
| 134 | + /*** 识别是否创建过下载任务 ***/ | ||
| 135 | + NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:self.totalLengthPlist]; | ||
| 136 | + if (!dic || dic.count <= 0) { | ||
| 137 | + return; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + NSArray *dicKeys = dic.allKeys; | ||
| 141 | + if (dicKeys.count <= 0) { | ||
| 142 | + return; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + [dicKeys enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 146 | + NSString *key = obj; | ||
| 147 | + /*** 创建缓存路径 ***/ | ||
| 148 | +// NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:key]; | ||
| 149 | + NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:key]; | ||
| 150 | + if ([self zipExists:key]) { | ||
| 151 | + NSFileManager *fileManger = [NSFileManager defaultManager];//文件管理器 | ||
| 152 | + [fileManger removeItemAtPath:cachePath error:nil]; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + }]; | ||
| 156 | + | ||
| 157 | + dic = [NSDictionary dictionary]; | ||
| 158 | + | ||
| 159 | + BOOL isWrite = [dic writeToFile:self.totalLengthPlist atomically:YES]; | ||
| 160 | + if (isWrite) { | ||
| 161 | + NSLog(@"输出已经写入"); | ||
| 162 | + }else { | ||
| 163 | + NSLog(@"未写入"); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +/* 检测指定路径zip是否存在 | ||
| 169 | + | ||
| 170 | + @param directoryPath 目录路径 | ||
| 171 | + @return 是否存在 | ||
| 172 | + */ | ||
| 173 | +- (BOOL)zipExists:(NSString *)key | ||
| 174 | +{ | ||
| 175 | + __block BOOL isDir = NO; | ||
| 176 | +// NSString * paths = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; | ||
| 177 | + NSString * paths = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; | ||
| 178 | + NSArray * files = [[ NSFileManager defaultManager] subpathsAtPath :paths]; | ||
| 179 | + | ||
| 180 | + [files enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 181 | + NSLog(@"输出文件夹内容 = %@",obj); | ||
| 182 | + NSString *fileStr = [NSString stringWithFormat:@"%@",obj ? obj : @""]; | ||
| 183 | + if ([fileStr isEqualToString:key]) { | ||
| 184 | + isDir = YES; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + }]; | ||
| 188 | + | ||
| 189 | + return isDir; | ||
| 190 | +} | ||
| 191 | + | ||
| 192 | + | ||
| 193 | +#pragma mark - Getter方法 | ||
| 194 | +- (NSURLSession *)session | ||
| 195 | +{ | ||
| 196 | + if (!_session) { | ||
| 197 | + | ||
| 198 | + NSOperationQueue *queue = [[NSOperationQueue alloc] init]; | ||
| 199 | + queue.maxConcurrentOperationCount = 1; // 并发队列 | ||
| 200 | + _session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:queue]; | ||
| 201 | + } | ||
| 202 | + return _session; | ||
| 203 | +} | ||
| 204 | + | ||
| 205 | +- (NSOutputStream *)stream | ||
| 206 | +{ | ||
| 207 | + if (!_stream) { | ||
| 208 | + _stream = [NSOutputStream outputStreamToFileAtPath:self.fileStorePath append:YES]; | ||
| 209 | + } | ||
| 210 | + return _stream; | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | + | ||
| 214 | +- (NSURLSessionDataTask *)task | ||
| 215 | +{ | ||
| 216 | + if (!_task) { | ||
| 217 | + | ||
| 218 | + /*** 识别是否创建过下载任务 ***/ | ||
| 219 | + NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:self.totalLengthPlist]; | ||
| 220 | + NSString *key = [self.downloadUrl md5]; | ||
| 221 | + if (dic && [dic containsObjectForKey:key]) { | ||
| 222 | + NSInteger totalL = [dic[key] integerValue];//获取总大小 | ||
| 223 | + NSInteger downloadL = [self downloadLength]; | ||
| 224 | + if (totalL && downloadL == totalL) {//下载等于总大小 | ||
| 225 | + NSLog(@"######文件已经下载完成了######"); | ||
| 226 | + return nil; | ||
| 227 | + } | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + // 创建请求 | ||
| 231 | + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: self.downloadUrl]]; | ||
| 232 | + | ||
| 233 | + // 设置请求头 | ||
| 234 | + // Range : bytes=xxx-xxx,从已经下载的长度开始到文件总长度的最后都要下载 | ||
| 235 | + NSString *range = [NSString stringWithFormat:@"bytes=%zd-", [self downloadLength]]; | ||
| 236 | + [request setValue:range forHTTPHeaderField:@"Range"]; | ||
| 237 | + | ||
| 238 | + // 创建一个Data任务 | ||
| 239 | + _task = [self.session dataTaskWithRequest:request]; | ||
| 240 | + } | ||
| 241 | + return _task; | ||
| 242 | +} | ||
| 243 | + | ||
| 244 | +#pragma mark - NSURLSessionDataDelegate | ||
| 245 | +/** | ||
| 246 | + * 1.接收到响应 | ||
| 247 | + */ | ||
| 248 | +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSHTTPURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler | ||
| 249 | +{ | ||
| 250 | + // 打开流 | ||
| 251 | + [self.stream open]; | ||
| 252 | + | ||
| 253 | + /* | ||
| 254 | + (Content-Length字段返回的是服务器对每次客户端请求要下载文件的大小) | ||
| 255 | + 比如首次客户端请求下载文件A,大小为1000byte,那么第一次服务器返回的Content-Length = 1000, | ||
| 256 | + 客户端下载到500byte,突然中断,再次请求的range为 “bytes=500-”,那么此时服务器返回的Content-Length为500 | ||
| 257 | + 所以对于单个文件进行多次下载的情况(断点续传),计算文件的总大小,必须把服务器返回的content-length加上本地存储的已经下载的文件大小 | ||
| 258 | + */ | ||
| 259 | + self.totalLength = [response.allHeaderFields[@"Content-Length"] integerValue] + [self downloadLength]; | ||
| 260 | + | ||
| 261 | + // 把此次已经下载的文件大小存储在plist文件 | ||
| 262 | + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile: self.totalLengthPlist]; | ||
| 263 | + if (!dict) { | ||
| 264 | + dict = [NSMutableDictionary dictionary]; | ||
| 265 | + } | ||
| 266 | + NSString *key = [self.downloadUrl md5]; | ||
| 267 | + dict[key] = @(self.totalLength); | ||
| 268 | + BOOL isWrite = [dict writeToFile:self.totalLengthPlist atomically:YES]; | ||
| 269 | + if (isWrite) { | ||
| 270 | + NSLog(@"输出已经写入"); | ||
| 271 | + }else { | ||
| 272 | + NSLog(@"未写入"); | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + // 接收这个请求,允许接收服务器的数据 | ||
| 276 | + completionHandler(NSURLSessionResponseAllow); | ||
| 277 | +} | ||
| 278 | + | ||
| 279 | +/** | ||
| 280 | + * 2.接收到服务器返回的数据(这个方法可能会被调用N次) | ||
| 281 | + */ | ||
| 282 | +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data | ||
| 283 | +{ | ||
| 284 | + // 写入数据 | ||
| 285 | + [self.stream write:data.bytes maxLength:data.length]; | ||
| 286 | + | ||
| 287 | + float progress = 1.0 * self.downloadLength / self.totalLength; | ||
| 288 | + if (self.progressBlock) { | ||
| 289 | + self.progressBlock(self.downloadUrl, progress); | ||
| 290 | + } | ||
| 291 | + // 下载进度 | ||
| 292 | +} | ||
| 293 | + | ||
| 294 | +/** | ||
| 295 | + * 3.请求完毕(成功\失败) | ||
| 296 | + */ | ||
| 297 | +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error | ||
| 298 | +{ | ||
| 299 | + if (error) { | ||
| 300 | + self.stream = nil; | ||
| 301 | + self.task = nil; | ||
| 302 | + | ||
| 303 | + if (self.failedBlock) { | ||
| 304 | + self.failedBlock(self.downloadUrl, error); | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + }else{ | ||
| 308 | + // 关闭流 | ||
| 309 | + [self.stream close]; | ||
| 310 | + self.stream = nil; | ||
| 311 | + // 清除任务 | ||
| 312 | + self.task = nil; | ||
| 313 | + | ||
| 314 | + if (self.successBlock) { | ||
| 315 | + self.successBlock(self.downloadUrl, self.fileStorePath); | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + | ||
| 319 | + } | ||
| 320 | +} | ||
| 321 | + | ||
| 322 | + | ||
| 323 | + | ||
| 324 | + | ||
| 325 | +#pragma mark - 私有方法 | ||
| 326 | +- (NSInteger)downloadLength { | ||
| 327 | + | ||
| 328 | + NSDictionary *infoDic = [[NSFileManager defaultManager] attributesOfItemAtPath:self.fileStorePath error:nil]; | ||
| 329 | + if (!infoDic || ![infoDic containsObjectForKey:NSFileSize]) { | ||
| 330 | + return 0; | ||
| 331 | + } | ||
| 332 | + NSInteger size = [infoDic[NSFileSize] integerValue]; | ||
| 333 | + return size; | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | + | ||
| 337 | +- (NSString *)totalLengthPlist | ||
| 338 | +{ | ||
| 339 | + /*** 创建plist路径 ***/ | ||
| 340 | + NSString *plistPath = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:FileTotalLengthPlist]; | ||
| 341 | + return plistPath; | ||
| 342 | +} | ||
| 343 | + | ||
| 344 | +-(NSString *)fileStorePath | ||
| 345 | +{ | ||
| 346 | + /*** 创建缓存路径 ***/ | ||
| 347 | +// NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[self.downloadUrl md5]]; | ||
| 348 | + NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[self.downloadUrl md5]]; | ||
| 349 | + return cachePath; | ||
| 350 | +} | ||
| 351 | + | ||
| 352 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadAndZip/CNLiveWebZipManager.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebZipManager.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/22. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + zipResultBlock | ||
| 15 | + | ||
| 16 | + @param hostPath 指定目录 | ||
| 17 | + @param array 指定目录下的zip解压文件名 例:hostPath/(zip解压后文件名) | ||
| 18 | + */ | ||
| 19 | +typedef void (^UnZipResultBlock)(Boolean isSuccess,NSString *hostPath, NSArray *array, Boolean isUnpack); | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +@interface CNLiveWebZipManager : NSObject | ||
| 23 | + | ||
| 24 | +/*** 单例初始化 ***/ | ||
| 25 | ++ (instancetype)sharedInstance; | ||
| 26 | + | ||
| 27 | +/*** 解压文件 ***/ | ||
| 28 | +- (void)unZipWithZipPath:(NSString *)zipPath downloadUrl:(NSString *)downloadUrl resultBlock:(UnZipResultBlock) resultBlock; | ||
| 29 | + | ||
| 30 | +/*** 查看ziploadUrl Key 解压是否成功 ***/ | ||
| 31 | +- (BOOL)isUnzipWithLoadUrl:(NSString *)loadUrl; | ||
| 32 | + | ||
| 33 | +/*** 根据图片key生成对应路径 ***/ | ||
| 34 | +- (NSString *)getImagePathWithLoadUrl:(NSString *)loadUrl name:(NSString *)name key:(NSString *)key; | ||
| 35 | + | ||
| 36 | +/*** 删除指定解压文件目录下文件 ***/ | ||
| 37 | +- (void)removeZipSuccessFile; | ||
| 38 | + | ||
| 39 | +@end | ||
| 40 | + | ||
| 41 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadAndZip/CNLiveWebZipManager.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebZipManager.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/22. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveWebZipManager.h" | ||
| 10 | +#import "SSZipArchive.h" | ||
| 11 | +#import "NSString+CNLiveExtension.h" | ||
| 12 | + | ||
| 13 | +// 解压目录 | ||
| 14 | +#define DownloadAPPIcon @"DownloadAPPIcon" | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +@interface CNLiveWebZipManager()<SSZipArchiveDelegate> | ||
| 18 | + | ||
| 19 | +/*** zip下载地址 ***/ | ||
| 20 | +@property (nonatomic, strong) NSString *downloadUrl; | ||
| 21 | + | ||
| 22 | +/*** 缓存路径目录 ***/ | ||
| 23 | +@property (nonatomic, strong) NSString *cachesPath; | ||
| 24 | + | ||
| 25 | +/*** 结果block ***/ | ||
| 26 | +@property (nonatomic, copy) UnZipResultBlock resultBlock; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +@end | ||
| 30 | +@implementation CNLiveWebZipManager | ||
| 31 | + | ||
| 32 | +static CNLiveWebZipManager *_instance = nil; | ||
| 33 | + | ||
| 34 | +/* 单例控制器 */ | ||
| 35 | ++ (instancetype)sharedInstance { | ||
| 36 | + static dispatch_once_t onceToken; | ||
| 37 | + dispatch_once(&onceToken, ^{ | ||
| 38 | + _instance = [[self alloc] init]; | ||
| 39 | + }); | ||
| 40 | + return _instance; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +- (instancetype)init { | ||
| 44 | + self = [super init]; | ||
| 45 | + if (self) { | ||
| 46 | + | ||
| 47 | + } | ||
| 48 | + return self; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +#pragma mark - 公开方法 | ||
| 53 | +#pragma mark - 从本地路径获取对应文件 | ||
| 54 | + | ||
| 55 | +/*** 解压文件 ***/ | ||
| 56 | +- (void)unZipWithZipPath:(NSString *)zipPath downloadUrl:(NSString *)downloadUrl resultBlock:(UnZipResultBlock) resultBlock{ | ||
| 57 | + | ||
| 58 | + self.downloadUrl = downloadUrl; | ||
| 59 | + self.resultBlock = resultBlock; | ||
| 60 | + | ||
| 61 | + NSString *urlCachePath = [self.cachesPath stringByAppendingPathComponent:[self.downloadUrl md5]]; | ||
| 62 | + | ||
| 63 | + if ([self directoryExists:urlCachePath]) {//看key路径目录下是否有文件 | ||
| 64 | + NSArray *urlCacheFiles = [self fileList:urlCachePath]; | ||
| 65 | + if (urlCacheFiles && urlCacheFiles.count > 0) { | ||
| 66 | + // 存在文件夹则之间返回 | ||
| 67 | + if (self.resultBlock) { | ||
| 68 | + self.resultBlock(YES,urlCachePath,urlCacheFiles,YES); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + }else {//解压 | ||
| 72 | + if ([self createFolderWithPath:urlCachePath]) { | ||
| 73 | + [self unZipFiles:zipPath toPath:urlCachePath]; | ||
| 74 | + | ||
| 75 | + }else{ | ||
| 76 | + if (self.resultBlock) { | ||
| 77 | + self.resultBlock(NO,@"",@[],NO); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + }else {//不存在解压 | ||
| 83 | + | ||
| 84 | + if ([self createFolderWithPath:urlCachePath]) { | ||
| 85 | + [self unZipFiles:zipPath toPath:urlCachePath]; | ||
| 86 | + | ||
| 87 | + }else{ | ||
| 88 | + if (self.resultBlock) { | ||
| 89 | + self.resultBlock(NO,@"",@[],NO); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +/*** 查看ziploadUrl Key 解压是否成功 ***/ | ||
| 99 | +- (BOOL)isUnzipWithLoadUrl:(NSString *)loadUrl { | ||
| 100 | + | ||
| 101 | + NSString *urlCachePath = [self.cachesPath stringByAppendingPathComponent:[loadUrl md5]]; | ||
| 102 | + | ||
| 103 | + if ([self directoryExists:urlCachePath]) {//看key路径目录下是否有文件 | ||
| 104 | + NSArray *urlCacheFiles = [self fileList:urlCachePath]; | ||
| 105 | + if (urlCacheFiles && urlCacheFiles.count > 0) { | ||
| 106 | + return YES; | ||
| 107 | + | ||
| 108 | + }else {//解压 | ||
| 109 | + return NO; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + }else { | ||
| 113 | + return NO; | ||
| 114 | + } | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +/*** 根据图片key生成对应路径 ***/ | ||
| 118 | +- (NSString *)getImagePathWithLoadUrl:(NSString *)loadUrl name:(NSString *)name key:(NSString *)key{ | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + __block NSString *imagePath = @""; | ||
| 123 | + | ||
| 124 | + NSString *urlCachePath = [self.cachesPath stringByAppendingPathComponent:[loadUrl md5]]; | ||
| 125 | + | ||
| 126 | + if ([self directoryExists:urlCachePath]) {//看key路径目录下是否有文件 | ||
| 127 | + NSArray *urlCacheFiles = [self fileList:urlCachePath]; | ||
| 128 | + if (urlCacheFiles && urlCacheFiles.count > 0) { | ||
| 129 | + | ||
| 130 | + if (!name || name.length == 0) { | ||
| 131 | + name = [NSString stringWithFormat:@"%@",urlCacheFiles[0]]; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + [urlCacheFiles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 135 | + NSString *file = [NSString stringWithFormat:@"%@",obj]; | ||
| 136 | + | ||
| 137 | + if ([file isEqualToString:name]) {//去指定zip目录 | ||
| 138 | + | ||
| 139 | + NSString *nextPath = [urlCachePath stringByAppendingPathComponent:file];//添加指定目录 | ||
| 140 | + NSArray *nextCacheFiles = [self fileList:nextPath]; | ||
| 141 | + if (nextCacheFiles && nextCacheFiles.count > 0) { | ||
| 142 | + | ||
| 143 | + [nextCacheFiles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { | ||
| 144 | + NSString *imageName = [NSString stringWithFormat:@"%@",obj]; | ||
| 145 | + | ||
| 146 | + if ([imageName hasPrefix:key]) {//和key相同 | ||
| 147 | + imagePath = [nextPath stringByAppendingPathComponent:imageName]; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + }]; | ||
| 151 | + | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + }]; | ||
| 156 | + | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + return imagePath; | ||
| 161 | + | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | + | ||
| 165 | +#pragma mark - 文件处理 | ||
| 166 | +#pragma mark - 检测目录文件夹是否存在 | ||
| 167 | +/** | ||
| 168 | + 检测目录文件夹是否存在 | ||
| 169 | + | ||
| 170 | + @param directoryPath 目录路径 | ||
| 171 | + @return 是否存在 | ||
| 172 | + */ | ||
| 173 | +- (BOOL)directoryExists:(NSString *)directoryPath | ||
| 174 | +{ | ||
| 175 | + BOOL isDir = NO; | ||
| 176 | + BOOL isDirExist = [[NSFileManager defaultManager] fileExistsAtPath:directoryPath isDirectory:&isDir]; | ||
| 177 | + if (isDir && isDirExist) { | ||
| 178 | + return YES; | ||
| 179 | + }else{ | ||
| 180 | + return NO; | ||
| 181 | + } | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +/*** 获取文件夹下所有文件列表。 ***/ | ||
| 185 | +- (NSArray *)fileList:(NSString *)directoryPath | ||
| 186 | +{ | ||
| 187 | + return [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil] mutableCopy]; | ||
| 188 | +} | ||
| 189 | + | ||
| 190 | +/*** 创建文件夹。下载完文件,文件需要解压到这个文件夹 ***/ | ||
| 191 | +- (BOOL)createFolderWithPath:(NSString *)folderPath | ||
| 192 | +{ | ||
| 193 | + // 在路径下创建文件夹 | ||
| 194 | + return [[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:YES attributes:nil error:nil]; | ||
| 195 | + | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | + | ||
| 199 | +#pragma mark - SSZipArchive | ||
| 200 | +#pragma mark - 解压 | ||
| 201 | +- (void)unZipFiles:(NSString *)zipPath toPath:(NSString *)toPath{ | ||
| 202 | + if ([SSZipArchive unzipFileAtPath:zipPath toDestination:toPath delegate:self]) { | ||
| 203 | + | ||
| 204 | + }else { | ||
| 205 | + if (self.resultBlock) { | ||
| 206 | + self.resultBlock(NO, @"", @[], NO); | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | +} | ||
| 210 | + | ||
| 211 | +#pragma mark - SSZipArchiveDelegate | ||
| 212 | +- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath | ||
| 213 | +{ | ||
| 214 | + // 解压会出现多余的文件夹__MACOSX,删除掉吧 | ||
| 215 | + NSString *invalidFolder = [unzippedPath stringByAppendingPathComponent:@"__MACOSX"]; | ||
| 216 | + [[NSFileManager defaultManager] removeItemAtPath:invalidFolder error:nil]; | ||
| 217 | + /* | ||
| 218 | + // 或者过滤数组,只取所需要的png文件名 | ||
| 219 | + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF ENDSWITH %@", @".png"]; | ||
| 220 | + NSArray *reslutFilteredArray = [fileList filteredArrayUsingPredicate:predicate]; | ||
| 221 | + */ | ||
| 222 | + NSArray *fileList = [self fileList:unzippedPath]; | ||
| 223 | + if (fileList && fileList.count > 0) { | ||
| 224 | + if (self.resultBlock) { | ||
| 225 | + self.resultBlock(YES,unzippedPath, fileList,NO); | ||
| 226 | + } | ||
| 227 | + }else { | ||
| 228 | + if (self.resultBlock) { | ||
| 229 | + self.resultBlock(NO,@"", @[],NO); | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | +} | ||
| 234 | + | ||
| 235 | + | ||
| 236 | +/*** 删除指定解压文件目录下文件 ***/ | ||
| 237 | +- (void)removeZipSuccessFile { | ||
| 238 | + /*** 创建缓存路径 ***/ | ||
| 239 | + if ([self directoryExists:self.cachesPath]) { | ||
| 240 | + NSFileManager *fileManger = [NSFileManager defaultManager];//文件管理器 | ||
| 241 | + [fileManger removeItemAtPath:self.cachesPath error:nil]; | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | + | ||
| 247 | +#pragma mark - 私有方法 | ||
| 248 | +- (NSString *)cachesPath | ||
| 249 | +{ | ||
| 250 | + /*** 创建缓存路径 ***/ | ||
| 251 | + NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:DownloadAPPIcon]; | ||
| 252 | + return cachePath; | ||
| 253 | +} | ||
| 254 | + | ||
| 255 | + | ||
| 256 | + | ||
| 257 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadGif/CNDownLoadGifManager.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNDownLoadGifManager.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by daojian on 2021/1/22. | ||
| 6 | +// Copyright © 2021 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | + | ||
| 13 | +typedef NS_ENUM(NSInteger, CNDownLoadGifType) { | ||
| 14 | + CNDownLoadMomentGifType = 1, //生活圈gif | ||
| 15 | + CNDownLoadSubscribeGifType = 2, //订阅号gif | ||
| 16 | + CNDownLoadYouxuanGifType = 3, //优选库gif | ||
| 17 | +}; | ||
| 18 | + | ||
| 19 | +/// 下载首页 生活圈,订阅号, 优选库 gif图 | ||
| 20 | +@interface CNDownLoadGifManager : NSObject | ||
| 21 | + | ||
| 22 | +/// 开启下载gif任务 | ||
| 23 | +/// @param gifUrlDic 存放的要下载的gif url地址 | ||
| 24 | ++ (void)startDownloadTask:(NSDictionary *)gifUrlDic; | ||
| 25 | + | ||
| 26 | +/// 返回下载的gif文件路径 | ||
| 27 | +/// @param fileName 文件名 | ||
| 28 | ++(NSString *)filePath:(NSString *)fileName; | ||
| 29 | + | ||
| 30 | +@end | ||
| 31 | + | ||
| 32 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadGif/CNDownLoadGifManager.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNDownLoadGifManager.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by daojian on 2021/1/22. | ||
| 6 | +// Copyright © 2021 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNDownLoadGifManager.h" | ||
| 10 | +#import "NSString+CNLiveExtension.h" | ||
| 11 | + | ||
| 12 | +@implementation CNDownLoadGifManager | ||
| 13 | + | ||
| 14 | +/// 开启下载gif任务 | ||
| 15 | +/// @param gifUrlDic 存放的要下载的gif url地址 | ||
| 16 | ++ (void)startDownloadTask:(NSDictionary *)gifUrlDic | ||
| 17 | +{ | ||
| 18 | + if (![NSString isEmpty:[gifUrlDic objectForKey:@"moment"]]) { | ||
| 19 | + //生活圈icon 有gif图需要显示 | ||
| 20 | + NSString *momentUrl = [gifUrlDic objectForKey:@"moment"]; | ||
| 21 | + | ||
| 22 | + /**服务器返回的最新gif*/ | ||
| 23 | + NSString *newMomentGifName = momentUrl.lastPathComponent; | ||
| 24 | + /**本地保存的gif*/ | ||
| 25 | + NSString *localMomentGifName = [[NSUserDefaults standardUserDefaults] objectForKey:CNMomentGitName]; | ||
| 26 | + | ||
| 27 | + if (![[NSFileManager defaultManager] fileExistsAtPath:[CNDownLoadGifManager filePath:localMomentGifName]]) { | ||
| 28 | + /**本地不存在下载*/ | ||
| 29 | + [CNDownLoadGifManager downLoadGifByUrl:momentUrl giftType:CNDownLoadMomentGifType]; | ||
| 30 | + } | ||
| 31 | + else if (![localMomentGifName isEqualToString:newMomentGifName]) | ||
| 32 | + { | ||
| 33 | + /**下载最新的生活圈 gif*/ | ||
| 34 | + [CNDownLoadGifManager downLoadGifByUrl:momentUrl giftType:CNDownLoadMomentGifType]; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + else | ||
| 39 | + { | ||
| 40 | + [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:CNMomentGitName]; | ||
| 41 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + if (![NSString isEmpty:[gifUrlDic objectForKey:@"subscribe"]]) { | ||
| 46 | + //订阅号icon 有gif图需要显示 | ||
| 47 | + NSString *subscribeUrl = [gifUrlDic objectForKey:@"subscribe"]; | ||
| 48 | + | ||
| 49 | + /**服务器返回的最新gif*/ | ||
| 50 | + NSString *newSubscribeGifName = subscribeUrl.lastPathComponent; | ||
| 51 | + /**本地保存的gif*/ | ||
| 52 | + NSString *localSubscribeGifName = [[NSUserDefaults standardUserDefaults] objectForKey:CNSubscribeGitName]; | ||
| 53 | + | ||
| 54 | + if (![[NSFileManager defaultManager] fileExistsAtPath:[CNDownLoadGifManager filePath:localSubscribeGifName]]) { | ||
| 55 | + /**本地不存在下载*/ | ||
| 56 | + [CNDownLoadGifManager downLoadGifByUrl:subscribeUrl giftType:CNDownLoadSubscribeGifType]; | ||
| 57 | + } | ||
| 58 | + else if (![localSubscribeGifName isEqualToString:newSubscribeGifName]) { | ||
| 59 | + /**下载 最新的订阅号 gif*/ | ||
| 60 | + [CNDownLoadGifManager downLoadGifByUrl:subscribeUrl giftType:CNDownLoadSubscribeGifType]; | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + else | ||
| 64 | + { | ||
| 65 | + [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:CNSubscribeGitName]; | ||
| 66 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + if (![NSString isEmpty:[gifUrlDic objectForKey:@"youxuan"]]) { | ||
| 71 | + //优选库icon 有gif图需要显示 | ||
| 72 | + | ||
| 73 | + NSString *youxuanUrl = [gifUrlDic objectForKey:@"youxuan"]; | ||
| 74 | + | ||
| 75 | + /**服务器返回的最新gif*/ | ||
| 76 | + NSString *newYouxuanGifName = youxuanUrl.lastPathComponent; | ||
| 77 | + /**本地保存的gif*/ | ||
| 78 | + NSString *localYouxuanGifName = [[NSUserDefaults standardUserDefaults] objectForKey:CNYouxuanGitName]; | ||
| 79 | + if (![[NSFileManager defaultManager] fileExistsAtPath:[CNDownLoadGifManager filePath:localYouxuanGifName]]) { | ||
| 80 | + /**本地不存在下载*/ | ||
| 81 | + [CNDownLoadGifManager downLoadGifByUrl:youxuanUrl giftType:CNDownLoadYouxuanGifType]; | ||
| 82 | + } | ||
| 83 | + else if (![localYouxuanGifName isEqualToString:newYouxuanGifName]) { | ||
| 84 | + /**下载最新的优选库 gif*/ | ||
| 85 | + [CNDownLoadGifManager downLoadGifByUrl:youxuanUrl giftType:CNDownLoadYouxuanGifType]; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + } | ||
| 89 | + else | ||
| 90 | + { | ||
| 91 | + [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:CNYouxuanGitName]; | ||
| 92 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 93 | + } | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +/// 下载gif | ||
| 97 | +/// @param strUrl 下载地址 | ||
| 98 | +/// @param giftType 下载gif类型 | ||
| 99 | ++ (void)downLoadGifByUrl:(NSString *)strUrl giftType:(CNDownLoadGifType)giftType | ||
| 100 | +{ | ||
| 101 | + NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
| 102 | + NSLog(@"strUrl.lastPathComponent = %@",strUrl.lastPathComponent); | ||
| 103 | + NSURLSession *session = [NSURLSession sessionWithConfiguration:config]; | ||
| 104 | + | ||
| 105 | + NSURL *url = [NSURL URLWithString:strUrl]; | ||
| 106 | + | ||
| 107 | + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | ||
| 108 | + NSURLSessionDownloadTask *task = [session downloadTaskWithURL:url completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { | ||
| 109 | + | ||
| 110 | + if (error) { | ||
| 111 | + | ||
| 112 | + NSLog(@"gif download error:%@", error); | ||
| 113 | + | ||
| 114 | + } else { | ||
| 115 | + | ||
| 116 | + NSLog(@"gif download success, file path:%@",location.path); | ||
| 117 | + | ||
| 118 | + //图片下载已完成,处理数据 | ||
| 119 | + NSData *data = [[NSData alloc] initWithContentsOfFile:location.path]; | ||
| 120 | + if ([data writeToFile:[self filePath:strUrl.lastPathComponent] atomically:YES]) { | ||
| 121 | + NSLog(@"gif写入成功"); | ||
| 122 | + switch (giftType) { | ||
| 123 | + case CNDownLoadMomentGifType: | ||
| 124 | + { | ||
| 125 | + /**把生活圈 Git 名保存到本地*/ | ||
| 126 | + [[NSUserDefaults standardUserDefaults] setObject:strUrl.lastPathComponent forKey:CNMomentGitName]; | ||
| 127 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 128 | + } | ||
| 129 | + break; | ||
| 130 | + case CNDownLoadSubscribeGifType: | ||
| 131 | + { | ||
| 132 | + /**把订阅号 Git 名保存到本地*/ | ||
| 133 | + [[NSUserDefaults standardUserDefaults] setObject:strUrl.lastPathComponent forKey:CNSubscribeGitName]; | ||
| 134 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 135 | + } | ||
| 136 | + break; | ||
| 137 | + case CNDownLoadYouxuanGifType: | ||
| 138 | + { | ||
| 139 | + /**把优选库 Git 名保存到本地*/ | ||
| 140 | + [[NSUserDefaults standardUserDefaults] setObject:strUrl.lastPathComponent forKey:CNYouxuanGitName]; | ||
| 141 | + [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 142 | + } | ||
| 143 | + break; | ||
| 144 | + default: | ||
| 145 | + break; | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + }]; | ||
| 151 | + [task resume]; | ||
| 152 | + }); | ||
| 153 | + | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +/// 返回文件路径 | ||
| 157 | +/// @param fileName 文件名 | ||
| 158 | ++(NSString *)filePath:(NSString *)fileName | ||
| 159 | +{ | ||
| 160 | + NSString *homePageGif = [NSString stringWithFormat:@"Documents/HomePageGif"]; | ||
| 161 | + NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:homePageGif]; | ||
| 162 | + | ||
| 163 | + NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| 164 | + | ||
| 165 | + BOOL isDir = NO; | ||
| 166 | + BOOL existed = [fileManager fileExistsAtPath:filePath isDirectory:&isDir]; | ||
| 167 | + /**HomePageGif文件夹不存在就创建*/ | ||
| 168 | + if ( !(isDir == YES && existed == YES) ) { | ||
| 169 | + [fileManager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + //拼接文件名 | ||
| 173 | + filePath = [NSString stringWithFormat:@"%@/%@",filePath,fileName]; | ||
| 174 | + | ||
| 175 | + return filePath; | ||
| 176 | +} | ||
| 177 | +@end |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadManager/CNLiveWebImageManager.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebImageManager.h | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/21. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | +#import <UIKit/UIKit.h> | ||
| 11 | + | ||
| 12 | +NS_ASSUME_NONNULL_BEGIN | ||
| 13 | + | ||
| 14 | +typedef void(^DownloadBack)(NSMutableArray *imagePaths,Boolean isLocation); | ||
| 15 | + | ||
| 16 | +@interface CNLiveWebImageManager : NSObject | ||
| 17 | + | ||
| 18 | + | ||
| 19 | +/// 单例 | ||
| 20 | ++ (instancetype)share; | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +#pragma mark -下载 | ||
| 24 | +/// 多张下载 | ||
| 25 | +/// @param imageUrls 多个urls | ||
| 26 | +/// @param completion 完成 | ||
| 27 | +- (void)downloadImageWithUrls:(NSMutableArray *)imageUrls completion:(DownloadBack)completion; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +/// 多张下载 | ||
| 31 | +/// @param imageUrls 多张urls | ||
| 32 | +/// @param path 指定路径 | ||
| 33 | +/// @param completion 完成 | ||
| 34 | +- (void)downloadImageWithUrls:(NSMutableArray *)imageUrls path:(NSString *)path completion:(DownloadBack)completion; | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +///清除默认路径下的缓存,无回调 | ||
| 38 | +- (void)clearCache; | ||
| 39 | +///清除指定路径下的缓存,无回调 | ||
| 40 | +- (void)clearCacheWithPath:(NSString *)path; | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +@end | ||
| 45 | + | ||
| 46 | +NS_ASSUME_NONNULL_END |
CNLiveBaseTools/Classes/TabBarEditIcon/WebLoadManager/CNLiveWebImageManager.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveWebImageManager.m | ||
| 3 | +// CNLiveNetAdd | ||
| 4 | +// | ||
| 5 | +// Created by 梁星国 on 2019/11/21. | ||
| 6 | +// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveWebImageManager.h" | ||
| 10 | +#import "CNLiveWebImageCacheManager.h" | ||
| 11 | +#import "NSFileManager+ImgPath.h" | ||
| 12 | +#import <SDWebImage/SDWebImage.h> | ||
| 13 | + | ||
| 14 | +//中间层文件夹 | ||
| 15 | +NSString *const webMidPath =@"CNLiveWebImg"; | ||
| 16 | +//默认图片缓存路径文件夹 | ||
| 17 | +NSString *const webDefaultCachePath = @"WebImageCache"; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +@interface CNLiveWebImageManager () | ||
| 21 | + | ||
| 22 | +@property (nonatomic ,strong) dispatch_queue_t operationQueue; | ||
| 23 | +//默认缓存路径 | ||
| 24 | +@property (nonatomic ,copy) NSString *cachePath; | ||
| 25 | + | ||
| 26 | +@end | ||
| 27 | + | ||
| 28 | +@implementation CNLiveWebImageManager | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +//单例 | ||
| 32 | ++ (instancetype)share{ | ||
| 33 | + static CNLiveWebImageManager *instance = nil; | ||
| 34 | + static dispatch_once_t onceToken; | ||
| 35 | + dispatch_once(&onceToken, ^{ | ||
| 36 | + instance = [[CNLiveWebImageManager alloc] init]; | ||
| 37 | + }); | ||
| 38 | + return instance; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +- (instancetype)init | ||
| 42 | +{ | ||
| 43 | + self = [super init]; | ||
| 44 | + if (self) { | ||
| 45 | + //创建缓存文件夹 | ||
| 46 | + [[CNLiveWebImageCacheManager share] createFileAtPath:self.cachePath]; | ||
| 47 | + } | ||
| 48 | + return self; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +/// 多张下载 | ||
| 52 | +/// @param imageUrls 多个urls | ||
| 53 | +/// @param completion 多有完成 | ||
| 54 | +- (void)downloadImageWithUrls:(NSMutableArray *)imageUrls completion:(DownloadBack)completion { | ||
| 55 | + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | ||
| 56 | + | ||
| 57 | + Boolean isLoc = YES; | ||
| 58 | + /*** 先检测是否都在本地 ***/ | ||
| 59 | + for (NSString *checkImgPath in imageUrls) { | ||
| 60 | + NSString *checckImgParhStr = [NSString stringWithFormat:@"%@",checkImgPath]; | ||
| 61 | + if ([[CNLiveWebImageCacheManager share] isExistsCacheWithKey:checckImgParhStr path:self.cachePath]) {//存在 | ||
| 62 | + | ||
| 63 | + }else {//没有 | ||
| 64 | + isLoc = NO; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + /*** 所有都在本地 ***/ | ||
| 68 | + if (isLoc) { | ||
| 69 | + | ||
| 70 | + NSArray *array = [[CNLiveWebImageCacheManager share] getCacheImageFileArrayWithPath:self.cachePath]; | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + completion(imageUrls,isLoc); | ||
| 74 | + return; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /*** 筛选并将网络图片下载 ***/ | ||
| 78 | + /*** 线程租 ***/ | ||
| 79 | + dispatch_group_t group = dispatch_group_create(); | ||
| 80 | + | ||
| 81 | + NSMutableArray *loacationImgPaths = [NSMutableArray array]; | ||
| 82 | + | ||
| 83 | + for (NSString *imagePath in imageUrls) { | ||
| 84 | + | ||
| 85 | + NSString *imagePathStr = [NSString stringWithFormat:@"%@",imagePath]; | ||
| 86 | + | ||
| 87 | + if ([[CNLiveWebImageCacheManager share] isExistsCacheWithKey:imagePathStr path:self.cachePath]) {//存在 | ||
| 88 | + continue; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /*** 下载 ***/ | ||
| 92 | + dispatch_group_enter(group); | ||
| 93 | + [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:imagePathStr] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { | ||
| 94 | + | ||
| 95 | + if (finished && data) { | ||
| 96 | + NSLog(@"输出成功下载一个图片"); | ||
| 97 | + [[CNLiveWebImageCacheManager share] cacheContent:data key:imagePathStr path:self.cachePath completion:^(BOOL isSuccess) { | ||
| 98 | + if (isSuccess) { | ||
| 99 | + | ||
| 100 | + if ([[CNLiveWebImageCacheManager share] isExistsCacheWithKey:imagePathStr path:self.cachePath]) {//存在 | ||
| 101 | + | ||
| 102 | + [loacationImgPaths addObject:imagePathStr]; | ||
| 103 | + dispatch_group_leave(group); | ||
| 104 | + | ||
| 105 | + }else {//没有 | ||
| 106 | + dispatch_group_leave(group); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + }else {//存储失败 | ||
| 110 | + dispatch_group_leave(group); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + }]; | ||
| 114 | + }else {//下载失败 | ||
| 115 | + dispatch_group_leave(group); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + }]; | ||
| 119 | + | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ | ||
| 123 | + NSLog(@"全部完成下载,输出个数 = %ld",loacationImgPaths.count); | ||
| 124 | + | ||
| 125 | + for (NSString *locationImgStr in loacationImgPaths) { | ||
| 126 | + NSDictionary *dic = [[CNLiveWebImageCacheManager share] getCacheImageInfoWithKey:locationImgStr path:self.cachePath]; | ||
| 127 | + NSLog(@"输出存储文件的信息 = %@",dic); | ||
| 128 | + } | ||
| 129 | + completion(loacationImgPaths,isLoc); | ||
| 130 | + }); | ||
| 131 | + | ||
| 132 | + | ||
| 133 | + }); | ||
| 134 | + | ||
| 135 | + | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | + | ||
| 139 | +/// 多张下载 | ||
| 140 | +/// @param imageUrls 多个urls | ||
| 141 | +/// @param path 指定路径 | ||
| 142 | +/// @param completion 多有完成 | ||
| 143 | +- (void)downloadImageWithUrls:(NSMutableArray *)imageUrls path:(NSString *)path completion:(DownloadBack)completion { | ||
| 144 | + | ||
| 145 | + /*** 线程租 ***/ | ||
| 146 | + dispatch_group_t group = dispatch_group_create(); | ||
| 147 | + | ||
| 148 | + for (NSString *imagePath in imageUrls) { | ||
| 149 | + | ||
| 150 | + NSString *imagePathStr = [NSString stringWithFormat:@"%@",imagePath]; | ||
| 151 | + | ||
| 152 | + /*** 下载 ***/ | ||
| 153 | + dispatch_group_enter(group); | ||
| 154 | + [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:imagePathStr] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { | ||
| 155 | + dispatch_group_leave(group); | ||
| 156 | + if (finished) { | ||
| 157 | + NSLog(@"输出成功下载一个图片"); | ||
| 158 | + if (data) { | ||
| 159 | + dispatch_group_enter(group); | ||
| 160 | + [[CNLiveWebImageCacheManager share] cacheContent:data key:imagePathStr path:path completion:^(BOOL isSuccess) { | ||
| 161 | + dispatch_group_leave(group); | ||
| 162 | + | ||
| 163 | + }]; | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + }]; | ||
| 168 | + | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ | ||
| 172 | + NSLog(@"全部完成下载"); | ||
| 173 | + }); | ||
| 174 | + | ||
| 175 | + | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | + | ||
| 179 | +///清除默认路径下的缓存,无回调 | ||
| 180 | +- (void)clearCache { | ||
| 181 | + [self clearCacheWithPath:self.cachePath]; | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +///清除指定路径下的缓存,无回调 | ||
| 185 | +- (void)clearCacheWithPath:(NSString *)path { | ||
| 186 | + | ||
| 187 | + [[CNLiveWebImageCacheManager share] clearCacheWithPath:path]; | ||
| 188 | + | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +#pragma mark - 路径 | ||
| 192 | +/// 返回图片中间层文件夹(默认定死的) | ||
| 193 | +- (NSString *)getMidFilePath{ | ||
| 194 | + NSString *path = [[NSFileManager documentsPath] stringByAppendingPathComponent:webMidPath]; | ||
| 195 | + return path; | ||
| 196 | +} | ||
| 197 | + | ||
| 198 | +#pragma mark - 属性 | ||
| 199 | +- (dispatch_queue_t)operationQueue{ | ||
| 200 | + if (!_operationQueue) { | ||
| 201 | + _operationQueue = dispatch_queue_create("com.CNLive.WebManager", DISPATCH_QUEUE_SERIAL); | ||
| 202 | + } | ||
| 203 | + return _operationQueue; | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | + | ||
| 207 | +-(NSString *)cachePath{ | ||
| 208 | + if (!_cachePath) { | ||
| 209 | + _cachePath = [[self getMidFilePath] stringByAppendingPathComponent:webDefaultCachePath]; | ||
| 210 | + } | ||
| 211 | + return _cachePath; | ||
| 212 | +} | ||
| 213 | + | ||
| 214 | + | ||
| 215 | + | ||
| 216 | + | ||
| 217 | +@end |
Example/CNLiveBaseTools.xcodeproj/project.pbxproj
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | objects = { | 7 | objects = { |
| 8 | 8 | ||
| 9 | /* Begin PBXBuildFile section */ | 9 | /* Begin PBXBuildFile section */ |
| 10 | + 089886C527A2890C00C469D3 /* BeigerSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 089886C427A2890C00C469D3 /* BeigerSwift.swift */; }; | ||
| 10 | 4A1C5764892F3772DB1BC0FA /* Pods_CNLiveBaseTools_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30EBFFB403ADBCF7372F102C /* Pods_CNLiveBaseTools_Tests.framework */; }; | 11 | 4A1C5764892F3772DB1BC0FA /* Pods_CNLiveBaseTools_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30EBFFB403ADBCF7372F102C /* Pods_CNLiveBaseTools_Tests.framework */; }; |
| 11 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; | 12 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; |
| 12 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; | 13 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; |
| @@ -37,10 +38,12 @@ | @@ -37,10 +38,12 @@ | ||
| 37 | /* End PBXContainerItemProxy section */ | 38 | /* End PBXContainerItemProxy section */ |
| 38 | 39 | ||
| 39 | /* Begin PBXFileReference section */ | 40 | /* Begin PBXFileReference section */ |
| 41 | + 089886C327A2890B00C469D3 /* CNLiveBaseTools_Example-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CNLiveBaseTools_Example-Bridging-Header.h"; sourceTree = "<group>"; }; | ||
| 42 | + 089886C427A2890C00C469D3 /* BeigerSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeigerSwift.swift; sourceTree = "<group>"; }; | ||
| 40 | 30EBFFB403ADBCF7372F102C /* Pods_CNLiveBaseTools_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLiveBaseTools_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | 43 | 30EBFFB403ADBCF7372F102C /* Pods_CNLiveBaseTools_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLiveBaseTools_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 41 | 343C02ECB62DC97B331F61EA /* Pods-CNLiveBaseTools_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveBaseTools_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CNLiveBaseTools_Tests/Pods-CNLiveBaseTools_Tests.debug.xcconfig"; sourceTree = "<group>"; }; | 44 | 343C02ECB62DC97B331F61EA /* Pods-CNLiveBaseTools_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveBaseTools_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CNLiveBaseTools_Tests/Pods-CNLiveBaseTools_Tests.debug.xcconfig"; sourceTree = "<group>"; }; |
| 42 | 35DDD35853901065714DBDCE /* Pods_CNLiveBaseTools_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLiveBaseTools_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | 45 | 35DDD35853901065714DBDCE /* Pods_CNLiveBaseTools_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLiveBaseTools_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 43 | - 4984FF53638ED216DEA100FC /* CNLiveBaseTools.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CNLiveBaseTools.podspec; path = ../CNLiveBaseTools.podspec; sourceTree = "<group>"; }; | 46 | + 4984FF53638ED216DEA100FC /* CNLiveBaseTools.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CNLiveBaseTools.podspec; path = ../CNLiveBaseTools.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; |
| 44 | 6003F58A195388D20070C39A /* CNLiveBaseTools_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLiveBaseTools_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; | 47 | 6003F58A195388D20070C39A /* CNLiveBaseTools_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNLiveBaseTools_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 45 | 6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; | 48 | 6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; |
| 46 | 6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | 49 | 6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; |
| @@ -140,6 +143,8 @@ | @@ -140,6 +143,8 @@ | ||
| 140 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */, | 143 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */, |
| 141 | 6003F5A8195388D20070C39A /* Images.xcassets */, | 144 | 6003F5A8195388D20070C39A /* Images.xcassets */, |
| 142 | 6003F594195388D20070C39A /* Supporting Files */, | 145 | 6003F594195388D20070C39A /* Supporting Files */, |
| 146 | + 089886C427A2890C00C469D3 /* BeigerSwift.swift */, | ||
| 147 | + 089886C327A2890B00C469D3 /* CNLiveBaseTools_Example-Bridging-Header.h */, | ||
| 143 | ); | 148 | ); |
| 144 | name = "Example for CNLiveBaseTools"; | 149 | name = "Example for CNLiveBaseTools"; |
| 145 | path = CNLiveBaseTools; | 150 | path = CNLiveBaseTools; |
| @@ -249,6 +254,7 @@ | @@ -249,6 +254,7 @@ | ||
| 249 | TargetAttributes = { | 254 | TargetAttributes = { |
| 250 | 6003F589195388D20070C39A = { | 255 | 6003F589195388D20070C39A = { |
| 251 | DevelopmentTeam = 94X49GG3ZW; | 256 | DevelopmentTeam = 94X49GG3ZW; |
| 257 | + LastSwiftMigration = 1300; | ||
| 252 | }; | 258 | }; |
| 253 | 6003F5AD195388D20070C39A = { | 259 | 6003F5AD195388D20070C39A = { |
| 254 | TestTargetID = 6003F589195388D20070C39A; | 260 | TestTargetID = 6003F589195388D20070C39A; |
| @@ -260,6 +266,7 @@ | @@ -260,6 +266,7 @@ | ||
| 260 | developmentRegion = English; | 266 | developmentRegion = English; |
| 261 | hasScannedForEncodings = 0; | 267 | hasScannedForEncodings = 0; |
| 262 | knownRegions = ( | 268 | knownRegions = ( |
| 269 | + English, | ||
| 263 | en, | 270 | en, |
| 264 | Base, | 271 | Base, |
| 265 | ); | 272 | ); |
| @@ -346,21 +353,35 @@ | @@ -346,21 +353,35 @@ | ||
| 346 | buildActionMask = 2147483647; | 353 | buildActionMask = 2147483647; |
| 347 | files = ( | 354 | files = ( |
| 348 | ); | 355 | ); |
| 349 | - inputFileListPaths = ( | ||
| 350 | - ); | ||
| 351 | inputPaths = ( | 356 | inputPaths = ( |
| 352 | - "${SRCROOT}/Pods/Target Support Files/Pods-CNLiveBaseTools_Example/Pods-CNLiveBaseTools_Example-frameworks.sh", | 357 | + "${PODS_ROOT}/Target Support Files/Pods-CNLiveBaseTools_Example/Pods-CNLiveBaseTools_Example-frameworks.sh", |
| 358 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", | ||
| 353 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", | 359 | "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", |
| 360 | + "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", | ||
| 361 | + "${BUILT_PRODUCTS_DIR}/CNLiveNewTripartiteManagement/CNLiveNewTripartiteManagement.framework", | ||
| 362 | + "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", | ||
| 363 | + "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", | ||
| 364 | + "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", | ||
| 365 | + "${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework", | ||
| 366 | + "${BUILT_PRODUCTS_DIR}/YYCategories/YYCategories.framework", | ||
| 367 | + "${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework", | ||
| 354 | ); | 368 | ); |
| 355 | name = "[CP] Embed Pods Frameworks"; | 369 | name = "[CP] Embed Pods Frameworks"; |
| 356 | - outputFileListPaths = ( | ||
| 357 | - ); | ||
| 358 | outputPaths = ( | 370 | outputPaths = ( |
| 371 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", | ||
| 359 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", | 372 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", |
| 373 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", | ||
| 374 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveNewTripartiteManagement.framework", | ||
| 375 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", | ||
| 376 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", | ||
| 377 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", | ||
| 378 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SSZipArchive.framework", | ||
| 379 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYCategories.framework", | ||
| 380 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework", | ||
| 360 | ); | 381 | ); |
| 361 | runOnlyForDeploymentPostprocessing = 0; | 382 | runOnlyForDeploymentPostprocessing = 0; |
| 362 | shellPath = /bin/sh; | 383 | shellPath = /bin/sh; |
| 363 | - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CNLiveBaseTools_Example/Pods-CNLiveBaseTools_Example-frameworks.sh\"\n"; | 384 | + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CNLiveBaseTools_Example/Pods-CNLiveBaseTools_Example-frameworks.sh\"\n"; |
| 364 | showEnvVarsInLog = 0; | 385 | showEnvVarsInLog = 0; |
| 365 | }; | 386 | }; |
| 366 | /* End PBXShellScriptBuildPhase section */ | 387 | /* End PBXShellScriptBuildPhase section */ |
| @@ -373,6 +394,7 @@ | @@ -373,6 +394,7 @@ | ||
| 373 | 6003F59E195388D20070C39A /* CNLiveAppDelegate.m in Sources */, | 394 | 6003F59E195388D20070C39A /* CNLiveAppDelegate.m in Sources */, |
| 374 | 6003F5A7195388D20070C39A /* CNLiveViewController.m in Sources */, | 395 | 6003F5A7195388D20070C39A /* CNLiveViewController.m in Sources */, |
| 375 | 6003F59A195388D20070C39A /* main.m in Sources */, | 396 | 6003F59A195388D20070C39A /* main.m in Sources */, |
| 397 | + 089886C527A2890C00C469D3 /* BeigerSwift.swift in Sources */, | ||
| 376 | ); | 398 | ); |
| 377 | runOnlyForDeploymentPostprocessing = 0; | 399 | runOnlyForDeploymentPostprocessing = 0; |
| 378 | }; | 400 | }; |
| @@ -500,14 +522,19 @@ | @@ -500,14 +522,19 @@ | ||
| 500 | baseConfigurationReference = E99F8259F99F21E31465646D /* Pods-CNLiveBaseTools_Example.debug.xcconfig */; | 522 | baseConfigurationReference = E99F8259F99F21E31465646D /* Pods-CNLiveBaseTools_Example.debug.xcconfig */; |
| 501 | buildSettings = { | 523 | buildSettings = { |
| 502 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | 524 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
| 525 | + CLANG_ENABLE_MODULES = YES; | ||
| 503 | DEVELOPMENT_TEAM = 94X49GG3ZW; | 526 | DEVELOPMENT_TEAM = 94X49GG3ZW; |
| 504 | GCC_PRECOMPILE_PREFIX_HEADER = YES; | 527 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
| 505 | GCC_PREFIX_HEADER = "CNLiveBaseTools/CNLiveBaseTools-Prefix.pch"; | 528 | GCC_PREFIX_HEADER = "CNLiveBaseTools/CNLiveBaseTools-Prefix.pch"; |
| 506 | INFOPLIST_FILE = "CNLiveBaseTools/CNLiveBaseTools-Info.plist"; | 529 | INFOPLIST_FILE = "CNLiveBaseTools/CNLiveBaseTools-Info.plist"; |
| 507 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; | 530 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; |
| 531 | + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
| 508 | MODULE_NAME = ExampleApp; | 532 | MODULE_NAME = ExampleApp; |
| 509 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; | 533 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; |
| 510 | PRODUCT_NAME = "$(TARGET_NAME)"; | 534 | PRODUCT_NAME = "$(TARGET_NAME)"; |
| 535 | + SWIFT_OBJC_BRIDGING_HEADER = "CNLiveBaseTools/CNLiveBaseTools_Example-Bridging-Header.h"; | ||
| 536 | + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
| 537 | + SWIFT_VERSION = 5.0; | ||
| 511 | WRAPPER_EXTENSION = app; | 538 | WRAPPER_EXTENSION = app; |
| 512 | }; | 539 | }; |
| 513 | name = Debug; | 540 | name = Debug; |
| @@ -517,14 +544,18 @@ | @@ -517,14 +544,18 @@ | ||
| 517 | baseConfigurationReference = D6B8BAE000FCD669B6DBDC7A /* Pods-CNLiveBaseTools_Example.release.xcconfig */; | 544 | baseConfigurationReference = D6B8BAE000FCD669B6DBDC7A /* Pods-CNLiveBaseTools_Example.release.xcconfig */; |
| 518 | buildSettings = { | 545 | buildSettings = { |
| 519 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | 546 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
| 547 | + CLANG_ENABLE_MODULES = YES; | ||
| 520 | DEVELOPMENT_TEAM = 94X49GG3ZW; | 548 | DEVELOPMENT_TEAM = 94X49GG3ZW; |
| 521 | GCC_PRECOMPILE_PREFIX_HEADER = YES; | 549 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
| 522 | GCC_PREFIX_HEADER = "CNLiveBaseTools/CNLiveBaseTools-Prefix.pch"; | 550 | GCC_PREFIX_HEADER = "CNLiveBaseTools/CNLiveBaseTools-Prefix.pch"; |
| 523 | INFOPLIST_FILE = "CNLiveBaseTools/CNLiveBaseTools-Info.plist"; | 551 | INFOPLIST_FILE = "CNLiveBaseTools/CNLiveBaseTools-Info.plist"; |
| 524 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; | 552 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; |
| 553 | + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
| 525 | MODULE_NAME = ExampleApp; | 554 | MODULE_NAME = ExampleApp; |
| 526 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; | 555 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; |
| 527 | PRODUCT_NAME = "$(TARGET_NAME)"; | 556 | PRODUCT_NAME = "$(TARGET_NAME)"; |
| 557 | + SWIFT_OBJC_BRIDGING_HEADER = "CNLiveBaseTools/CNLiveBaseTools_Example-Bridging-Header.h"; | ||
| 558 | + SWIFT_VERSION = 5.0; | ||
| 528 | WRAPPER_EXTENSION = app; | 559 | WRAPPER_EXTENSION = app; |
| 529 | }; | 560 | }; |
| 530 | name = Release; | 561 | name = Release; |
| @@ -533,6 +564,7 @@ | @@ -533,6 +564,7 @@ | ||
| 533 | isa = XCBuildConfiguration; | 564 | isa = XCBuildConfiguration; |
| 534 | baseConfigurationReference = 343C02ECB62DC97B331F61EA /* Pods-CNLiveBaseTools_Tests.debug.xcconfig */; | 565 | baseConfigurationReference = 343C02ECB62DC97B331F61EA /* Pods-CNLiveBaseTools_Tests.debug.xcconfig */; |
| 535 | buildSettings = { | 566 | buildSettings = { |
| 567 | + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; | ||
| 536 | BUNDLE_LOADER = "$(TEST_HOST)"; | 568 | BUNDLE_LOADER = "$(TEST_HOST)"; |
| 537 | FRAMEWORK_SEARCH_PATHS = ( | 569 | FRAMEWORK_SEARCH_PATHS = ( |
| 538 | "$(SDKROOT)/Developer/Library/Frameworks", | 570 | "$(SDKROOT)/Developer/Library/Frameworks", |
| @@ -557,6 +589,7 @@ | @@ -557,6 +589,7 @@ | ||
| 557 | isa = XCBuildConfiguration; | 589 | isa = XCBuildConfiguration; |
| 558 | baseConfigurationReference = 775105512AF49730C481ED7A /* Pods-CNLiveBaseTools_Tests.release.xcconfig */; | 590 | baseConfigurationReference = 775105512AF49730C481ED7A /* Pods-CNLiveBaseTools_Tests.release.xcconfig */; |
| 559 | buildSettings = { | 591 | buildSettings = { |
| 592 | + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; | ||
| 560 | BUNDLE_LOADER = "$(TEST_HOST)"; | 593 | BUNDLE_LOADER = "$(TEST_HOST)"; |
| 561 | FRAMEWORK_SEARCH_PATHS = ( | 594 | FRAMEWORK_SEARCH_PATHS = ( |
| 562 | "$(SDKROOT)/Developer/Library/Frameworks", | 595 | "$(SDKROOT)/Developer/Library/Frameworks", |
Example/CNLiveBaseTools/BeigerSwift.swift
0 → 100644
Example/CNLiveBaseTools/CNLiveBaseTools_Example-Bridging-Header.h
0 → 100644
Example/Podfile
| 1 | use_frameworks! | 1 | use_frameworks! |
| 2 | 2 | ||
| 3 | -platform :ios, '9.0' | ||
| 4 | - | 3 | +platform :ios, '10.0' |
| 4 | +source 'http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git' | ||
| 5 | +source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' | ||
| 5 | target 'CNLiveBaseTools_Example' do | 6 | target 'CNLiveBaseTools_Example' do |
| 6 | pod 'CNLiveBaseTools', :path => '../' | 7 | pod 'CNLiveBaseTools', :path => '../' |
| 7 | 8 |
Example/Podfile.lock
| 1 | PODS: | 1 | PODS: |
| 2 | - - CNLiveBaseTools (0.1.0) | 2 | + - CNLiveBaseKit (0.1.23): |
| 3 | + - CNLiveNewTripartiteManagement/MJExtension | ||
| 4 | + - CNLiveBaseTools (0.0.3): | ||
| 5 | + - CNLiveBaseKit | ||
| 6 | + - CNLiveBeeHive | ||
| 7 | + - CNLiveNewTripartiteManagement/QMUIKit | ||
| 8 | + - CNLiveNewTripartiteManagement/SDWebImage | ||
| 9 | + - CNLiveNewTripartiteManagement/SSZipArchive | ||
| 10 | + - CNLiveNewTripartiteManagement/YYCategories | ||
| 11 | + - CNLiveNewTripartiteManagement/YYImage | ||
| 12 | + - CNLiveBeeHive (0.1.9) | ||
| 13 | + - CNLiveNewTripartiteManagement/MJExtension (0.2.0.6): | ||
| 14 | + - MJExtension (= 3.2.1) | ||
| 15 | + - CNLiveNewTripartiteManagement/QMUIKit (0.2.0.6): | ||
| 16 | + - QMUIKit (= 4.2.1) | ||
| 17 | + - CNLiveNewTripartiteManagement/SDWebImage (0.2.0.6): | ||
| 18 | + - SDWebImage (= 5.2.3) | ||
| 19 | + - CNLiveNewTripartiteManagement/SSZipArchive (0.2.0.6): | ||
| 20 | + - SSZipArchive (= 2.1.5) | ||
| 21 | + - CNLiveNewTripartiteManagement/YYCategories (0.2.0.6): | ||
| 22 | + - YYCategories (= 1.0.4) | ||
| 23 | + - CNLiveNewTripartiteManagement/YYImage (0.2.0.6): | ||
| 24 | + - YYImage (= 1.0.4) | ||
| 25 | + - MJExtension (3.2.1) | ||
| 26 | + - QMUIKit (4.2.1): | ||
| 27 | + - QMUIKit/QMUIComponents (= 4.2.1) | ||
| 28 | + - QMUIKit/QMUICore (= 4.2.1) | ||
| 29 | + - QMUIKit/QMUILog (= 4.2.1) | ||
| 30 | + - QMUIKit/QMUIMainFrame (= 4.2.1) | ||
| 31 | + - QMUIKit/QMUIResources (= 4.2.1) | ||
| 32 | + - QMUIKit/QMUIWeakObjectContainer (= 4.2.1) | ||
| 33 | + - QMUIKit/QMUIComponents (4.2.1): | ||
| 34 | + - QMUIKit/QMUIComponents/NavigationBarTransition (= 4.2.1) | ||
| 35 | + - QMUIKit/QMUIComponents/QMUIAlertController (= 4.2.1) | ||
| 36 | + - QMUIKit/QMUIComponents/QMUIAnimation (= 4.2.1) | ||
| 37 | + - QMUIKit/QMUIComponents/QMUIAppearance (= 4.2.1) | ||
| 38 | + - QMUIKit/QMUIComponents/QMUIAssetLibrary (= 4.2.1) | ||
| 39 | + - QMUIKit/QMUIComponents/QMUIBadge (= 4.2.1) | ||
| 40 | + - QMUIKit/QMUIComponents/QMUIButton (= 4.2.1) | ||
| 41 | + - QMUIKit/QMUIComponents/QMUICAAnimationExtension (= 4.2.1) | ||
| 42 | + - QMUIKit/QMUIComponents/QMUICALayerExtension (= 4.2.1) | ||
| 43 | + - QMUIKit/QMUIComponents/QMUICellHeightCache (= 4.2.1) | ||
| 44 | + - QMUIKit/QMUIComponents/QMUICellHeightKeyCache (= 4.2.1) | ||
| 45 | + - QMUIKit/QMUIComponents/QMUICellSizeKeyCache (= 4.2.1) | ||
| 46 | + - QMUIKit/QMUIComponents/QMUICollectionViewPagingLayout (= 4.2.1) | ||
| 47 | + - QMUIKit/QMUIComponents/QMUIConsole (= 4.2.1) | ||
| 48 | + - QMUIKit/QMUIComponents/QMUIDialogViewController (= 4.2.1) | ||
| 49 | + - QMUIKit/QMUIComponents/QMUIEmotionInputManager (= 4.2.1) | ||
| 50 | + - QMUIKit/QMUIComponents/QMUIEmotionView (= 4.2.1) | ||
| 51 | + - QMUIKit/QMUIComponents/QMUIEmptyView (= 4.2.1) | ||
| 52 | + - QMUIKit/QMUIComponents/QMUIFillButton (= 4.2.1) | ||
| 53 | + - QMUIKit/QMUIComponents/QMUIFloatLayoutView (= 4.2.1) | ||
| 54 | + - QMUIKit/QMUIComponents/QMUIGhostButton (= 4.2.1) | ||
| 55 | + - QMUIKit/QMUIComponents/QMUIGridView (= 4.2.1) | ||
| 56 | + - QMUIKit/QMUIComponents/QMUIImagePickerLibrary (= 4.2.1) | ||
| 57 | + - QMUIKit/QMUIComponents/QMUIImagePreviewView (= 4.2.1) | ||
| 58 | + - QMUIKit/QMUIComponents/QMUIKeyboardManager (= 4.2.1) | ||
| 59 | + - QMUIKit/QMUIComponents/QMUILabel (= 4.2.1) | ||
| 60 | + - QMUIKit/QMUIComponents/QMUILinkButton (= 4.2.1) | ||
| 61 | + - QMUIKit/QMUIComponents/QMUILogManagerViewController (= 4.2.1) | ||
| 62 | + - QMUIKit/QMUIComponents/QMUILogWithConfigurationSupported (= 4.2.1) | ||
| 63 | + - QMUIKit/QMUIComponents/QMUIMarqueeLabel (= 4.2.1) | ||
| 64 | + - QMUIKit/QMUIComponents/QMUIModalPresentationViewController (= 4.2.1) | ||
| 65 | + - QMUIKit/QMUIComponents/QMUIMoreOperationController (= 4.2.1) | ||
| 66 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates (= 4.2.1) | ||
| 67 | + - QMUIKit/QMUIComponents/QMUINavigationButton (= 4.2.1) | ||
| 68 | + - QMUIKit/QMUIComponents/QMUINavigationTitleView (= 4.2.1) | ||
| 69 | + - QMUIKit/QMUIComponents/QMUIOrderedDictionary (= 4.2.1) | ||
| 70 | + - QMUIKit/QMUIComponents/QMUIPieProgressView (= 4.2.1) | ||
| 71 | + - QMUIKit/QMUIComponents/QMUIPopupContainerView (= 4.2.1) | ||
| 72 | + - QMUIKit/QMUIComponents/QMUIPopupMenuView (= 4.2.1) | ||
| 73 | + - QMUIKit/QMUIComponents/QMUIScrollAnimator (= 4.2.1) | ||
| 74 | + - QMUIKit/QMUIComponents/QMUISearchBar (= 4.2.1) | ||
| 75 | + - QMUIKit/QMUIComponents/QMUISearchController (= 4.2.1) | ||
| 76 | + - QMUIKit/QMUIComponents/QMUISegmentedControl (= 4.2.1) | ||
| 77 | + - QMUIKit/QMUIComponents/QMUISlider (= 4.2.1) | ||
| 78 | + - QMUIKit/QMUIComponents/QMUIStaticTableView (= 4.2.1) | ||
| 79 | + - QMUIKit/QMUIComponents/QMUITableView (= 4.2.1) | ||
| 80 | + - QMUIKit/QMUIComponents/QMUITableViewCell (= 4.2.1) | ||
| 81 | + - QMUIKit/QMUIComponents/QMUITableViewHeaderFooterView (= 4.2.1) | ||
| 82 | + - QMUIKit/QMUIComponents/QMUITableViewProtocols (= 4.2.1) | ||
| 83 | + - QMUIKit/QMUIComponents/QMUITestView (= 4.2.1) | ||
| 84 | + - QMUIKit/QMUIComponents/QMUITextField (= 4.2.1) | ||
| 85 | + - QMUIKit/QMUIComponents/QMUITextView (= 4.2.1) | ||
| 86 | + - QMUIKit/QMUIComponents/QMUITheme (= 4.2.1) | ||
| 87 | + - QMUIKit/QMUIComponents/QMUITips (= 4.2.1) | ||
| 88 | + - QMUIKit/QMUIComponents/QMUIToastView (= 4.2.1) | ||
| 89 | + - QMUIKit/QMUIComponents/QMUIToolbarButton (= 4.2.1) | ||
| 90 | + - QMUIKit/QMUIComponents/QMUIVisualEffectView (= 4.2.1) | ||
| 91 | + - QMUIKit/QMUIComponents/QMUIWindowSizeMonitor (= 4.2.1) | ||
| 92 | + - QMUIKit/QMUIComponents/QMUIZoomImageView (= 4.2.1) | ||
| 93 | + - QMUIKit/QMUICore | ||
| 94 | + - QMUIKit/QMUIComponents/NavigationBarTransition (4.2.1): | ||
| 95 | + - QMUIKit/QMUIComponents/QMUINavigationTitleView | ||
| 96 | + - QMUIKit/QMUICore | ||
| 97 | + - QMUIKit/QMUIMainFrame | ||
| 98 | + - QMUIKit/QMUIComponents/QMUIAlertController (4.2.1): | ||
| 99 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 100 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 101 | + - QMUIKit/QMUIComponents/QMUIKeyboardManager | ||
| 102 | + - QMUIKit/QMUIComponents/QMUIModalPresentationViewController | ||
| 103 | + - QMUIKit/QMUIComponents/QMUITextField | ||
| 104 | + - QMUIKit/QMUICore | ||
| 105 | + - QMUIKit/QMUIComponents/QMUIAnimation (4.2.1): | ||
| 106 | + - QMUIKit/QMUICore | ||
| 107 | + - QMUIKit/QMUIComponents/QMUIAppearance (4.2.1): | ||
| 108 | + - QMUIKit/QMUICore | ||
| 109 | + - QMUIKit/QMUIComponents/QMUIAssetLibrary (4.2.1): | ||
| 110 | + - QMUIKit/QMUICore | ||
| 111 | + - QMUIKit/QMUIComponents/QMUIBadge (4.2.1): | ||
| 112 | + - QMUIKit/QMUIComponents/QMUILabel | ||
| 113 | + - QMUIKit/QMUICore | ||
| 114 | + - QMUIKit/QMUIComponents/QMUIButton (4.2.1): | ||
| 115 | + - QMUIKit/QMUICore | ||
| 116 | + - QMUIKit/QMUIComponents/QMUICAAnimationExtension (4.2.1): | ||
| 117 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 118 | + - QMUIKit/QMUICore | ||
| 119 | + - QMUIKit/QMUIComponents/QMUICALayerExtension (4.2.1): | ||
| 120 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 121 | + - QMUIKit/QMUICore | ||
| 122 | + - QMUIKit/QMUIComponents/QMUICellHeightCache (4.2.1): | ||
| 123 | + - QMUIKit/QMUIComponents/QMUITableViewProtocols | ||
| 124 | + - QMUIKit/QMUICore | ||
| 125 | + - QMUIKit/QMUIComponents/QMUICellHeightKeyCache (4.2.1): | ||
| 126 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 127 | + - QMUIKit/QMUIComponents/QMUITableViewProtocols | ||
| 128 | + - QMUIKit/QMUICore | ||
| 129 | + - QMUIKit/QMUIComponents/QMUICellSizeKeyCache (4.2.1): | ||
| 130 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 131 | + - QMUIKit/QMUICore | ||
| 132 | + - QMUIKit/QMUIComponents/QMUICollectionViewPagingLayout (4.2.1): | ||
| 133 | + - QMUIKit/QMUICore | ||
| 134 | + - QMUIKit/QMUIComponents/QMUIConsole (4.2.1): | ||
| 135 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 136 | + - QMUIKit/QMUIComponents/QMUICAAnimationExtension | ||
| 137 | + - QMUIKit/QMUIComponents/QMUIPopupMenuView | ||
| 138 | + - QMUIKit/QMUIComponents/QMUITextField | ||
| 139 | + - QMUIKit/QMUIComponents/QMUITextView | ||
| 140 | + - QMUIKit/QMUICore | ||
| 141 | + - QMUIKit/QMUIResources | ||
| 142 | + - QMUIKit/QMUIComponents/QMUIDialogViewController (4.2.1): | ||
| 143 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 144 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 145 | + - QMUIKit/QMUIComponents/QMUILabel | ||
| 146 | + - QMUIKit/QMUIComponents/QMUIModalPresentationViewController | ||
| 147 | + - QMUIKit/QMUIComponents/QMUINavigationTitleView | ||
| 148 | + - QMUIKit/QMUIComponents/QMUITableView | ||
| 149 | + - QMUIKit/QMUIComponents/QMUITableViewCell | ||
| 150 | + - QMUIKit/QMUIComponents/QMUITextField | ||
| 151 | + - QMUIKit/QMUICore | ||
| 152 | + - QMUIKit/QMUIMainFrame | ||
| 153 | + - QMUIKit/QMUIComponents/QMUIEmotionInputManager (4.2.1): | ||
| 154 | + - QMUIKit/QMUIComponents/QMUIEmotionView | ||
| 155 | + - QMUIKit/QMUICore | ||
| 156 | + - QMUIKit/QMUIComponents/QMUIEmotionView (4.2.1): | ||
| 157 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 158 | + - QMUIKit/QMUICore | ||
| 159 | + - QMUIKit/QMUIResources | ||
| 160 | + - QMUIKit/QMUIComponents/QMUIEmptyView (4.2.1): | ||
| 161 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 162 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 163 | + - QMUIKit/QMUICore | ||
| 164 | + - QMUIKit/QMUIComponents/QMUIFillButton (4.2.1): | ||
| 165 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 166 | + - QMUIKit/QMUICore | ||
| 167 | + - QMUIKit/QMUIComponents/QMUIFloatLayoutView (4.2.1): | ||
| 168 | + - QMUIKit/QMUICore | ||
| 169 | + - QMUIKit/QMUIComponents/QMUIGhostButton (4.2.1): | ||
| 170 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 171 | + - QMUIKit/QMUICore | ||
| 172 | + - QMUIKit/QMUIComponents/QMUIGridView (4.2.1): | ||
| 173 | + - QMUIKit/QMUICore | ||
| 174 | + - QMUIKit/QMUIComponents/QMUIImagePickerLibrary (4.2.1): | ||
| 175 | + - QMUIKit/QMUIComponents/QMUIAlertController | ||
| 176 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 177 | + - QMUIKit/QMUIComponents/QMUIAssetLibrary | ||
| 178 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 179 | + - QMUIKit/QMUIComponents/QMUIEmptyView | ||
| 180 | + - QMUIKit/QMUIComponents/QMUIImagePreviewView | ||
| 181 | + - QMUIKit/QMUIComponents/QMUINavigationButton | ||
| 182 | + - QMUIKit/QMUIComponents/QMUITableViewCell | ||
| 183 | + - QMUIKit/QMUIComponents/QMUIZoomImageView | ||
| 184 | + - QMUIKit/QMUICore | ||
| 185 | + - QMUIKit/QMUIMainFrame | ||
| 186 | + - QMUIKit/QMUIResources | ||
| 187 | + - QMUIKit/QMUIComponents/QMUIImagePreviewView (4.2.1): | ||
| 188 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 189 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 190 | + - QMUIKit/QMUIComponents/QMUICollectionViewPagingLayout | ||
| 191 | + - QMUIKit/QMUIComponents/QMUIEmptyView | ||
| 192 | + - QMUIKit/QMUIComponents/QMUIPieProgressView | ||
| 193 | + - QMUIKit/QMUIComponents/QMUIZoomImageView | ||
| 194 | + - QMUIKit/QMUICore | ||
| 195 | + - QMUIKit/QMUIMainFrame | ||
| 196 | + - QMUIKit/QMUIComponents/QMUIKeyboardManager (4.2.1): | ||
| 197 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 198 | + - QMUIKit/QMUICore | ||
| 199 | + - QMUIKit/QMUIComponents/QMUILabel (4.2.1): | ||
| 200 | + - QMUIKit/QMUICore | ||
| 201 | + - QMUIKit/QMUIComponents/QMUILinkButton (4.2.1): | ||
| 202 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 203 | + - QMUIKit/QMUICore | ||
| 204 | + - QMUIKit/QMUIComponents/QMUILogManagerViewController (4.2.1): | ||
| 205 | + - QMUIKit/QMUIComponents/QMUIPopupMenuView | ||
| 206 | + - QMUIKit/QMUIComponents/QMUISearchController | ||
| 207 | + - QMUIKit/QMUIComponents/QMUIStaticTableView | ||
| 208 | + - QMUIKit/QMUIComponents/QMUITableView | ||
| 209 | + - QMUIKit/QMUICore | ||
| 210 | + - QMUIKit/QMUIMainFrame | ||
| 211 | + - QMUIKit/QMUIComponents/QMUILogWithConfigurationSupported (4.2.1): | ||
| 212 | + - QMUIKit/QMUICore | ||
| 213 | + - QMUIKit/QMUIComponents/QMUIMarqueeLabel (4.2.1): | ||
| 214 | + - QMUIKit/QMUICore | ||
| 215 | + - QMUIKit/QMUIComponents/QMUIModalPresentationViewController (4.2.1): | ||
| 216 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 217 | + - QMUIKit/QMUIComponents/QMUIKeyboardManager | ||
| 218 | + - QMUIKit/QMUICore | ||
| 219 | + - QMUIKit/QMUIComponents/QMUIMoreOperationController (4.2.1): | ||
| 220 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 221 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 222 | + - QMUIKit/QMUIComponents/QMUIModalPresentationViewController | ||
| 223 | + - QMUIKit/QMUICore | ||
| 224 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates (4.2.1): | ||
| 225 | + - QMUIKit/QMUICore | ||
| 226 | + - QMUIKit/QMUIComponents/QMUINavigationButton (4.2.1): | ||
| 227 | + - QMUIKit/QMUICore | ||
| 228 | + - QMUIKit/QMUIMainFrame | ||
| 229 | + - QMUIKit/QMUIComponents/QMUINavigationTitleView (4.2.1): | ||
| 230 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 231 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 232 | + - QMUIKit/QMUICore | ||
| 233 | + - QMUIKit/QMUIComponents/QMUIOrderedDictionary (4.2.1): | ||
| 234 | + - QMUIKit/QMUICore | ||
| 235 | + - QMUIKit/QMUIComponents/QMUIPieProgressView (4.2.1): | ||
| 236 | + - QMUIKit/QMUICore | ||
| 237 | + - QMUIKit/QMUIComponents/QMUIPopupContainerView (4.2.1): | ||
| 238 | + - QMUIKit/QMUIComponents/QMUIAppearance | ||
| 239 | + - QMUIKit/QMUICore | ||
| 240 | + - QMUIKit/QMUIMainFrame | ||
| 241 | + - QMUIKit/QMUIComponents/QMUIPopupMenuView (4.2.1): | ||
| 242 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 243 | + - QMUIKit/QMUIComponents/QMUIPopupContainerView | ||
| 244 | + - QMUIKit/QMUICore | ||
| 245 | + - QMUIKit/QMUIComponents/QMUIScrollAnimator (4.2.1): | ||
| 246 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 247 | + - QMUIKit/QMUICore | ||
| 248 | + - QMUIKit/QMUIComponents/QMUISearchBar (4.2.1): | ||
| 249 | + - QMUIKit/QMUICore | ||
| 250 | + - QMUIKit/QMUIComponents/QMUISearchController (4.2.1): | ||
| 251 | + - QMUIKit/QMUIComponents/QMUIEmptyView | ||
| 252 | + - QMUIKit/QMUIComponents/QMUISearchBar | ||
| 253 | + - QMUIKit/QMUICore | ||
| 254 | + - QMUIKit/QMUIMainFrame | ||
| 255 | + - QMUIKit/QMUIComponents/QMUISegmentedControl (4.2.1): | ||
| 256 | + - QMUIKit/QMUICore | ||
| 257 | + - QMUIKit/QMUIComponents/QMUISlider (4.2.1): | ||
| 258 | + - QMUIKit/QMUICore | ||
| 259 | + - QMUIKit/QMUIComponents/QMUIStaticTableView (4.2.1): | ||
| 260 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 261 | + - QMUIKit/QMUIComponents/QMUITableViewCell | ||
| 262 | + - QMUIKit/QMUICore | ||
| 263 | + - QMUIKit/QMUIComponents/QMUITableView (4.2.1): | ||
| 264 | + - QMUIKit/QMUIComponents/QMUITableViewProtocols | ||
| 265 | + - QMUIKit/QMUICore | ||
| 266 | + - QMUIKit/QMUIComponents/QMUITableViewCell (4.2.1): | ||
| 267 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 268 | + - QMUIKit/QMUICore | ||
| 269 | + - QMUIKit/QMUIComponents/QMUITableViewHeaderFooterView (4.2.1): | ||
| 270 | + - QMUIKit/QMUICore | ||
| 271 | + - QMUIKit/QMUIComponents/QMUITableViewProtocols (4.2.1): | ||
| 272 | + - QMUIKit/QMUICore | ||
| 273 | + - QMUIKit/QMUIComponents/QMUITestView (4.2.1): | ||
| 274 | + - QMUIKit/QMUICore | ||
| 275 | + - QMUIKit/QMUIComponents/QMUITextField (4.2.1): | ||
| 276 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 277 | + - QMUIKit/QMUICore | ||
| 278 | + - QMUIKit/QMUIComponents/QMUITextView (4.2.1): | ||
| 279 | + - QMUIKit/QMUIComponents/QMUILabel | ||
| 280 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 281 | + - QMUIKit/QMUICore | ||
| 282 | + - QMUIKit/QMUIComponents/QMUITheme (4.2.1): | ||
| 283 | + - QMUIKit/QMUIComponents/QMUIAlertController | ||
| 284 | + - QMUIKit/QMUIComponents/QMUIBadge | ||
| 285 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 286 | + - QMUIKit/QMUIComponents/QMUIConsole | ||
| 287 | + - QMUIKit/QMUIComponents/QMUIEmotionView | ||
| 288 | + - QMUIKit/QMUIComponents/QMUIEmptyView | ||
| 289 | + - QMUIKit/QMUIComponents/QMUIFillButton | ||
| 290 | + - QMUIKit/QMUIComponents/QMUIGhostButton | ||
| 291 | + - QMUIKit/QMUIComponents/QMUIGridView | ||
| 292 | + - QMUIKit/QMUIComponents/QMUIImagePickerLibrary | ||
| 293 | + - QMUIKit/QMUIComponents/QMUIImagePreviewView | ||
| 294 | + - QMUIKit/QMUIComponents/QMUILabel | ||
| 295 | + - QMUIKit/QMUIComponents/QMUILinkButton | ||
| 296 | + - QMUIKit/QMUIComponents/QMUIModalPresentationViewController | ||
| 297 | + - QMUIKit/QMUIComponents/QMUIPopupContainerView | ||
| 298 | + - QMUIKit/QMUIComponents/QMUIPopupMenuView | ||
| 299 | + - QMUIKit/QMUIComponents/QMUISlider | ||
| 300 | + - QMUIKit/QMUIComponents/QMUITextField | ||
| 301 | + - QMUIKit/QMUIComponents/QMUITextView | ||
| 302 | + - QMUIKit/QMUIComponents/QMUIToastView | ||
| 303 | + - QMUIKit/QMUIComponents/QMUIVisualEffectView | ||
| 304 | + - QMUIKit/QMUICore | ||
| 305 | + - QMUIKit/QMUIComponents/QMUITips (4.2.1): | ||
| 306 | + - QMUIKit/QMUIComponents/QMUIToastView | ||
| 307 | + - QMUIKit/QMUICore | ||
| 308 | + - QMUIKit/QMUIResources | ||
| 309 | + - QMUIKit/QMUIComponents/QMUIToastView (4.2.1): | ||
| 310 | + - QMUIKit/QMUIComponents/QMUIKeyboardManager | ||
| 311 | + - QMUIKit/QMUIComponents/QMUIVisualEffectView | ||
| 312 | + - QMUIKit/QMUICore | ||
| 313 | + - QMUIKit/QMUIComponents/QMUIToolbarButton (4.2.1): | ||
| 314 | + - QMUIKit/QMUICore | ||
| 315 | + - QMUIKit/QMUIComponents/QMUIVisualEffectView (4.2.1): | ||
| 316 | + - QMUIKit/QMUIComponents/QMUICALayerExtension | ||
| 317 | + - QMUIKit/QMUICore | ||
| 318 | + - QMUIKit/QMUIComponents/QMUIWindowSizeMonitor (4.2.1): | ||
| 319 | + - QMUIKit/QMUICore | ||
| 320 | + - QMUIKit/QMUIComponents/QMUIZoomImageView (4.2.1): | ||
| 321 | + - QMUIKit/QMUIComponents/QMUIAssetLibrary | ||
| 322 | + - QMUIKit/QMUIComponents/QMUIButton | ||
| 323 | + - QMUIKit/QMUIComponents/QMUIEmptyView | ||
| 324 | + - QMUIKit/QMUIComponents/QMUIPieProgressView | ||
| 325 | + - QMUIKit/QMUIComponents/QMUISlider | ||
| 326 | + - QMUIKit/QMUICore | ||
| 327 | + - QMUIKit/QMUIResources | ||
| 328 | + - QMUIKit/QMUICore (4.2.1): | ||
| 329 | + - QMUIKit/QMUILog | ||
| 330 | + - QMUIKit/QMUIWeakObjectContainer | ||
| 331 | + - QMUIKit/QMUILog (4.2.1) | ||
| 332 | + - QMUIKit/QMUIMainFrame (4.2.1): | ||
| 333 | + - QMUIKit/QMUIComponents/QMUIEmptyView | ||
| 334 | + - QMUIKit/QMUIComponents/QMUIKeyboardManager | ||
| 335 | + - QMUIKit/QMUIComponents/QMUIMultipleDelegates | ||
| 336 | + - QMUIKit/QMUIComponents/QMUINavigationTitleView | ||
| 337 | + - QMUIKit/QMUIComponents/QMUITableView | ||
| 338 | + - QMUIKit/QMUIComponents/QMUITableViewHeaderFooterView | ||
| 339 | + - QMUIKit/QMUICore | ||
| 340 | + - QMUIKit/QMUILog | ||
| 341 | + - QMUIKit/QMUIResources (4.2.1) | ||
| 342 | + - QMUIKit/QMUIWeakObjectContainer (4.2.1) | ||
| 343 | + - SDWebImage (5.2.3): | ||
| 344 | + - SDWebImage/Core (= 5.2.3) | ||
| 345 | + - SDWebImage/Core (5.2.3) | ||
| 346 | + - SSZipArchive (2.1.5) | ||
| 347 | + - YYCategories (1.0.4): | ||
| 348 | + - YYCategories/no-arc (= 1.0.4) | ||
| 349 | + - YYCategories/no-arc (1.0.4) | ||
| 350 | + - YYImage (1.0.4): | ||
| 351 | + - YYImage/Core (= 1.0.4) | ||
| 352 | + - YYImage/Core (1.0.4) | ||
| 3 | 353 | ||
| 4 | DEPENDENCIES: | 354 | DEPENDENCIES: |
| 5 | - CNLiveBaseTools (from `../`) | 355 | - CNLiveBaseTools (from `../`) |
| 6 | 356 | ||
| 357 | +SPEC REPOS: | ||
| 358 | + http://bj.gitlab.cnlive.com/ios-team/CNLiveRepos.git: | ||
| 359 | + - CNLiveBaseKit | ||
| 360 | + - CNLiveBeeHive | ||
| 361 | + - CNLiveNewTripartiteManagement | ||
| 362 | + https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git: | ||
| 363 | + - MJExtension | ||
| 364 | + - QMUIKit | ||
| 365 | + - SDWebImage | ||
| 366 | + - SSZipArchive | ||
| 367 | + - YYCategories | ||
| 368 | + - YYImage | ||
| 369 | + | ||
| 7 | EXTERNAL SOURCES: | 370 | EXTERNAL SOURCES: |
| 8 | CNLiveBaseTools: | 371 | CNLiveBaseTools: |
| 9 | :path: "../" | 372 | :path: "../" |
| 10 | 373 | ||
| 11 | SPEC CHECKSUMS: | 374 | SPEC CHECKSUMS: |
| 12 | - CNLiveBaseTools: fdaa990ec0d2e0eb8517f1e4e89a4e8e2f39af4f | 375 | + CNLiveBaseKit: 44e5fc573cbca78a86b704cf77c886ef53889807 |
| 376 | + CNLiveBaseTools: 0b0d61d114cc5feceba079a732debb13190b1249 | ||
| 377 | + CNLiveBeeHive: 1e105b15b6ccaad546258fcf91231563beb853d4 | ||
| 378 | + CNLiveNewTripartiteManagement: 29ddb2d23ee77bcd42ba5eaf5f1322ed37db5baa | ||
| 379 | + MJExtension: 635f2c663dcb1bf76fa4b715b2570a5710aec545 | ||
| 380 | + QMUIKit: 15294d6a350466e4a6f4df0333eac5bff474f995 | ||
| 381 | + SDWebImage: 46a7f73228f84ce80990c786e4372cf4db5875ce | ||
| 382 | + SSZipArchive: cefe1364104a0231268a5deb8495bdf2861f52f0 | ||
| 383 | + YYCategories: 6bcd4314c6661a561410dce4a793379ebd306abd | ||
| 384 | + YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54 | ||
| 13 | 385 | ||
| 14 | -PODFILE CHECKSUM: d6face71e3b70b71c5b143a67dd4f471cd45159d | 386 | +PODFILE CHECKSUM: c83e68c17422a4178ce600c26b1d6a3234b90a8c |
| 15 | 387 | ||
| 16 | -COCOAPODS: 1.5.3 | 388 | +COCOAPODS: 1.11.2 |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/BaseModel/BaseModel.h
0 → 100644
| 1 | +// | ||
| 2 | +// BaseModel.h | ||
| 3 | +// ZXBaseProject | ||
| 4 | +// | ||
| 5 | +// Created by 张旭 on 2017/1/10. | ||
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +@interface BaseModel : NSObject | ||
| 12 | + | ||
| 13 | +/** 字典初始化模型 dic -> model */ | ||
| 14 | ++ (id _Nullable)modelWithDic:(NSDictionary <NSString * , id>*_Nullable)dic; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + 子类重写 | ||
| 18 | + */ | ||
| 19 | +- (void)loadModel; // init时调用 | ||
| 20 | +@end |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/BaseModel/BaseModel.m
0 → 100644
| 1 | +// | ||
| 2 | +// BaseModel.m | ||
| 3 | +// ZXBaseProject | ||
| 4 | +// | ||
| 5 | +// Created by 张旭 on 2017/1/10. | ||
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "BaseModel.h" | ||
| 10 | +#import <MJExtension/NSObject+MJKeyValue.h> | ||
| 11 | + | ||
| 12 | +@implementation BaseModel | ||
| 13 | + | ||
| 14 | +/** 字典初始化模型 dic -> models */ | ||
| 15 | ++ (id _Nullable)modelWithDic:(NSDictionary <NSString * , id>*_Nullable)dic | ||
| 16 | +{ | ||
| 17 | + return [[[self alloc] init] mj_setKeyValues:dic]; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +- (instancetype)init | ||
| 21 | +{ | ||
| 22 | + if (self = [super init]) { | ||
| 23 | + [self loadModel]; | ||
| 24 | + } | ||
| 25 | + return self; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +- (void)loadModel {} | ||
| 29 | + | ||
| 30 | +@end |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/IOSDeviceSetting/IOSDeviceConfig.h
0 → 100644
| 1 | +// | ||
| 2 | +// IOSDeviceConfig.h | ||
| 3 | +// CommonLibrary | ||
| 4 | +// | ||
| 5 | +// Created by AlexiChen on 13-1-11. | ||
| 6 | +// Copyright (c) 2013年 AlexiChen. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +@interface IOSDeviceConfig : NSObject | ||
| 12 | + | ||
| 13 | +// 固有属性 | ||
| 14 | +@property (nonatomic, readonly) BOOL isIPad; | ||
| 15 | + | ||
| 16 | +@property (nonatomic, readonly) BOOL isIPhone; | ||
| 17 | + | ||
| 18 | +@property (nonatomic, readonly) BOOL isIPhone4; | ||
| 19 | + | ||
| 20 | +@property (nonatomic, readonly) BOOL isIPhone5; | ||
| 21 | + | ||
| 22 | +@property (nonatomic, readonly) BOOL isIOS7; | ||
| 23 | + | ||
| 24 | +@property (nonatomic, readonly) BOOL isIOS6; | ||
| 25 | + | ||
| 26 | +@property (nonatomic, readonly) BOOL isIOS6Later; | ||
| 27 | + | ||
| 28 | +@property (nonatomic, readonly) BOOL isIOS7Later; | ||
| 29 | + | ||
| 30 | +// 全局设置 | ||
| 31 | +@property (nonatomic, readonly) BOOL isPortrait; | ||
| 32 | + | ||
| 33 | ++ (IOSDeviceConfig *)sharedConfig; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +@end |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/IOSDeviceSetting/IOSDeviceConfig.m
0 → 100644
| 1 | + | ||
| 2 | +// | ||
| 3 | +// IOSDeviceConfig.m | ||
| 4 | +// CommonLibrary | ||
| 5 | +// | ||
| 6 | +// Created by AlexiChen on 13-1-11. | ||
| 7 | +// Copyright (c) 2013年 AlexiChen. All rights reserved. | ||
| 8 | +// | ||
| 9 | + | ||
| 10 | +#import "IOSDeviceConfig.h" | ||
| 11 | +#import "IOSDeviceMacro.h" | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +@implementation IOSDeviceConfig | ||
| 15 | + | ||
| 16 | +static IOSDeviceConfig *_sharedConfig = nil; | ||
| 17 | + | ||
| 18 | + | ||
| 19 | +@synthesize isIPad = _isIPad; | ||
| 20 | +@synthesize isIPhone = _isIPhone; | ||
| 21 | +@synthesize isIPhone4 = _isIPhone4; | ||
| 22 | +@synthesize isIPhone5 = _isIPhone5; | ||
| 23 | +@synthesize isIOS7 = _isIOS7; | ||
| 24 | +@synthesize isIOS6 = _isIOS6; | ||
| 25 | +@synthesize isIOS6Later = _isIOS6Later; | ||
| 26 | + | ||
| 27 | + | ||
| 28 | ++ (IOSDeviceConfig *)sharedConfig | ||
| 29 | +{ | ||
| 30 | + @synchronized(_sharedConfig) | ||
| 31 | + { | ||
| 32 | + if (_sharedConfig == nil) { | ||
| 33 | + _sharedConfig = [[IOSDeviceConfig alloc] init]; | ||
| 34 | + } | ||
| 35 | + return _sharedConfig; | ||
| 36 | + } | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +- (void)dealloc | ||
| 40 | +{ | ||
| 41 | + | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | + | ||
| 45 | +- (id)init | ||
| 46 | +{ | ||
| 47 | + if (self = [super init]) | ||
| 48 | + { | ||
| 49 | + _isIPad = isIPad(); | ||
| 50 | + _isIPhone = isIPhone(); | ||
| 51 | + _isIPhone4 = isIPhone4(); | ||
| 52 | + _isIPhone5 = isIPhone5(); | ||
| 53 | + _isIOS7 = isIOS7(); | ||
| 54 | + _isIOS6 = isIOS6(); | ||
| 55 | + _isIOS6Later = [[UIDevice currentDevice].systemVersion doubleValue]>= 7.0; | ||
| 56 | + _isIOS7Later = [[UIDevice currentDevice].systemVersion doubleValue]>= 8.0; | ||
| 57 | + } | ||
| 58 | + return self; | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +- (BOOL)isPortrait | ||
| 62 | +{ | ||
| 63 | + return UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation); | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | + | ||
| 67 | +@end |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/IOSDeviceSetting/IOSDeviceMacro.h
0 → 100644
| 1 | +// | ||
| 2 | +// IOSDeviceMacro.h | ||
| 3 | +// CommonLibrary | ||
| 4 | +// | ||
| 5 | +// Created by Alexi on 13-10-23. | ||
| 6 | +// Copyright (c) 2013年 ywchen. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#ifndef CommonLibrary_IOSDeviceMacro_h | ||
| 10 | +#define CommonLibrary_IOSDeviceMacro_h | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +#pragma mark - | ||
| 14 | +#pragma mark iOS 4 Version Checkers | ||
| 15 | + | ||
| 16 | +#define isIPad() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | ||
| 17 | +#define isIPhone() (!isIPad()) | ||
| 18 | + | ||
| 19 | +#define isIPhone5() ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) | ||
| 20 | +#define isIPhone4() ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO) | ||
| 21 | + | ||
| 22 | +#define isIOS7() ([[UIDevice currentDevice].systemVersion doubleValue]>= 7.0 && [[UIDevice currentDevice].systemVersion doubleValue] < 8.0) | ||
| 23 | + | ||
| 24 | +#define isIOS6() ([[UIDevice currentDevice].systemVersion doubleValue]>= 6.0 && [[UIDevice currentDevice].systemVersion doubleValue] < 7.0) | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +#endif |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/Utils/CNLiveDefinesHeader.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveDefinesHeader.h | ||
| 3 | +// CNLiveCommonCategory | ||
| 4 | +// | ||
| 5 | +// Created by 张旭 on 2018/9/26. | ||
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#ifndef CNLiveDefinesHeader_h | ||
| 10 | +#define CNLiveDefinesHeader_h | ||
| 11 | +#import <UIKit/UIKit.h> | ||
| 12 | +#import <Foundation/Foundation.h> | ||
| 13 | +#import "ColorHeaders.h" | ||
| 14 | +#import "CNLiveBaseKit.h" | ||
| 15 | + | ||
| 16 | +#pragma mark -- 颜色 | ||
| 17 | +//////////////////////////////////////////////////////// | ||
| 18 | +//////////// Color | ||
| 19 | +//////////////////////////////////////////////////////// | ||
| 20 | +// 默认的字体颜色 | ||
| 21 | +#define kMainTextColor kBlackColor | ||
| 22 | +#define kAppBakgroundColor RGBOF(0xF9F7F8) | ||
| 23 | +// 主色调 | ||
| 24 | +// 导航按钮 | ||
| 25 | +#define kNavBarThemeColor RGB(128, 64, 122) | ||
| 26 | +// loading 文字颜色 | ||
| 27 | +#define kDetailTextColor RGB(145, 145, 145) | ||
| 28 | + | ||
| 29 | +#pragma mark -- 默认常量 高度、宽度、间距 | ||
| 30 | +//////////////////////////////////////////////////////// | ||
| 31 | +//////////// height | ||
| 32 | +//////////////////////////////////////////////////////// | ||
| 33 | +// 默认TableViewCell高度 | ||
| 34 | +#define kDefaultCellHeight 69 | ||
| 35 | +// 默认界面之间的间距 | ||
| 36 | +#define kDefaultMargin 5 | ||
| 37 | + | ||
| 38 | +#define contentLabelFontSize 16 | ||
| 39 | + | ||
| 40 | +#pragma mark -- 设备屏幕/status/safe区域 宽高常量 | ||
| 41 | +//////////////////////////////////////////////////////// | ||
| 42 | +//////////// SCreen | ||
| 43 | +//////////////////////////////////////////////////////// | ||
| 44 | +#define KScreenWidth ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width) | ||
| 45 | +#define KScreenHeight ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.width : [UIScreen mainScreen].bounds.size.height) | ||
| 46 | + | ||
| 47 | +// 判断 iPad | ||
| 48 | +#define DX_UI_IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | ||
| 49 | + | ||
| 50 | +//判断iPHoneXr | 11 分辨率 | ||
| 51 | +#define DX_Is_iPhoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 52 | +//判断iPHoneXr | 11 放大模式分辨率 | ||
| 53 | +#define DX_Is_iPhoneXR_MaxModel ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1624), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 54 | + | ||
| 55 | + | ||
| 56 | +//判断iPhone X,iPHoneXs | 11Pro分辨率 | ||
| 57 | +#define DX_Is_iPhoneXS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 58 | +//判断iPhone X,iPHoneXs | 11Pro 放大模式分辨率 | ||
| 59 | +#define DX_Is_iPhoneXS_MaxModel ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize( CGSizeMake(960, 2079), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 60 | + | ||
| 61 | + | ||
| 62 | +//判断iPhoneXs Max | 11ProMax分辨率 | ||
| 63 | +#define DX_Is_iPhoneXS_MAX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 64 | +//判断iPhoneXs Max | 11ProMax 放大模式分辨率 | ||
| 65 | +#define DX_Is_iPhoneXS_MAX_MaxModel ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 66 | + | ||
| 67 | + | ||
| 68 | +//判断iPhone12_Mini | ||
| 69 | +#define DX_Is_iPhone12_Mini ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1080, 2340), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 70 | +//判断iPhone12_Mini 放大模式分辨率 | ||
| 71 | +#define DX_Is_iPhone12_Mini_MaxModel ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(960, 2079), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 72 | + | ||
| 73 | + | ||
| 74 | +//判断iPhone12 | 12Pro 分辨率 | ||
| 75 | +#define DX_Is_iPhone12 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1170, 2532), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 76 | +//判断iPhone12 | 12Pro 放大模式分辨率 | ||
| 77 | +#define DX_Is_iPhone12_MaxModel ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(960, 2079), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 78 | + | ||
| 79 | + | ||
| 80 | +//判断iPhone12 Pro Max分辨率 | ||
| 81 | +#define DX_Is_iPhone12_ProMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1284, 2778), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 82 | +//判断iPhone12 Pro Max 放大模式分辨率 | ||
| 83 | +#define DX_Is_iPhone12_ProMax_MaxModel ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !DX_UI_IS_IPAD : NO) | ||
| 84 | + | ||
| 85 | +//x系列 | ||
| 86 | +#define IS_IPhoneX_All (DX_Is_iPhoneXR || DX_Is_iPhoneXS || DX_Is_iPhoneXS_MAX || DX_Is_iPhone12_Mini || DX_Is_iPhone12 || DX_Is_iPhone12_ProMax || DX_Is_iPhoneXR_MaxModel || DX_Is_iPhoneXS_MaxModel || DX_Is_iPhoneXS_MAX_MaxModel || DX_Is_iPhone12_Mini_MaxModel || DX_Is_iPhone12_MaxModel || DX_Is_iPhone12_ProMax_MaxModel) | ||
| 87 | + | ||
| 88 | +#define kStatusHeight (int)[UIApplication sharedApplication].statusBarFrame.size.height //x44 非x20 | ||
| 89 | +#define kNavigationBarHeight ((int)[UIApplication sharedApplication].statusBarFrame.size.height+44) //x88 非x64 | ||
| 90 | +#define kVerticalNaviBarHeight 44 | ||
| 91 | +#define kVerticalTabBarTotalHeight ((IS_IPhoneX_All > 0) ? 83 : 49) | ||
| 92 | +#define kVerticalBottomSafeHeight ((IS_IPhoneX_All > 0) ? 34 : 0) | ||
| 93 | +#define kVerticalStatusHeight ((IS_IPhoneX_All > 0) ? 44 : 20) | ||
| 94 | +#define KVerticalTopPlayerHeight ((IS_IPhoneX_All > 0) ? 44 : 0) | ||
| 95 | +#define kVerticalTopHeight ((IS_IPhoneX_All > 0) ? 24 : 0) | ||
| 96 | +#define kHorizontalTopNaviBarHeight 32 | ||
| 97 | +#define kHorizontalBottomHeight ((IS_IPhoneX_All > 0) ? 21 : 0) | ||
| 98 | +#define kHorizontalLeftHeight ((IS_IPhoneX_All > 0) ? 44 : 0) | ||
| 99 | +#define kHorizontalRightHeight ((IS_IPhoneX_All > 0) ? 44 : 0) | ||
| 100 | +#define kHorizontalTopHeight ((IS_IPhoneX_All > 0) ? 24 : 0) | ||
| 101 | + | ||
| 102 | +#pragma mark -- 弱/强 引用 | ||
| 103 | +//////////////////////////////////////////////////////// | ||
| 104 | +//////////// WeakSelf&StrongSelf | ||
| 105 | +//////////////////////////////////////////////////////// | ||
| 106 | +/** | ||
| 107 | + * weakSelf | ||
| 108 | + */ | ||
| 109 | +#ifndef weakself | ||
| 110 | +#define weakself __weak typeof(self)weakSelf = self; | ||
| 111 | +#endif | ||
| 112 | +/** | ||
| 113 | + * strongSelf | ||
| 114 | + */ | ||
| 115 | +#ifndef strongself | ||
| 116 | +#define strongself __strong typeof(weakSelf)self = weakSelf; | ||
| 117 | +#endif | ||
| 118 | + | ||
| 119 | +#pragma mark -- 输出测试 | ||
| 120 | +//////////////////////////////////////////////////////// | ||
| 121 | +//////////// 输出测试 | ||
| 122 | +//////////////////////////////////////////////////////// | ||
| 123 | +#ifdef DEBUG | ||
| 124 | +#define NSLog(s, ... ) NSLog( @"[%@ in line %d] ===============>%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] ) | ||
| 125 | +#else | ||
| 126 | +#define NSLog(s, ... ) | ||
| 127 | +#endif | ||
| 128 | + | ||
| 129 | +//////// | ||
| 130 | +#ifdef DEBUG | ||
| 131 | + | ||
| 132 | +#ifndef DebugLog | ||
| 133 | +#define DebugLog(fmt, ...) NSLog((@"[%s Line %d] \n" fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) | ||
| 134 | +#endif | ||
| 135 | + | ||
| 136 | +#else | ||
| 137 | + | ||
| 138 | +#ifndef DebugLog | ||
| 139 | +#define DebugLog(fmt, ...) | ||
| 140 | +#endif | ||
| 141 | + | ||
| 142 | +#endif | ||
| 143 | + | ||
| 144 | +#pragma mark -- 字体 | ||
| 145 | +//////////////////////////////////////////////////////// | ||
| 146 | +//////////// Font | ||
| 147 | +//////////////////////////////////////////////////////// | ||
| 148 | +// CommonLibrary中常用的字体 | ||
| 149 | +#define kCommonLargeTextFont [UIFont systemFontOfSize:16] | ||
| 150 | +#define kCommonMiddleTextFont [UIFont systemFontOfSize:14] | ||
| 151 | +#define kCommonSmallTextFont [UIFont systemFontOfSize:12] | ||
| 152 | + | ||
| 153 | +//////////////////////////////////////////////////////// | ||
| 154 | +//////////// 动态跟随系统设置的字体大小改变字体和行高 | ||
| 155 | +//////////////////////////////////////////////////////// | ||
| 156 | +#define UIFontCNMake(size) [UIFont CNFontOfSize:size] //根据APP设置的字体大小显示 | ||
| 157 | +#define UIFontBoldCNMake(size) [UIFont CNBoldFontOfSize:size] //根据APP设置的粗体字体大小显示 | ||
| 158 | + | ||
| 159 | +#define RATIO [CNFontAndRatioTool getScaleCoefficient] | ||
| 160 | + | ||
| 161 | +#pragma mark -- AppDelegate/window | ||
| 162 | +//////////////////////////////////////////////////////// | ||
| 163 | +//////////// AppDelegate | ||
| 164 | +//////////////////////////////////////////////////////// | ||
| 165 | +#ifndef AppKeyWindow | ||
| 166 | +#define AppKeyWindow ([UIApplication sharedApplication].delegate).window | ||
| 167 | +#endif | ||
| 168 | + | ||
| 169 | +#ifndef CNAppDelegate | ||
| 170 | +#define CNAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate) | ||
| 171 | +#endif | ||
| 172 | + | ||
| 173 | +#pragma mark -- 通知 | ||
| 174 | +//////////////////////////////////////////////////////// | ||
| 175 | +//////////// NSNotificationCenter | ||
| 176 | +//////////////////////////////////////////////////////// | ||
| 177 | +#define CNNotificationCenter [NSNotificationCenter defaultCenter] | ||
| 178 | + | ||
| 179 | +#pragma mark -- 单例 | ||
| 180 | +#define SINGLETON_FOR_HEADER(className) \ | ||
| 181 | +\ | ||
| 182 | ++ (className *)shared##className; | ||
| 183 | + | ||
| 184 | +#define SINGLETON_FOR_CLASS(className) \ | ||
| 185 | +\ | ||
| 186 | ++ (className *)shared##className { \ | ||
| 187 | +static className *shared##className = nil; \ | ||
| 188 | +static dispatch_once_t onceToken; \ | ||
| 189 | +dispatch_once(&onceToken, ^{ \ | ||
| 190 | +shared##className = [[self alloc] init]; \ | ||
| 191 | +}); \ | ||
| 192 | +return shared##className; \ | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +#pragma mark -- 获取版本号 | ||
| 196 | +#define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] | ||
| 197 | + | ||
| 198 | + | ||
| 199 | +#endif /* CNLiveDefinesHeader_h */ |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/Utils/Categorys/NSString+AES.h
0 → 100644
| 1 | +// | ||
| 2 | +// NSString+AES.h | ||
| 3 | +// | ||
| 4 | +// | ||
| 5 | +// Created by Bear on 16/11/26. | ||
| 6 | +// Copyright © 2016年 Bear. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +@interface NSString (AES) | ||
| 12 | + | ||
| 13 | +/**< 加密方法 */ | ||
| 14 | +- (NSString*)aci_encryptWithAES; | ||
| 15 | + | ||
| 16 | +/**< 解密方法 */ | ||
| 17 | +- (NSString*)aci_decryptWithAES; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +/**< 加密方法 */ | ||
| 21 | +- (NSString*)aci_encryptWithAESWithKey:(NSString *)key; | ||
| 22 | + | ||
| 23 | +/**< 解密方法 */ | ||
| 24 | +- (NSString*)aci_decryptWithAESWithKey:(NSString *)key; | ||
| 25 | +@end |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/Utils/Categorys/NSString+AES.m
0 → 100644
| 1 | +// | ||
| 2 | +// NSString+AES.m | ||
| 3 | +// | ||
| 4 | +// | ||
| 5 | +// Created by Bear on 16/11/26. | ||
| 6 | +// Copyright © 2016年 Bear . All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "NSString+AES.h" | ||
| 10 | +#import <CommonCrypto/CommonDigest.h> | ||
| 11 | +#import <CommonCrypto/CommonCryptor.h> | ||
| 12 | +#import "GTMBase64.h" | ||
| 13 | + | ||
| 14 | +static NSString *const PSW_AES_KEY = @"gndtd3b785q40bgm";//@"TESTPASSWORD"; | ||
| 15 | +static NSString *const AES_IV_PARAMETER = @"";//AES00IVPARAMETER | ||
| 16 | + | ||
| 17 | +@implementation NSString (AES) | ||
| 18 | + | ||
| 19 | +/**< 加密方法 */ | ||
| 20 | +- (NSString*)aci_encryptWithAESWithKey:(NSString *)key | ||
| 21 | +{ | ||
| 22 | + NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; | ||
| 23 | + NSData *AESData = [self AES128operation:kCCEncrypt | ||
| 24 | + data:data | ||
| 25 | + key:key | ||
| 26 | + iv:AES_IV_PARAMETER]; | ||
| 27 | + NSString *baseStr_GTM = [self encodeBase64Data:AESData]; | ||
| 28 | + NSString *baseStr = [AESData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; | ||
| 29 | + | ||
| 30 | + NSLog(@"*****************\nGTMBase:%@\n*****************", baseStr_GTM); | ||
| 31 | + NSLog(@"*****************\niOSCode:%@\n*****************", baseStr); | ||
| 32 | + return baseStr_GTM; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +/**< 解密方法 */ | ||
| 36 | +- (NSString*)aci_decryptWithAESWithKey:(NSString *)key | ||
| 37 | +{ | ||
| 38 | + NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; | ||
| 39 | + NSData *baseData_GTM = [self decodeBase64Data:data]; | ||
| 40 | + NSData *baseData = [[NSData alloc]initWithBase64EncodedString:self options:0]; | ||
| 41 | + | ||
| 42 | + NSData *AESData_GTM = [self AES128operation:kCCDecrypt | ||
| 43 | + data:baseData_GTM | ||
| 44 | + key:key | ||
| 45 | + iv:AES_IV_PARAMETER]; | ||
| 46 | + NSData *AESData = [self AES128operation:kCCDecrypt | ||
| 47 | + data:baseData | ||
| 48 | + key:key | ||
| 49 | + iv:AES_IV_PARAMETER]; | ||
| 50 | + | ||
| 51 | + NSString *decStr_GTM = [[NSString alloc] initWithData:AESData_GTM encoding:NSUTF8StringEncoding]; | ||
| 52 | + NSString *decStr = [[NSString alloc] initWithData:AESData encoding:NSUTF8StringEncoding]; | ||
| 53 | + | ||
| 54 | + NSLog(@"*****************\nGTMBase:%@\n*****************", decStr_GTM); | ||
| 55 | + NSLog(@"*****************\niOSCode:%@\n*****************", decStr); | ||
| 56 | + | ||
| 57 | + return decStr; | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | + | ||
| 61 | +- (NSString*)aci_encryptWithAES { | ||
| 62 | + | ||
| 63 | + NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; | ||
| 64 | + NSData *AESData = [self AES128operation:kCCEncrypt | ||
| 65 | + data:data | ||
| 66 | + key:PSW_AES_KEY | ||
| 67 | + iv:AES_IV_PARAMETER]; | ||
| 68 | + NSString *baseStr_GTM = [self encodeBase64Data:AESData]; | ||
| 69 | + NSString *baseStr = [AESData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; | ||
| 70 | + | ||
| 71 | + NSLog(@"*****************\nGTMBase:%@\n*****************", baseStr_GTM); | ||
| 72 | + NSLog(@"*****************\niOSCode:%@\n*****************", baseStr); | ||
| 73 | + return baseStr_GTM; | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +- (NSString*)aci_decryptWithAES { | ||
| 77 | + | ||
| 78 | + NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; | ||
| 79 | + NSData *baseData_GTM = [self decodeBase64Data:data]; | ||
| 80 | + NSData *baseData = [[NSData alloc]initWithBase64EncodedString:self options:0]; | ||
| 81 | + | ||
| 82 | + NSData *AESData_GTM = [self AES128operation:kCCDecrypt | ||
| 83 | + data:baseData_GTM | ||
| 84 | + key:PSW_AES_KEY | ||
| 85 | + iv:AES_IV_PARAMETER]; | ||
| 86 | + NSData *AESData = [self AES128operation:kCCDecrypt | ||
| 87 | + data:baseData | ||
| 88 | + key:PSW_AES_KEY | ||
| 89 | + iv:AES_IV_PARAMETER]; | ||
| 90 | + | ||
| 91 | + NSString *decStr_GTM = [[NSString alloc] initWithData:AESData_GTM encoding:NSUTF8StringEncoding]; | ||
| 92 | + NSString *decStr = [[NSString alloc] initWithData:AESData encoding:NSUTF8StringEncoding]; | ||
| 93 | + | ||
| 94 | + NSLog(@"*****************\nGTMBase:%@\n*****************", decStr_GTM); | ||
| 95 | + NSLog(@"*****************\niOSCode:%@\n*****************", decStr); | ||
| 96 | + | ||
| 97 | + return decStr; | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +/** | ||
| 101 | + * AES加解密算法 | ||
| 102 | + * | ||
| 103 | + * @param operation kCCEncrypt(加密)kCCDecrypt(解密) | ||
| 104 | + * @param data 待操作Data数据 | ||
| 105 | + * @param key key | ||
| 106 | + * @param iv 向量 | ||
| 107 | + * | ||
| 108 | + * @return | ||
| 109 | + */ | ||
| 110 | +- (NSData *)AES128operation:(CCOperation)operation data:(NSData *)data key:(NSString *)key iv:(NSString *)iv { | ||
| 111 | + char keyPtr[kCCKeySizeAES128 + 1]; | ||
| 112 | + bzero(keyPtr, sizeof(keyPtr)); | ||
| 113 | + [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; | ||
| 114 | + | ||
| 115 | + // IV | ||
| 116 | + char ivPtr[kCCBlockSizeAES128 + 1]; | ||
| 117 | + bzero(ivPtr, sizeof(ivPtr)); | ||
| 118 | + [iv getCString:ivPtr maxLength:sizeof(ivPtr) encoding:NSUTF8StringEncoding]; | ||
| 119 | + | ||
| 120 | + size_t bufferSize = [data length] + kCCBlockSizeAES128; | ||
| 121 | + void *buffer = malloc(bufferSize); | ||
| 122 | + size_t numBytesEncrypted = 0; | ||
| 123 | + | ||
| 124 | + CCCryptorStatus cryptorStatus = CCCrypt(operation, kCCAlgorithmAES128, kCCOptionPKCS7Padding |kCCOptionECBMode, | ||
| 125 | + keyPtr, kCCKeySizeAES128, | ||
| 126 | + ivPtr, | ||
| 127 | + [data bytes], [data length], | ||
| 128 | + buffer, bufferSize, | ||
| 129 | + &numBytesEncrypted); | ||
| 130 | + | ||
| 131 | + if(cryptorStatus == kCCSuccess) { | ||
| 132 | + NSLog(@"Success"); | ||
| 133 | + return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted]; | ||
| 134 | + | ||
| 135 | + } else { | ||
| 136 | + NSLog(@"Error"); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + free(buffer); | ||
| 140 | + return nil; | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +/**< GTMBase64编码 */ | ||
| 144 | +- (NSString*)encodeBase64Data:(NSData *)data { | ||
| 145 | + data = [GTMBase64 encodeData:data]; | ||
| 146 | + NSString *base64String = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | ||
| 147 | + return base64String; | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +/**< GTMBase64解码 */ | ||
| 151 | +- (NSData*)decodeBase64Data:(NSData *)data { | ||
| 152 | + data = [GTMBase64 decodeData:data]; | ||
| 153 | + return data; | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +@end |
Example/Pods/CNLiveBaseKit/CNLiveBaseKit/Classes/ARC/Utils/Categorys/NSString+CNLiveExtension.h
0 → 100644
| 1 | +// | ||
| 2 | +// NSString+CNLiveExtension.h | ||
| 3 | +// CNLiveCommonCategory | ||
| 4 | +// | ||
| 5 | +// Created by 张旭 on 2018/9/26. | ||
| 6 | +// Copyright © 2018年 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <Foundation/Foundation.h> | ||
| 10 | + | ||
| 11 | +///判断是否为空字符串 | ||
| 12 | +#ifndef CNLiveStringIsEmpty | ||
| 13 | +#define CNLiveStringIsEmpty(string) [NSString isEmpty:string] | ||
| 14 | +#endif | ||
| 15 | + | ||
| 16 | +///判断是否为空字符串当去除换行和空格后 | ||
| 17 | +#ifndef CNLiveStringTrimedIsEmpty | ||
| 18 | +#define CNLiveStringTrimedIsEmpty(string) [NSString isEmptyByTrimStr:string] | ||
| 19 | +#endif | ||
| 20 | + | ||
| 21 | +///把格式化的JSON格式的字符串转换成字典 | ||
| 22 | +#ifndef CNLiveStringJsonToDictionary | ||
| 23 | +#define CNLiveStringJsonToDictionary(jsonStr) [NSString jsonToDictionaryWithJson:jsonStr] | ||
| 24 | +#endif | ||
| 25 | + | ||
| 26 | +@interface NSString (CNLiveExtension) | ||
| 27 | + | ||
| 28 | +#pragma mark -- 去除空处理 | ||
| 29 | +///判断是否为空字符串 | ||
| 30 | ++ (BOOL)isEmpty:(NSString *)string; | ||
| 31 | +///判断是否为空字符串当去除换行和空格后 | ||
| 32 | ++ (BOOL)isEmptyByTrimStr:(NSString *)string; | ||
| 33 | + | ||
| 34 | +///把格式化的JSON格式的字符串转换成字典 | ||
| 35 | ++ (NSDictionary *)jsonToDictionaryWithJson:(NSString *)jsonStr; | ||
| 36 | + | ||
| 37 | +/** 去除字符串前后的空白,不包含换行符 */ | ||
| 38 | +- (NSString *)trim; | ||
| 39 | + | ||
| 40 | +/** 当前字符串是否只包含空白字符和换行符 */ | ||
| 41 | +- (BOOL)isWhitespaceAndNewlines; | ||
| 42 | + | ||
| 43 | +/** 去除字符串中所有空白 */ | ||
| 44 | +- (NSString *)removeWhiteSpace; | ||
| 45 | + | ||
| 46 | +/** 去除字符串中所有换行 */ | ||
| 47 | +- (NSString *)removeNewLine; | ||
| 48 | +#pragma mark -- | ||
| 49 | + | ||
| 50 | +#pragma mark --字符串格式化 | ||
| 51 | +/** 将字符串以URL格式编码 */ | ||
| 52 | +- (NSString *)stringByUrlEncoding; | ||
| 53 | + | ||
| 54 | +/*! | ||
| 55 | + @brief 大写第一个字符 | ||
| 56 | + @return 格式化后的字符串 | ||
| 57 | + */ | ||
| 58 | +- (NSString *)capitalize; | ||
| 59 | +#pragma mark -- 字符串首字母 | ||
| 60 | +/** 字符串首字母 */ | ||
| 61 | +-(NSString*)firstPinYin; | ||
| 62 | +#pragma mark -- | ||
| 63 | + | ||
| 64 | +#pragma mark -- 字符串截取 | ||
| 65 | +/** 以给定字符串开始,忽略大小写 */ | ||
| 66 | +- (BOOL)startsWith:(NSString *)str; | ||
| 67 | + | ||
| 68 | +/** 以指定条件判断字符串是否以给定字符串开始 */ | ||
| 69 | +- (BOOL)startsWith:(NSString *)str Options:(NSStringCompareOptions)compareOptions; | ||
| 70 | + | ||
| 71 | +/** 以给定字符串结束,忽略大小写 */ | ||
| 72 | +- (BOOL)endsWith:(NSString *)str; | ||
| 73 | + | ||
| 74 | +/** 以指定条件判断字符串是否以给定字符串结尾 */ | ||
| 75 | +- (BOOL)endsWith:(NSString *)str Options:(NSStringCompareOptions)compareOptions; | ||
| 76 | + | ||
| 77 | +/** 包含给定的字符串, 忽略大小写 */ | ||
| 78 | +- (BOOL)containsString:(NSString *)str; | ||
| 79 | +- (BOOL)cn_containsString:(NSString *)str; | ||
| 80 | + | ||
| 81 | +/** 以指定条件判断是否包含给定的字符串 */ | ||
| 82 | +- (BOOL)containsString:(NSString *)str Options:(NSStringCompareOptions)compareOptions; | ||
| 83 | + | ||
| 84 | +/** 判断字符串是否相同,忽略大小写 */ | ||
| 85 | +- (BOOL)equalsString:(NSString *)str; | ||
| 86 | +#pragma mark -- | ||
| 87 | + | ||
| 88 | +#pragma mark -- emoji | ||
| 89 | +/** 对emoji encode处理 */ | ||
| 90 | +- (NSString *)emjoiText; | ||
| 91 | + | ||
| 92 | +/** 是否包含Emoji表情 */ | ||
| 93 | +- (BOOL)isContainsEmoji; | ||
| 94 | ++ (BOOL)hasEmoji:(NSString*)string; | ||
| 95 | + | ||
| 96 | +/** 去除Emoji表情 */ | ||
| 97 | ++ (NSString *)disable_emoji:(NSString *)text; | ||
| 98 | + | ||
| 99 | +#pragma mark -- 计算一段文字的高度 | ||
| 100 | +/** 计算一段文字的高度*/ | ||
| 101 | +- (CGSize)textSizeIn:(CGSize)size font:(UIFont *)font; | ||
| 102 | +- (CGSize)textSizeIn:(CGSize)size font:(UIFont *)font breakMode:(NSLineBreakMode)breakMode; | ||
| 103 | +- (CGSize)textSizeIn:(CGSize)size font:(UIFont *)font breakMode:(NSLineBreakMode)breakMode align:(NSTextAlignment)alignment; | ||
| 104 | + | ||
| 105 | +#pragma mark -- 字符串utf8后长度 | ||
| 106 | +/** 字符串utf8后长度 */ | ||
| 107 | +- (NSUInteger)utf8Length; | ||
| 108 | + | ||
| 109 | +/** 递归计算符合规定的文本长度 */ | ||
| 110 | +- (NSString *)cutBeyondTextInLength:(NSInteger)maxLenth; | ||
| 111 | +#pragma mark -- 是不是 url | ||
| 112 | +/** 是不是 url */ | ||
| 113 | +- (BOOL)isValidUrl; | ||
| 114 | +#pragma mark -- 截取字符串 | ||
| 115 | +/** 截取字符串 */ | ||
| 116 | +- (NSString *)substringAtRange:(NSRange)rang; | ||
| 117 | +#pragma mark -- 比较两个版本是否一样 | ||
| 118 | +/** | ||
| 119 | + compare two version 比较两个版本是否一样 | ||
| 120 | + @param sourVersion *.*.*.* | ||
| 121 | + @param desVersion *.*.*.* | ||
| 122 | + @returns No,sourVersion is less than desVersion; YES, the statue is opposed | ||
| 123 | + */ | ||
| 124 | ++(BOOL)compareVerison:(NSString *)sourVersion withDes:(NSString *)desVersion; | ||
| 125 | +#pragma mark -- 解析html标签对应的值 | ||
| 126 | +/** 解析html标签对应的值 */ | ||
| 127 | +- (NSString *)valueOfLabel:(NSString *)label; | ||
| 128 | + | ||
| 129 | +//+ (BOOL)isMobileNumber:(NSString *)mobileNum; | ||
| 130 | +////正则 手机号码 | ||
| 131 | +//+ (BOOL)validateCellPhoneNumber:(NSString *)cellNum; | ||
| 132 | +/// 将str加密成本地保存的文件名 | ||
| 133 | ++ (NSString *)md5String:(NSString *)str; | ||
| 134 | +- (NSString *)md5; | ||
| 135 | +///是否包含特殊字符 | ||
| 136 | ++ (BOOL)judgeTheillegalCharacter:(NSString *)content; | ||
| 137 | +///对字符串进行encode | ||
| 138 | ++ (NSString *)encodeToPercentEscapeString:(NSString *)input; | ||
| 139 | +///base64Encoding | ||
| 140 | +- (NSString *)base64Encoding; | ||
| 141 | +///字符串空处理 | ||
| 142 | ++(NSString*)convertNull:(id)object; | ||
| 143 | +//过滤未知字符 | ||
| 144 | ++ (NSString *)filterUnknownChara:(NSString *)text; | ||
| 145 | +/** | ||
| 146 | + 判断是不是九宫格 | ||
| 147 | + @param string 输入的字符 | ||
| 148 | + @return YES(是九宫格拼音键盘) | ||
| 149 | + */ | ||
| 150 | ++ (BOOL)isNineKeyBoard:(NSString *)string; | ||
| 151 | +/** | ||
| 152 | + * 截取URL中的参数 | ||
| 153 | + * | ||
| 154 | + * @return NSMutableDictionary parameters | ||
| 155 | + */ | ||
| 156 | ++ (NSMutableDictionary *)getURLParameters:(NSString *)urlStr; | ||
| 157 | + | ||
| 158 | +@end |