77// 代码地址:https://github.com/CoderZhuXH/XHLaunchAd
88
99#import " XHLaunchAd.h"
10- #import " XHLaunchAdConst.h"
1110#import " XHLaunchAdView.h"
1211#import " XHLaunchAdImageView+XHLaunchAdCache.h"
1312#import " XHLaunchAdDownloader.h"
@@ -35,6 +34,7 @@ @interface XHLaunchAd()
3534@property (nonatomic ,strong )UIWindow * window;
3635@property (nonatomic ,copy )dispatch_source_t waitDataTimer;
3736@property (nonatomic ,copy )dispatch_source_t skipTimer;
37+ @property (nonatomic , assign ) BOOL detailPageShowing;
3838
3939@end
4040
@@ -83,6 +83,7 @@ +(void)skipAction
8383{
8484 [[XHLaunchAd shareLaunchAd ] adSkipButtonClick ];
8585}
86+
8687+(BOOL )checkImageInCacheWithURL : (NSURL *)url
8788{
8889 return [XHLaunchAdCache checkImageInCacheWithURL: url];
@@ -97,6 +98,16 @@ +(void)clearDiskCache
9798 [XHLaunchAdCache clearDiskCache ];
9899}
99100
101+ +(void )clearDiskCacheWithImageUrlArray : (NSArray <NSURL *> *)imageUrlArray
102+ {
103+ [XHLaunchAdCache clearDiskCacheWithImageUrlArray: imageUrlArray];
104+ }
105+
106+ +(void )clearDiskCacheWithVideoUrlArray : (NSArray <NSURL *> *)videoUrlArray
107+ {
108+ [XHLaunchAdCache clearDiskCacheWithVideoUrlArray: videoUrlArray];
109+ }
110+
100111+(float )diskCacheSize
101112{
102113 return [XHLaunchAdCache diskCacheSize ];
@@ -139,6 +150,19 @@ - (instancetype)init
139150
140151 }];
141152
153+
154+ [[NSNotificationCenter defaultCenter ] addObserverForName: XHLaunchAdDetailPageWillShowNotification object: nil queue: nil usingBlock: ^(NSNotification * _Nonnull note) {
155+
156+ _detailPageShowing = YES ;
157+
158+ }];
159+
160+ [[NSNotificationCenter defaultCenter ] addObserverForName: XHLaunchAdDetailPageShowFinishNotification object: nil queue: nil usingBlock: ^(NSNotification * _Nonnull note) {
161+
162+ _detailPageShowing = NO ;
163+
164+ }];
165+
142166 }
143167 return self;
144168}
@@ -148,14 +172,14 @@ -(void)setupLaunchAdEnterForeground
148172 switch (_launchAdType) {
149173 case XHLaunchAdTypeImage:
150174 {
151- if (!_imageAdConfiguration.showEnterForeground ) return ;
175+ if (!_imageAdConfiguration.showEnterForeground || _detailPageShowing ) return ;
152176 [self setupLaunchAd ];
153177 [self setupImageAdForConfiguration: _imageAdConfiguration];
154178 }
155179 break ;
156180 case XHLaunchAdTypeVideo:
157181 {
158- if (!_videoAdConfiguration.showEnterForeground ) return ;
182+ if (!_videoAdConfiguration.showEnterForeground || _detailPageShowing ) return ;
159183 [self setupLaunchAd ];
160184 [self setupVideoAdForConfiguration: _videoAdConfiguration];
161185 }
@@ -283,7 +307,8 @@ -(void)addSkipButtonForConfiguration:(XHLaunchAdConfiguration *)configuration
283307
284308 if (_adSkipButton == nil ){
285309
286- _adSkipButton = [[XHLaunchAdButton alloc ] initWithFrame: CGRectMake ([UIScreen mainScreen ].bounds.size.width-80 ,20 , 70 , 35 )];
310+ CGFloat y = XH_IPHONEX ? 44 : 20 ;
311+ _adSkipButton = [[XHLaunchAdButton alloc ] initWithFrame: CGRectMake ([UIScreen mainScreen ].bounds.size.width-80 ,y, 70 , 35 )];
287312 _adSkipButton.hidden = YES ;
288313 [_adSkipButton addTarget: self action: @selector (adSkipButtonClick ) forControlEvents: UIControlEventTouchUpInside];
289314 _adSkipButton.leftRightSpace = 5 ;
@@ -417,7 +442,7 @@ -(void)click
417442 XHLaunchAdConfiguration * configuration = [self commonConfiguration ];
418443
419444 if ([self .delegate respondsToSelector: @selector (xhLaunchAd:clickAndOpenURLString: )] && configuration.openURLString .length ) {
420-
445+
421446 [self .delegate xhLaunchAd: self clickAndOpenURLString: configuration.openURLString];
422447
423448 [self removeAndAnimateDefault ];
0 commit comments