Commit f3e33038 authored by wanglei's avatar wanglei

...

parent 2d822de0
...@@ -2,6 +2,7 @@ package com.base.datarecovery.ads; ...@@ -2,6 +2,7 @@ package com.base.datarecovery.ads;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.util.Log; import android.util.Log;
import com.base.datarecovery.BuildConfig; import com.base.datarecovery.BuildConfig;
import com.base.datarecovery.MyApplication; import com.base.datarecovery.MyApplication;
import com.base.datarecovery.help.BaseApplication; import com.base.datarecovery.help.BaseApplication;
...@@ -9,8 +10,10 @@ import com.base.datarecovery.utils.AppPreferences; ...@@ -9,8 +10,10 @@ import com.base.datarecovery.utils.AppPreferences;
import com.base.datarecovery.utils.EventUtils; import com.base.datarecovery.utils.EventUtils;
import com.base.datarecovery.utils.LogEx; import com.base.datarecovery.utils.LogEx;
import com.facebook.appevents.AppEventsLogger; import com.facebook.appevents.AppEventsLogger;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -108,6 +111,18 @@ public class AdDisplayUtils { ...@@ -108,6 +111,18 @@ public class AdDisplayUtils {
obj2.put("shouldDisplayAd", shouldDisplayAd); obj2.put("shouldDisplayAd", shouldDisplayAd);
obj2.put("shouldIncrementClickCount", shouldIncrementClickCount); 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("maxAdRequestCount", maxAdRequestCount);
obj2.put("ad_unit", ad_unit); obj2.put("ad_unit", ad_unit);
EventUtils.INSTANCE.event("ad_show_error", null, obj2, false); EventUtils.INSTANCE.event("ad_show_error", null, obj2, false);
} catch (JSONException ignored) { } catch (JSONException ignored) {
......
...@@ -14,6 +14,7 @@ import com.base.datarecovery.ads.max.AdMaxInterstitialUtils ...@@ -14,6 +14,7 @@ import com.base.datarecovery.ads.max.AdMaxInterstitialUtils
import com.base.datarecovery.ads.max.AdMaxOpenUtils import com.base.datarecovery.ads.max.AdMaxOpenUtils
import com.base.datarecovery.help.BaseApplication import com.base.datarecovery.help.BaseApplication
import com.base.datarecovery.utils.AppPreferences import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.EventUtils
import com.base.datarecovery.utils.LogEx import com.base.datarecovery.utils.LogEx
import com.google.android.gms.ads.MobileAds import com.google.android.gms.ads.MobileAds
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
...@@ -59,17 +60,20 @@ object AdmobMaxHelper { ...@@ -59,17 +60,20 @@ object AdmobMaxHelper {
var lastShowedOnHiddenTime = 0L var lastShowedOnHiddenTime = 0L
fun admobMaxShowInterstitialAd(activity: Activity, isLoading: Boolean = true, onHidden: (() -> Unit)? = null) { fun admobMaxShowInterstitialAd(activity: Activity, isLoading: Boolean = true, onHidden: (() -> Unit)? = null) {
if (isBlack) { if (isBlack) {
EventUtils.event("ad_black", "interAd")
onHidden?.invoke() onHidden?.invoke()
return return
} }
val isShowLoadingAd = AppPreferences.getInstance().getString("isShowLoadingAd", "0").toInt() val isShowLoadingAd = AppPreferences.getInstance().getString("isShowLoadingAd", "0").toInt()
if (isShowLoadingAd == 0 && isLoading) { if (isShowLoadingAd == 0 && isLoading) {
EventUtils.event("ad_switch_close")
onHidden?.invoke() onHidden?.invoke()
return return
} }
val adInterval = AppPreferences.getInstance().getString("adInterval", "0").toInt() val adInterval = AppPreferences.getInstance().getString("adInterval", "0").toInt()
if ((System.currentTimeMillis() - lastShowedOnHiddenTime) < adInterval * 1000 && lastShowedOnHiddenTime != 0L) { if ((System.currentTimeMillis() - lastShowedOnHiddenTime) < adInterval * 1000 && lastShowedOnHiddenTime != 0L) {
onHidden?.invoke() onHidden?.invoke()
EventUtils.event("ad_interval")
return return
} }
...@@ -87,6 +91,7 @@ object AdmobMaxHelper { ...@@ -87,6 +91,7 @@ object AdmobMaxHelper {
fun admobMaxShowOpenAd(activity: Activity, showBeforeAction: (flag: Boolean) -> Unit, onHidden: (() -> Unit)? = null) { fun admobMaxShowOpenAd(activity: Activity, showBeforeAction: (flag: Boolean) -> Unit, onHidden: (() -> Unit)? = null) {
if (isBlack) { if (isBlack) {
onHidden?.invoke() onHidden?.invoke()
EventUtils.event("ad_black", "openAd")
return return
} }
...@@ -124,21 +129,21 @@ object AdmobMaxHelper { ...@@ -124,21 +129,21 @@ object AdmobMaxHelper {
} }
fun initAdmobMaxAd(activity: Activity? = null) { fun initAdmobMaxAd() {
if (isBlack) { if (isBlack) {
return return
} }
if (getSpAdmobTrueMaxFalse()) { if (getSpAdmobTrueMaxFalse()) {
LogEx.logDebug(TAG, "init sp Admob")
if (!isAdInit.get()) { if (!isAdInit.get()) {
LogEx.logDebug(TAG, "init sp Admob")
MobileAds.initialize(BaseApplication.context) { initializationStatus -> MobileAds.initialize(BaseApplication.context) { initializationStatus ->
isAdInit.set(true) isAdInit.set(true)
} }
} }
} else { } else {
LogEx.logDebug(TAG, "init sp AdMax")
if (!isAdInit.get()) { if (!isAdInit.get()) {
LogEx.logDebug(TAG, "init sp AdMax")
BaseApplication.context.initAdMax() BaseApplication.context.initAdMax()
} }
} }
......
...@@ -21,7 +21,6 @@ import java.net.URL ...@@ -21,7 +21,6 @@ import java.net.URL
import java.util.Base64 import java.util.Base64
import java.util.Locale import java.util.Locale
@RequiresApi(Build.VERSION_CODES.O)
object NewComUtils { object NewComUtils {
private val TAG = "NewComUtils" private val TAG = "NewComUtils"
private const val API_URL = ConfigHelper.apiUrl private const val API_URL = ConfigHelper.apiUrl
...@@ -33,16 +32,13 @@ object NewComUtils { ...@@ -33,16 +32,13 @@ object NewComUtils {
private val url: String by lazy { private val url: String by lazy {
val packageName = ConfigHelper.packageName val packageName = ConfigHelper.packageName
val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault()) val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault())
val baseRefer = if(Build.VERSION.SDK_INT >=Build.VERSION_CODES.O){
Base64.getEncoder().encodeToString(AppPreferences.getInstance().getString("referrerUrl", "").toByteArray()) val bRefer = Base64.getEncoder().encodeToString(AppPreferences.getInstance().getString("referrer", "").toByteArray())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { "$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
"$API_URL/${appCode}spk?pkg=$packageName" + "&referrer=${baseRefer}" + "&vn=${BuildConfig.VERSION_NAME}" +
"&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences.getInstance().getString("gid", "") AppPreferences.getInstance().getString("gid", "")
}&aid=${AppPreferences.getInstance().getString("uuid", "")}" }&aid=${AppPreferences.getInstance().getString("uuid", "")}"
} else { }else{
"$API_URL/${appCode}spk?pkg=$packageName" + "&vn=${BuildConfig.VERSION_NAME}" + "$API_URL/${appCode}spk?pkg=$packageName&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
"&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences.getInstance().getString("gid", "") AppPreferences.getInstance().getString("gid", "")
}&aid=${AppPreferences.getInstance().getString("uuid", "")}" }&aid=${AppPreferences.getInstance().getString("uuid", "")}"
} }
......
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