Skip to content

Commit ac5ac9f

Browse files
committed
v3.7.0 - 1.增加几种清除缓存的接口,2.增加几种倒计时按钮类型,3.已知问题优化与修复...
1 parent 626ace1 commit ac5ac9f

File tree

12 files changed

+383
-126
lines changed

12 files changed

+383
-126
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
### 更新记录:
3131

32+
* 2017.10.09 -- v3.7.0 -->1.增加几种清除缓存的接口,2.增加几种倒计时按钮类型,3.已知问题优化与修复...
3233
* 2017.09.29 -- v3.6.1 -->1.增加清除指定图片/视频缓存接口,2.优化在iPhoneX上显示效果,3.已知问题优化与修复...
3334
* 2017.09.18 -- v3.6.0 -->1.优化图片解码方案,2.支持设置GIF动图是否循环播放...
3435
* 2017.09.13 -- v3.5.8 -->增加几种显示完成的动画...

XHLaunchAd.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "XHLaunchAd"
3-
s.version = "3.6.1"
3+
s.version = "3.7.0"
44
s.summary = "The screen opening advertising solutions -开屏广告、启动广告解决方案,支持图片/视频、静态/动态、全屏/半屏广告,支持iPhone/iPad,自带图片下载、缓存功能"
55
s.homepage = "https://github.com/CoderZhuXH/XHLaunchAd"
66
s.license = { :type => "MIT", :file => "LICENSE" }

XHLaunchAd/XHLaunchAd/XHLaunchAd.h

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright © 2016年 it7090.com. All rights reserved.
77
// 代码地址:https://github.com/CoderZhuXH/XHLaunchAd
88

9-
// 版本:3.6.1
10-
// 发布:2017.09.29
9+
// 版本:3.7.0
10+
// 发布:2017.10.09
1111

1212
// 如果你在使用过程中出现bug,请及时以下面任意一种方式联系我,我会及时修复bug并帮您解决问题。
1313
// QQ交流群:537476189
@@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
101101
@property(nonatomic,assign) id<XHLaunchAdDelegate> delegate;
102102

103103
/**
104-
* 设置等待数据源时间(default 3)
104+
* 设置等待数据源时间(建议值:3)
105105
*
106106
* @param waitDataDuration waitDataDuration
107107
*/
@@ -146,14 +146,14 @@ NS_ASSUME_NONNULL_BEGIN
146146

147147
#pragma mark - 如果你需要提前下载并缓存广告图片或视频 请调用下面方法
148148
/**
149-
* 批量下载并缓存image(异步)
149+
* 批量下载并缓存image(异步) - 已缓存的image不会再次下载缓存
150150
*
151151
* @param urlArray image URL Array
152152
*/
153153
+(void)downLoadImageAndCacheWithURLArray:(NSArray <NSURL *> * )urlArray;
154154

155155
/**
156-
* 批量下载并缓存视频(异步)
156+
* 批量下载并缓存视频(异步) - 已缓存的视频不会再次下载缓存
157157
*
158158
* @param urlArray 视频URL Array
159159
*/
@@ -199,26 +199,40 @@ NS_ASSUME_NONNULL_BEGIN
199199
*/
200200
+(NSString *)cacheVideoURLString;
201201

202-
#pragma mark - 缓存清除及大小
202+
#pragma mark - 缓存相关
203203
/**
204-
* 清除XHLaunch本地缓存
204+
* 清除XHLaunchAd本地所有缓存(异步)
205205
*/
206206
+(void)clearDiskCache;
207207

208208
/**
209-
清除指定Url的图片本地缓存
209+
清除指定Url的图片本地缓存(异步)
210210
211-
@param imageUrlArray 图片Url数组
211+
@param imageUrlArray 需要清除缓存的图片Url数组
212212
*/
213213
+(void)clearDiskCacheWithImageUrlArray:(NSArray<NSURL *> *)imageUrlArray;
214214

215215
/**
216-
清除指定Url的视频本地缓存
216+
清除指定Url除外的图片本地缓存(异步)
217+
218+
@param exceptImageUrlArray 不需要清除缓存的图片Url数组,此url数组的图片缓存将被保留
219+
*/
220+
+(void)clearDiskCacheExceptImageUrlArray:(NSArray<NSURL *> *)exceptImageUrlArray;
221+
222+
/**
223+
清除指定Url的视频本地缓存(异步)
217224
218-
@param videoUrlArray 视频url数组
225+
@param videoUrlArray 需要清除缓存的视频url数组
219226
*/
220227
+(void)clearDiskCacheWithVideoUrlArray:(NSArray<NSURL *> *)videoUrlArray;
221228

