Commit eacf3173 authored by wanglei's avatar wanglei

...

parent 4bcf42c8
package com.base.pdfviewerscannerwhite.ads; package com.base.pdfviewerscannerwhite.ads
import android.content.Context; import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.inter_limit_click
import android.content.SharedPreferences; import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.inter_limit_request
import android.util.Log; import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.inter_limit_show
import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.native_limit_request
import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.native_limit_show
import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.open_limit_click
import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.open_limit_request
import com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.open_limit_show
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
import org.json.JSONException; object AdDisplayUtils {
import org.json.JSONObject;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import com.base.pdfviewerscannerwhite.BuildConfig; //region open
import com.base.pdfviewerscannerwhite.helper.EventUtils; private val open_max_request = AppPreferences.getInstance().getString(open_limit_request, "15").toInt()
import com.base.pdfviewerscannerwhite.helper.MyApplication; private val open_max_show = AppPreferences.getInstance().getString(open_limit_show, "10").toInt()
import com.base.pdfviewerscannerwhite.utils.AppPreferences; private val open_max_click = AppPreferences.getInstance().getString(open_limit_click, "1").toInt()
import com.base.pdfviewerscannerwhite.utils.LogEx;
import com.facebook.appevents.AppEventsLogger;
public class AdDisplayUtils { fun incrementOpenRequestCount() {
private String TAG = "AdDisplayUtils"; currentOpenRequest += 1
public static final int DEFAULT_MAX_AD_REQUEST_COUNT = 100; // 广告请求次数限制默认值
public static final int DEFAULT_MAX_AD_REQUEST_FAIL_COUNT = 20; // 单个广告点击次数限制默认值
public static final int DEFAULT_MAX_AD_DISPLAY_COUNT = 45; // 总广告展示次数限制默认值
public static final int DEFAULT_MAX_AD_CLICK_COUNT = 10; // 单个广告点击次数限制默认值
private static final String AD_PREFS_NAME = "ad_prefs"; // SharedPreferences 名称
private static AdDisplayUtils instance; // 单例对象
private String currentDate; // 当前日期
private Context context = MyApplication.context;
public void saveSp() {
this.maxAdRequestCount = Integer.parseInt(AppPreferences.getInstance().getString("adMaxRequestCount", String.valueOf(DEFAULT_MAX_AD_REQUEST_COUNT)));
saveMaxAdRequestCount();
this.maxAdRequestFailCount = Integer.parseInt(AppPreferences.getInstance().getString("adRequestFailCount", String.valueOf(DEFAULT_MAX_AD_REQUEST_FAIL_COUNT)));
saveMaxAdRequestFailCount();
this.maxAdDisplayCount = Integer.parseInt(AppPreferences.getInstance().getString("adShowCount", String.valueOf(DEFAULT_MAX_AD_DISPLAY_COUNT)));
saveMaxAdDisplayCount();
this.maxAdClickCount = Integer.parseInt(AppPreferences.getInstance().getString("adClickCount", String.valueOf(DEFAULT_MAX_AD_CLICK_COUNT)));
saveMaxAdClickCount();
}
private AdDisplayUtils() {
currentDate = getCurrentDate();
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0);
maxAdRequestCount = prefs.getInt(MAX_AD_REQUEST_COUNT_KEY, DEFAULT_MAX_AD_REQUEST_COUNT);
maxAdRequestFailCount = prefs.getInt(MAX_AD_REQUEST_FAIL_COUNT_KEY, DEFAULT_MAX_AD_REQUEST_FAIL_COUNT);
maxAdDisplayCount = prefs.getInt(MAX_AD_DISPLAY_COUNT_KEY, DEFAULT_MAX_AD_DISPLAY_COUNT);
maxAdClickCount = prefs.getInt(MAX_AD_CLICK_COUNT_KEY, DEFAULT_MAX_AD_CLICK_COUNT);
adRequestCount = prefs.getInt(getAdRequestCountKey(), 0);
adRequestFailCount = prefs.getInt(getAdRequestFailCountKey(), 0);
adDisplayCount = prefs.getInt(getAdDisplayCountKey(), 0);
adClickCount = prefs.getInt(getAdClickCountKey(), 0);
}
public static synchronized AdDisplayUtils getInstance() {
if (instance == null) {
instance = new AdDisplayUtils();
}
return instance;
}
public boolean shouldSendAdRequest() {
return adRequestCount < maxAdRequestCount;
} }
public boolean shouldIncrementRequestFailAd() { fun incrementOpenShow() {
return adRequestFailCount < maxAdRequestFailCount; currentOpenShow += 1
} }
public boolean shouldDisplayAd() { fun incrementClickShow() {
return adDisplayCount < maxAdDisplayCount; currentOpenClick += 1
} }
public boolean shouldIncrementClickCount() {
return adClickCount < maxAdClickCount;
}
public boolean shouldShowAd(String ad_unit) { //当前开屏请求次数
if (BuildConfig.DEBUG) { private var currentOpenRequest = 0
return true; get() {
return AppPreferences.getInstance().getInt("currentOpenRequest_${currentDate()}", field)
} }
boolean shouldDisplayAd = shouldDisplayAd(); set(value) {
boolean shouldIncrementClickCount = shouldIncrementClickCount(); field = value
boolean shouldIncrementRequestFailAd = shouldIncrementRequestFailAd(); AppPreferences.getInstance().put("currentOpenRequest_${currentDate()}", value, true)
boolean shouldSendAdRequest = shouldSendAdRequest();
LogEx.INSTANCE.logDebug(TAG, "shouldSendAdRequest=" + shouldSendAdRequest, false);
LogEx.INSTANCE.logDebug(TAG, "shouldIncrementRequestFailAd=" + shouldIncrementRequestFailAd, false);
LogEx.INSTANCE.logDebug(TAG, "shouldIncrementClickCount=" + shouldIncrementClickCount, false);
LogEx.INSTANCE.logDebug(TAG, "shouldDisplayAd=" + shouldDisplayAd, false);
boolean show = shouldIncrementRequestFailAd && shouldSendAdRequest && shouldDisplayAd && shouldIncrementClickCount;
if (!show) {
LogEx.INSTANCE.logDebug("glc", "!shouldShowAd", false);
JSONObject obj2 = new JSONObject();
try {
obj2.put("reason", "ad_limit");
obj2.put("shouldSendAdRequest", shouldSendAdRequest);
obj2.put("shouldIncrementRequestFailAd", shouldIncrementRequestFailAd);
obj2.put("shouldDisplayAd", shouldDisplayAd);
obj2.put("shouldIncrementClickCount", shouldIncrementClickCount);
obj2.put("adDisplayCount", adDisplayCount);
obj2.put("maxAdDisplayCount", maxAdDisplayCount);
obj2.put("adClickCount", adClickCount);
obj2.put("maxAdClickCount", maxAdClickCount);
obj2.put("adRequestFailCount", adRequestFailCount);
obj2.put("adRequestCount", maxAdRequestFailCount);
obj2.put("adRequestCount", adRequestCount);
obj2.put("ad_unit", ad_unit);
EventUtils.INSTANCE.event("ad_limit", null, obj2, false);
} catch (JSONException ignored) {
}
} }
return show;
}
//当前开屏展示次数
private var currentOpenShow = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenShow_${currentDate()}", value, true)
}
//region AdRequestCount //当前开屏点击次数
private int maxAdRequestCount = 0; // 最大广告请求次数 private var currentOpenClick = 0
private int adRequestCount = 0; // 当前广告请求次数 get() {
private static final String MAX_AD_REQUEST_COUNT_KEY = "max_ad_request_count"; // 广告请求次数限制的键 return AppPreferences.getInstance().getInt("currentOpenClick_${currentDate()}", field)
private static final String AD_REQUEST_COUNT_KEY = "ad_request_count";//广告请求次数 }
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenClick_${currentDate()}", value, true)
}
private void saveMaxAdRequestCount() { fun shouldShowOpenAd(): Boolean {
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(MAX_AD_REQUEST_COUNT_KEY, maxAdRequestCount);
editor.apply();
}
public void incrementAdRequestCount() { if (currentOpenRequest > open_max_request) {
if (!currentDate.equals(getCurrentDate())) { LogEx.logDebug(TAG, "currentOpenRequest=$currentOpenRequest open_max_request=$open_max_request")
currentDate = getCurrentDate(); EventUtils.event("ad_limit", "currentOpenRequest=$currentOpenRequest open_max_request=$open_max_request")
adRequestCount = 0; return false
}
if (currentOpenShow > open_max_show) {
LogEx.logDebug(TAG, "currentOpenShow=$currentOpenShow open_max_show=$open_max_show")
EventUtils.event("ad_limit", "currentOpenShow=$currentOpenShow open_max_show=$open_max_show")
return false
}
if (currentOpenClick > open_max_click) {
LogEx.logDebug(TAG, "currentOpenClick=$currentOpenClick open_max_click=$open_max_click")
EventUtils.event("ad_limit", "currentOpenClick=$currentOpenClick open_max_click=$open_max_click")
return false
} }
adRequestCount++;
saveAdRequestCount();
}
private String getAdRequestCountKey() {
return AD_REQUEST_COUNT_KEY + "_" + currentDate;
}
private void saveAdRequestCount() { return true
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(getAdRequestCountKey(), adRequestCount);
editor.apply();
} }
//endregion //endregion
//region AdRequestFailCount //region inter
private int maxAdRequestFailCount; // 请求失败总
private int adRequestFailCount = 0; // 请求失败当前
private static final String MAX_AD_REQUEST_FAIL_COUNT_KEY = "max_ad_request_fail_count"; // 单个广告点击次数限制的键
private static final String AD_REQUEST_FAIL_COUNT_KEY = "ad_request_fail_count"; // 单个广告点击次数限制的键
private void saveMaxAdRequestFailCount() { private val inter_max_request = AppPreferences.getInstance().getString(inter_limit_request, "15").toInt()
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0); private val inter_max_show = AppPreferences.getInstance().getString(inter_limit_show, "10").toInt()
SharedPreferences.Editor editor = prefs.edit(); private val inter_max_click = AppPreferences.getInstance().getString(inter_limit_click, "1").toInt()
editor.putInt(MAX_AD_REQUEST_FAIL_COUNT_KEY, maxAdRequestFailCount); fun incrementInterRequestCount() {
editor.apply(); currentInterRequest += 1
} }
public void incrementAdRequestFailCount() { fun incrementInterShowCount() {
if (!currentDate.equals(getCurrentDate())) { currentInterShow += 1
currentDate = getCurrentDate();
adRequestFailCount = 0;
}
adRequestFailCount++;
saveAdRequestFailCount();
Log.d("glc", "广告请求失败:" + adRequestFailCount);
}
private String getAdRequestFailCountKey() {
return AD_REQUEST_FAIL_COUNT_KEY + "_" + currentDate;
} }
private void saveAdRequestFailCount() { fun incrementInterClickCount() {
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0); currentInterClick += 1
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(getAdRequestFailCountKey(), adRequestFailCount);
editor.apply();
} }
//endregion
//region AdDisplayCount //当前插页请求次数
private int maxAdDisplayCount; // 总广告展示次数限制 private var currentInterRequest = 0
private int adDisplayCount = 0; // 当前广告展示次数 get() {
private static final String MAX_AD_DISPLAY_COUNT_KEY = "max_ad_display_count"; // 总广告展示次数限制的键 return AppPreferences.getInstance().getInt("currentInterRequest_${currentDate()}", field)
}
private static final String AD_DISPLAY_COUNT_KEY = "ad_display_count"; // 广告展示次数的键 set(value) {
field = value
AppPreferences.getInstance().put("currentInterRequest_${currentDate()}", value, true)
}
private void saveMaxAdDisplayCount() { //当前插页展示次数
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0); private var currentInterShow = 0
SharedPreferences.Editor editor = prefs.edit(); get() {
editor.putInt(MAX_AD_DISPLAY_COUNT_KEY, maxAdDisplayCount); return AppPreferences.getInstance().getInt("currentInterShow_${currentDate()}", field)
editor.apply(); }
} set(value) {
field = value
AppPreferences.getInstance().put("currentInterShow_${currentDate()}", value, true)
}
public void incrementAdDisplayCount() { //当前插页点击次数
if (!currentDate.equals(getCurrentDate())) { private var currentInterClick = 0
currentDate = getCurrentDate(); get() {
adDisplayCount = 0; return AppPreferences.getInstance().getInt("currentInterClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterClick_${currentDate()}", value, true)
} }
adDisplayCount++;
int max = AppPreferences.getInstance().getInt("facebookAdShowEventCount", 3); fun shouldShowInterAd(): Boolean {
if (adClickCount >= max && max != -1) { if (currentInterRequest > inter_max_request) {
AppEventsLogger logger = AppEventsLogger.newLogger(context); LogEx.logDebug(TAG, "currentInterRequest=$currentInterRequest inter_max_request=$inter_max_request")
logger.logEvent("ad_show"); EventUtils.event("ad_limit", "currentInterRequest=$currentInterRequest inter_max_request=$inter_max_request")
AppPreferences.getInstance().put("facebookAdShowEventCount", -1); return false
} }
if (currentInterShow > inter_max_show) {
saveAdDisplayCount(); LogEx.logDebug(TAG, "currentInterShow=$currentInterShow inter_max_show=$inter_max_show")
EventUtils.event("ad_limit", "currentInterShow=$currentInterShow inter_max_show=$inter_max_show")
return false
}
if (currentInterClick > inter_max_click) {
LogEx.logDebug(TAG, "currentInterClick=$currentInterClick inter_max_click=$inter_max_click")
EventUtils.event("ad_limit", "currentInterClick=$currentInterClick inter_max_click=$inter_max_click")
return false
}
return true
} }
//endregion
//region native
private val native_max_request = AppPreferences.getInstance().getString(native_limit_request, "15").toInt()
private val native_max_show = AppPreferences.getInstance().getString(native_limit_show, "10").toInt()
private val native_max_click = AppPreferences.getInstance().getString(native_limit_show, "1").toInt()
private String getAdDisplayCountKey() { fun incrementNativeRequestCount() {
return AD_DISPLAY_COUNT_KEY + "_" + currentDate; currentNativeRequest += 1
} }
private void saveAdDisplayCount() { fun incrementNativeShowCount() {
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0); currentNativeShow += 1
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(getAdDisplayCountKey(), adDisplayCount);
editor.apply();
} }
//endregion
//region AdClickCount
public int maxAdClickCount; // 单个广告点击次数限制
private int adClickCount = 0; // 当前广告点击次数
private static final String MAX_AD_CLICK_COUNT_KEY = "max_ad_click_count"; // 单个广告点击次数限制的键
private static final String AD_CLICK_COUNT_KEY = "ad_click_count"; // 广告点击次数的键
private void saveMaxAdClickCount() { fun incrementNativeClickCount() {
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0); currentNativeClick += 1
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(MAX_AD_CLICK_COUNT_KEY, maxAdClickCount);
editor.apply();
} }
public void incrementAdClickCount() { private var currentNativeRequest = 0
LogEx.INSTANCE.logDebug(TAG, "incrementAdClickCount", false); get() {
if (!currentDate.equals(getCurrentDate())) { return AppPreferences.getInstance().getInt("currentNativeRequest_${currentDate()}", field)
currentDate = getCurrentDate(); }
adClickCount = 0; set(value) {
field = value
AppPreferences.getInstance().put("currentNativeRequest_${currentDate()}", value, true)
}
private var currentNativeShow = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeShow_${currentDate()}", value, true)
} }
adClickCount++;
saveAdClickCount();
}
private String getAdClickCountKey() { private var currentNativeClick = 0
return AD_CLICK_COUNT_KEY + "_" + currentDate; get() {
} return AppPreferences.getInstance().getInt("currentNativeClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeClick_${currentDate()}", value, true)
}
public void setAdClickCount(int s) {
if (!currentDate.equals(getCurrentDate())) { fun shouldShowNative(): Boolean {
currentDate = getCurrentDate(); if (currentNativeRequest > native_max_request) {
adClickCount = 0; LogEx.logDebug(TAG, "currentNativeRequest=$currentNativeRequest native_max_request=$native_max_request")
EventUtils.event("ad_limit", "currentNativeRequest=$currentNativeRequest native_max_request=$native_max_request")
return false
}
if (currentNativeShow > native_max_show) {
LogEx.logDebug(TAG, "currentNativeShow=$currentNativeShow native_max_show=$native_max_show")
EventUtils.event("ad_limit", "currentNativeShow=$currentNativeShow native_max_show=$native_max_show")
return false
} }
adClickCount = s; if (currentNativeClick > native_max_click) {
saveAdClickCount(); LogEx.logDebug(TAG, "currentNativeClick=$currentNativeClick native_max_click=$native_max_click")
EventUtils.event("ad_limit", "currentNativeClick=$currentNativeClick native_max_click=$native_max_click")
return false
}
return true
} }
private void saveAdClickCount() {
SharedPreferences prefs = context.getSharedPreferences(AD_PREFS_NAME, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(getAdClickCountKey(), adClickCount);
editor.apply();
LogEx.INSTANCE.logDebug(TAG, "adClickCount=" + adClickCount, false);
}
//endregion //endregion
private val TAG = "AdDisplayUtils"
public String getCurrentDate() { private fun currentDate(): String {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
Date currentDate = Calendar.getInstance().getTime(); val currentDate = Calendar.getInstance().time
return dateFormat.format(currentDate); return dateFormat.format(currentDate)
} }
} }
package com.base.pdfviewerscannerwhite.ads package com.base.pdfviewerscannerwhite.ads
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.google.firebase.database.DataSnapshot import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError import com.google.firebase.database.DatabaseError
...@@ -27,7 +28,7 @@ object FirebaseDatabase { ...@@ -27,7 +28,7 @@ object FirebaseDatabase {
const val inter_limit_show = "inter_limit_show" const val inter_limit_show = "inter_limit_show"
const val inter_limit_click = "inter_limit_click" const val inter_limit_click = "inter_limit_click"
//原生广告现在 //原生广告限制
const val native_limit_request = "native_limit_request" const val native_limit_request = "native_limit_request"
const val native_limit_show = "native_limit_show" const val native_limit_show = "native_limit_show"
const val native_limit_click = "native_limit_click" const val native_limit_click = "native_limit_click"
...@@ -90,60 +91,63 @@ object FirebaseDatabase { ...@@ -90,60 +91,63 @@ object FirebaseDatabase {
//可请求时间段间隔时间 //可请求时间段间隔时间
const val ad_request_period_interval = "ad_request_period_interval" const val ad_request_period_interval = "ad_request_period_interval"
fun saveDatabase2Sp() { fun saveDatabase2Sp() {
add(open_limit_request, "15") // add(open_limit_request, "15")
add(open_limit_show, "10") // add(open_limit_show, "10")
add(open_limit_click, "1") // add(open_limit_click, "1")
//
//
add(inter_limit_request, "15") // add(inter_limit_request, "15")
add(inter_limit_show, "10") // add(inter_limit_show, "10")
add(inter_limit_click, "1") // add(inter_limit_click, "1")
//
add(native_limit_request, "15") // add(native_limit_request, "15")
add(native_limit_show, "10") // add(native_limit_show, "10")
add(native_limit_click, "1") // add(native_limit_click, "1")
//
add(popup_count, "0") // add(popup_count, "0")
add(popup_status, "1") // add(popup_status, "1")
//
add(popup_style1_start, "7") // add(popup_style1_start, "7")
add(popup_style1_end, "11") // add(popup_style1_end, "11")
add(popup_style1_count, "0") // add(popup_style1_count, "0")
add(popup_style1_status, "1") // add(popup_style1_status, "1")
add(popup_style1_interval, "120") // add(popup_style1_interval, "120")
//
add(popup_style2_start, "12") // add(popup_style2_start, "12")
add(popup_style2_end, "17") // add(popup_style2_end, "17")
add(popup_style2_count, "0") // add(popup_style2_count, "0")
add(popup_style2_status, "1") // add(popup_style2_status, "1")
add(popup_style2_interval, "120") // add(popup_style2_interval, "120")
//
add(popup_style3_start, "18") // add(popup_style3_start, "18")
add(popup_style3_end, "24") // add(popup_style3_end, "24")
add(popup_style3_count, "0") // add(popup_style3_count, "0")
add(popup_style3_status, "1") // add(popup_style3_status, "1")
add(popup_style3_interval, "120") // add(popup_style3_interval, "120")
//
add(showLanPage, "1") // add(showLanPage, "1")
//
add(open_ad_loading, "8000") // add(open_ad_loading, "8000")
add(create_pdf_loading, "8000") // add(create_pdf_loading, "8000")
add(delete_loading, "8000") // add(delete_loading, "8000")
add(open_file_loading, "8000") // add(open_file_loading, "8000")
add(merge_loading, "8000") // add(merge_loading, "8000")
add(split_loading, "8000") // add(split_loading, "8000")
//
add(ad_request_period, "1") // add(ad_request_period, "1")
add(ad_period_max_request, "10") // add(ad_period_max_request, "10")
add(ad_request_period_interval, "60") // add(ad_request_period_interval, "60")
rootRef.addListenerForSingleValueEvent(object : ValueEventListener { rootRef.addListenerForSingleValueEvent(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) { override fun onDataChange(dataSnapshot: DataSnapshot) {
var i = 0
for (snapshot in dataSnapshot.getChildren()) { for (snapshot in dataSnapshot.getChildren()) {
val key1 = snapshot.key val key1 = snapshot.key
val value1 = snapshot.value val value1 = snapshot.value
LogEx.logDebug("Database", "Key: $key1, Value: $value1") i++
LogEx.logDebug("Database", "Key: $key1, Value: $value1 $i")
AppPreferences.getInstance().put(key1, value1)
} }
} }
......
...@@ -55,7 +55,7 @@ object AdmobInterstitialUtils { ...@@ -55,7 +55,7 @@ object AdmobInterstitialUtils {
return return
} }
if (!AdDisplayUtils.getInstance().shouldShowAd("interAd")) { if (!AdDisplayUtils.shouldShowInterAd()) {
onHidden?.invoke(false) onHidden?.invoke(false)
return return
} }
...@@ -79,7 +79,7 @@ object AdmobInterstitialUtils { ...@@ -79,7 +79,7 @@ object AdmobInterstitialUtils {
onLoad?.invoke() onLoad?.invoke()
return return
} }
if (!AdDisplayUtils.getInstance().shouldShowAd("interAd")) { if (!AdDisplayUtils.shouldShowInterAd()) {
onLoad?.invoke() onLoad?.invoke()
return return
} }
...@@ -152,7 +152,7 @@ object AdmobInterstitialUtils { ...@@ -152,7 +152,7 @@ object AdmobInterstitialUtils {
thisInterAd?.fullScreenContentCallback = object : FullScreenContentCallback() { thisInterAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdClicked() { override fun onAdClicked() {
clickAd(thisInterAd?.responseInfo, "interAd") clickAd(thisInterAd?.responseInfo, "interAd")
AdDisplayUtils.getInstance().incrementAdClickCount() AdDisplayUtils.incrementInterAdClickCount()
} }
override fun onAdDismissedFullScreenContent() { override fun onAdDismissedFullScreenContent() {
...@@ -172,7 +172,7 @@ object AdmobInterstitialUtils { ...@@ -172,7 +172,7 @@ object AdmobInterstitialUtils {
override fun onAdShowedFullScreenContent() { override fun onAdShowedFullScreenContent() {
dialog?.dismiss() dialog?.dismiss()
showAd(thisInterAd?.responseInfo, "interAd", activity) showAd(thisInterAd?.responseInfo, "interAd", activity)
AdDisplayUtils.getInstance().incrementAdDisplayCount() AdDisplayUtils.incrementInterAdDisplayCount()
adLastDisplayTime = System.currentTimeMillis() / 1000 adLastDisplayTime = System.currentTimeMillis() / 1000
} }
} }
......
...@@ -40,7 +40,7 @@ object AdmobNativeUtils { ...@@ -40,7 +40,7 @@ object AdmobNativeUtils {
return return
} }
isLoading = true isLoading = true
if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) { if (!AdDisplayUtils.shouldShowNative()) {
return return
} }
...@@ -88,7 +88,7 @@ object AdmobNativeUtils { ...@@ -88,7 +88,7 @@ object AdmobNativeUtils {
val obj = JSONObject() val obj = JSONObject()
obj.put("ad_unit", "NativeAd") obj.put("ad_unit", "NativeAd")
EventUtils.event("ad_prepare_show_native", ext = obj) EventUtils.event("ad_prepare_show_native", ext = obj)
if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) { if (!AdDisplayUtils.shouldShowNative()) {
return return
} }
loadingListener = { loadingListener = {
......
...@@ -32,7 +32,7 @@ object AdmobOpenUtils { ...@@ -32,7 +32,7 @@ object AdmobOpenUtils {
onLoad?.invoke(1) onLoad?.invoke(1)
return return
} }
if (!AdDisplayUtils.getInstance().shouldShowAd("openAd")) { if (!AdDisplayUtils.shouldShowOpenAd()) {
onLoad?.invoke(2) onLoad?.invoke(2)
return return
} }
...@@ -75,7 +75,7 @@ object AdmobOpenUtils { ...@@ -75,7 +75,7 @@ object AdmobOpenUtils {
if (activity.isFinishing || activity.isDestroyed) { if (activity.isFinishing || activity.isDestroyed) {
return return
} }
if (!AdDisplayUtils.getInstance().shouldShowAd("openAd")) { if (!AdDisplayUtils.shouldShowOpenAd()) {
onHidden?.invoke(false) onHidden?.invoke(false)
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment