1414public  abstract  class  Activity_Base_Ads_Banner  extends  org .metatrans .commons .Activity_Base  implements  IActivityInterstitial , IActivityRewardedVideo  {
1515
1616
17- private  static  volatile  long  timestamp_last_interstitial_ad_openning ;
17+ private  static  final  int  INTERSTITIAL_INTERVAL 	= 60  * 1000 ; //1 minute 
18+ 
19+ private  static  final  int  REWARD_INTERVAL 	= 7  * 60  * 1000 ; //7 minutes 
20+ 
21+ private  static  volatile  long  timestamp_last_interstitial_ad_opening ;
22+ 
23+ private  static  volatile  long  timestamp_last_rewarded_ad_opening ;
1824
1925
2026private  IAdLoadFlow  current_adLoadFlow_Banner ;
@@ -32,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
3238super .onCreate (savedInstanceState );
3339
3440//Skip ads first 1 minute 
35- timestamp_last_interstitial_ad_openning  = System .currentTimeMillis ();
41+ timestamp_last_interstitial_ad_opening  = System .currentTimeMillis ();
3642}
3743
3844
@@ -49,18 +55,26 @@ protected void onResume() {
4955//try-catch ensures no errors, because of ads logic. 
5056try  {
5157
52- attachBanner ();
58+ if  (showAds ()) {
59+ 
60+ attachBanner ();
61+ }
5362
5463preloadInterstitial ();
5564
5665preloadRewardedVideo ();
5766
58- } catch (Throwable  t ) {
67+ } catch   (Throwable  t ) {
5968
6069t .printStackTrace ();
6170}
6271}
6372
73+ private  boolean  showAds () {
74+ 
75+ return  System .currentTimeMillis () >= timestamp_last_rewarded_ad_opening  + REWARD_INTERVAL ;
76+ }
77+ 
6478
6579@ Override 
6680protected  void  onPause () {
@@ -197,6 +211,11 @@ public boolean openInterstitial() {
197211
198212System .out .println ("Activity_Base_Ads_Banner.openInterstitial(): called" );
199213
214+ if  (!showAds ()) {
215+ 
216+ System .out .println ("Activity_Base_Ads_Banner.openInterstitial(): !showAds()" );
217+ }
218+ 
200219try  {
201220
202221if  (Application_Base .getInstance ().getApp_Me ().isPaid ()) {
@@ -211,7 +230,7 @@ public boolean openInterstitial() {
211230
212231long  now  = System .currentTimeMillis ();
213232
214- if  (now  >= timestamp_last_interstitial_ad_openning  + 60  *  1000 ) {
233+ if  (now  >= timestamp_last_interstitial_ad_opening  + INTERSTITIAL_INTERVAL ) {
215234
216235if  (current_adLoadFlow_Interstitial  != null ) {
217236
@@ -222,7 +241,7 @@ public boolean openInterstitial() {
222241success  = true ;
223242}
224243
225- timestamp_last_interstitial_ad_openning  = now ;
244+ timestamp_last_interstitial_ad_opening  = now ;
226245
227246} else  {
228247
@@ -282,6 +301,11 @@ public boolean openRewardedVideo() {
282301
283302System .out .println ("Activity_Base_Ads_Banner.openRewardedVideo(): called" );
284303
304+ if  (!showAds ()) {
305+ 
306+ System .out .println ("Activity_Base_Ads_Banner.openRewardedVideo(): !showAds()" );
307+ }
308+ 
285309try  {
286310
287311if  (Application_Base .getInstance ().getApp_Me ().isPaid ()) {
@@ -295,6 +319,8 @@ public boolean openRewardedVideo() {
295319
296320current_adLoadFlow_RewardedVideo .resume ();
297321
322+ timestamp_last_rewarded_ad_opening  = System .currentTimeMillis ();
323+ 
298324System .out .println ("Activity_Base_Ads_Banner.openRewardedVideo(): RESUMED" );
299325
300326return  true ;
0 commit comments