229+
/**
230+
清除指定Url除外的视频本地缓存(异步)
231+
232+
@param exceptVideoUrlArray 不需要清除缓存的视频Url数组,此url数组的视频缓存将被保留
233+
*/
234+
+(void)clearDiskCacheExceptVideoUrlArray:(NSArray<NSURL *> *)exceptVideoUrlArray;
235+
222236
/**
223237
* 获取XHLaunch本地缓存大小(M)
224238
*/

XHLaunchAd/XHLaunchAd/XHLaunchAd.m

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface XHLaunchAd()
2929
@property(nonatomic,assign)NSInteger waitDataDuration;
3030
@property(nonatomic,strong)XHLaunchImageAdConfiguration * imageAdConfiguration;
3131
@property(nonatomic,strong)XHLaunchVideoAdConfiguration * videoAdConfiguration;
32-
@property(nonatomic,strong)XHLaunchAdButton * adSkipButton;
32+
@property(nonatomic,strong)XHLaunchAdButton * skipButton;
3333
@property(nonatomic,strong)XHLaunchAdVideoView * adVideoView;
3434
@property(nonatomic,strong)UIWindow * window;
3535
@property(nonatomic,copy)dispatch_source_t waitDataTimer;
@@ -103,11 +103,21 @@ +(void)clearDiskCacheWithImageUrlArray:(NSArray<NSURL *> *)imageUrlArray
103103
[XHLaunchAdCache clearDiskCacheWithImageUrlArray:imageUrlArray];
104104
}
105105

106+
+(void)clearDiskCacheExceptImageUrlArray:(NSArray<NSURL *> *)exceptImageUrlArray
107+
{
108+
[XHLaunchAdCache clearDiskCacheExceptImageUrlArray:exceptImageUrlArray];
109+
}
110+
106111
+(void)clearDiskCacheWithVideoUrlArray:(NSArray<NSURL *> *)videoUrlArray
107112
{
108113
[XHLaunchAdCache clearDiskCacheWithVideoUrlArray:videoUrlArray];
109114
}
110115

116+
+(void)clearDiskCacheExceptVideoUrlArray:(NSArray<NSURL *> *)exceptVideoUrlArray
117+
{
118+
[XHLaunchAdCache clearDiskCacheExceptVideoUrlArray:exceptVideoUrlArray];
119+
}
120+
111121
+(float)diskCacheSize
112122
{
113123
return [XHLaunchAdCache diskCacheSize];
@@ -158,7 +168,7 @@ - (instancetype)init
158168
}];
159169

160170
[[NSNotificationCenter defaultCenter] addObserverForName:XHLaunchAdDetailPageShowFinishNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
161-
171+
162172
_detailPageShowing = NO;
163173

164174
}];
@@ -279,11 +289,11 @@ -(void)setupImageAdForConfiguration:(XHLaunchImageAdConfiguration *)configuratio
279289

280290
}
281291

282-
[self startSkipDispathTimer];
283-
284292
/** skipButton */
285293
[self addSkipButtonForConfiguration:configuration];
286294

295+
[self startSkipDispathTimer];
296+
287297
/** customView */
288298
if(configuration.subViews.count>0) [self addSubViews:configuration.subViews];
289299

@@ -305,19 +315,16 @@ -(void)addSkipButtonForConfiguration:(XHLaunchAdConfiguration *)configuration
305315

306316
}else{
307317

308-
if(_adSkipButton == nil){
309-
310-
CGFloat y = XH_IPHONEX ? 44 : 20;
311-
_adSkipButton = [[XHLaunchAdButton alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width-80,y, 70, 35)];
312-
_adSkipButton.hidden = YES;
313-
[_adSkipButton addTarget:self action:@selector(adSkipButtonClick) forControlEvents:UIControlEventTouchUpInside];
314-
_adSkipButton.leftRightSpace = 5;
315-
_adSkipButton.topBottomSpace = 2.5;
318+
if(_skipButton == nil){
316319

320+
_skipButton = [[XHLaunchAdButton alloc] initWithSkipType:configuration.skipButtonType];
321+
_skipButton.hidden = YES;
322+
[_skipButton addTarget:self action:@selector(adSkipButtonClick) forControlEvents:UIControlEventTouchUpInside];
317323
}
318324

319-
[_window addSubview:_adSkipButton];
320-
[_adSkipButton stateWithSkipType:configuration.skipButtonType andDuration:configuration.duration];
325+
[_window addSubview:_skipButton];
326+
[_skipButton setTitleWithSkipType:configuration.skipButtonType duration:configuration.duration];
327+
321328
}
322329
}
323330

@@ -391,11 +398,11 @@ -(void)setupVideoAdForConfiguration:(XHLaunchVideoAdConfiguration *)configuratio
391398
}
392399
}
393400

394-
[self startSkipDispathTimer];
395-
396401
/** skipButton */
397402
[self addSkipButtonForConfiguration:configuration];
398403

