@@ -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 ;
0 commit comments