404+
[self startSkipDispathTimer];
405+
399406
/** customView */
400407
if(configuration.subViews.count>0) [self addSubViews:configuration.subViews];
401408

@@ -442,7 +449,7 @@ -(void)click
442449
XHLaunchAdConfiguration * configuration = [self commonConfiguration];
443450

444451
if ([self.delegate respondsToSelector:@selector(xhLaunchAd:clickAndOpenURLString:)] && configuration.openURLString.length) {
445-
452+
446453
[self.delegate xhLaunchAd:self clickAndOpenURLString:configuration.openURLString];
447454

448455
[self removeAndAnimateDefault];
@@ -469,9 +476,8 @@ -(void)startWaitDataDispathTiemr
469476
{
470477
__block NSInteger duration = defaultWaitDataDuration;
471478
if(_waitDataDuration) duration = _waitDataDuration;
479+
_waitDataTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
472480
NSTimeInterval period = 1.0;
473-
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
474-
_waitDataTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
475481
dispatch_source_set_timer(_waitDataTimer, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0);
476482
dispatch_source_set_event_handler(_waitDataTimer, ^{
477483

@@ -496,9 +502,12 @@ -(void)startSkipDispathTimer
496502
if(!configuration.skipButtonType) configuration.skipButtonType = SkipTypeTimeText;//默认
497503
__block NSInteger duration = 5;//默认
498504
if(configuration.duration) duration = configuration.duration;
505+
if(configuration.skipButtonType == SkipTypeRoundProgressTime || configuration.skipButtonType == SkipTypeRoundProgressText)
506+
{
507+
[_skipButton startRoundDispathTimerWithDuration:duration];
508+
}
499509
NSTimeInterval period = 1.0;
500-
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
501-
_skipTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
510+
_skipTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
502511
dispatch_source_set_timer(_skipTimer, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0);
503512
dispatch_source_set_event_handler(_skipTimer, ^{
504513

@@ -510,13 +519,14 @@ -(void)startSkipDispathTimer
510519
}
511520
if(!configuration.customSkipView){
512521

513-
[_adSkipButton stateWithSkipType:configuration.skipButtonType andDuration:duration];
522+
[_skipButton setTitleWithSkipType:configuration.skipButtonType duration:duration];
514523
}
515524
if(duration==0){
516525

517526
DISPATCH_SOURCE_CANCEL_SAFE(_skipTimer);
518527
[self removeAndAnimate]; return ;
519528
}
529+
520530
duration--;
521531
});
522532
});
@@ -606,7 +616,7 @@ -(void)remove{
606616

607617
DISPATCH_SOURCE_CANCEL_SAFE(_waitDataTimer)
608618
DISPATCH_SOURCE_CANCEL_SAFE(_skipTimer)
609-
REMOVE_FROM_SUPERVIEW_SAFE(_adSkipButton)
619+
REMOVE_FROM_SUPERVIEW_SAFE(_skipButton)
610620
if(_launchAdType==XHLaunchAdTypeVideo){
611621

612622
if(_adVideoView==nil) return;

XHLaunchAd/XHLaunchAd/XHLaunchAdButton.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@
1414
typedef NS_ENUM(NSInteger,SkipType) {
1515

1616
SkipTypeNone = 1,//
17-
SkipTypeTime = 2,//倒计时
18-
SkipTypeText = 3,//跳过
19-
SkipTypeTimeText = 4,//倒计时+跳过
2017

18+
/** 方形 */
19+
SkipTypeTime = 2,//方形:倒计时
20+
SkipTypeText = 3,//方形:跳过
21+
SkipTypeTimeText = 4,//方形:倒计时+跳过 (default)
22+
23+
/** 圆形 */
24+
SkipTypeRoundTime = 5,//圆形:倒计时
25+
SkipTypeRoundText = 6,//圆形:跳过
26+
SkipTypeRoundProgressTime = 7,//圆形:进度圈+倒计时
27+
SkipTypeRoundProgressText = 8,//圆形:进度圈+跳过
2128
};
2229

2330
@interface XHLaunchAdButton : UIButton
2431

25-
@property(nonatomic,strong)UILabel *timeLab;
26-
@property(nonatomic,assign)CGFloat leftRightSpace;
27-
@property(nonatomic,assign)CGFloat topBottomSpace;
28-
29-
-(void)stateWithSkipType:(SkipType)skipType andDuration:(NSInteger)duration;
32+
- (instancetype)initWithSkipType:(SkipType)skipType;
33+
-(void)startRoundDispathTimerWithDuration:(CGFloat )duration;
34+
- (void)setTitleWithSkipType:(SkipType)skipType duration:(NSInteger)duration;
3035

3136
@end

0 commit comments

Comments
 (0)