Commit 35d3f4c4 authored by leichao.gao's avatar leichao.gao

update

parent 23676d43
...@@ -61,7 +61,7 @@ object AdMaxEvent { ...@@ -61,7 +61,7 @@ object AdMaxEvent {
} }
fun showAd(ad: MaxAd?, adUnit: String,activity: Activity) { fun showAd(ad: MaxAd?, adUnit: String,activity: Activity?) {
val obj = JSONObject() val obj = JSONObject()
obj.put("UnitId", ad?.adUnitId) obj.put("UnitId", ad?.adUnitId)
obj.put("ad_unit", adUnit) obj.put("ad_unit", adUnit)
...@@ -74,8 +74,8 @@ object AdMaxEvent { ...@@ -74,8 +74,8 @@ object AdMaxEvent {
obj.put("networkplacement", ad?.networkPlacement) obj.put("networkplacement", ad?.networkPlacement)
obj.put("latency", ad?.requestLatencyMillis) obj.put("latency", ad?.requestLatencyMillis)
obj.put("valueMicros", ad?.revenue) obj.put("valueMicros", ad?.revenue)
obj.put("from",activity.javaClass.simpleName) obj.put("from",activity?.javaClass?.simpleName)
LogEx.logDebug("glc","from: "+activity.javaClass.simpleName) LogEx.logDebug("glc","from: "+activity?.javaClass?.simpleName)
if(!adUnit.equals("nativeAd")){ if(!adUnit.equals("nativeAd")){
EventUtils.event("ad_show", ext = obj) EventUtils.event("ad_show", ext = obj)
}else{ }else{
......
...@@ -32,7 +32,6 @@ object AdMaxInterstitialUtils { ...@@ -32,7 +32,6 @@ object AdMaxInterstitialUtils {
private fun setListener(activity: Activity) { private fun setListener(activity: Activity) {
if (interstitialAd == null) { if (interstitialAd == null) {
val reqId = UUID.randomUUID().toString() val reqId = UUID.randomUUID().toString()
val obj = JSONObject() val obj = JSONObject()
obj.put("req_id", reqId) obj.put("req_id", reqId)
...@@ -87,7 +86,7 @@ object AdMaxInterstitialUtils { ...@@ -87,7 +86,7 @@ object AdMaxInterstitialUtils {
val obj2 = JSONObject() val obj2 = JSONObject()
obj2.put("code", p1.code) obj2.put("code", p1.code)
obj2.put("reason", p1.message) obj2.put("reason", p1.message)
obj2.put("ad_unit", "interstitialAd") obj2.put("ad_unit", "interAd")
EventUtils.event("ad_show_error", ext = obj2) EventUtils.event("ad_show_error", ext = obj2)
} }
}) })
...@@ -95,18 +94,12 @@ object AdMaxInterstitialUtils { ...@@ -95,18 +94,12 @@ object AdMaxInterstitialUtils {
} }
} }
fun showInterstitialAd( fun showInterstitialAd(activity: Activity, onHidden: (() -> Unit)? = null) {
activity: Activity,
onHidden: (() -> Unit)? = null
) {
setListener(activity) setListener(activity)
if (activity.isFinishing || activity.isDestroyed) { if (activity.isFinishing || activity.isDestroyed) {
return return
} }
val obj1 = JSONObject()
obj1.put("ad_unit", "interAd")
EventUtils.event("ad_prepare_show", ext = obj1)
if (isAdExpired()) { if (isAdExpired()) {
val obj2 = JSONObject() val obj2 = JSONObject()
...@@ -123,10 +116,14 @@ object AdMaxInterstitialUtils { ...@@ -123,10 +116,14 @@ object AdMaxInterstitialUtils {
return return
} }
val obj1 = JSONObject()
obj1.put("ad_unit", "interAd")
EventUtils.event("ad_prepare_show", ext = obj1)
this.onHidden = onHidden this.onHidden = onHidden
if (interstitialAd?.isReady == true) { if (interstitialAd?.isReady == true) {
LogEx.logDebug(TAG, "isReady=true") LogEx.logDebug(TAG, "isReady=true")
interstitialAd?.showAd() interstitialAd?.showAd(activity)
} else { } else {
LogEx.logDebug(TAG, "onAdDisplayFailed") LogEx.logDebug(TAG, "onAdDisplayFailed")
val obj2 = JSONObject() val obj2 = JSONObject()
...@@ -155,7 +152,7 @@ object AdMaxInterstitialUtils { ...@@ -155,7 +152,7 @@ object AdMaxInterstitialUtils {
} }
loadingListener = { loadingListener = {
customDialog?.dismiss() customDialog?.dismiss()
interstitialAd?.showAd() interstitialAd?.showAd(activity)
loadingListener = null loadingListener = null
} }
......
...@@ -105,7 +105,9 @@ object AdMaxOpenUtils { ...@@ -105,7 +105,9 @@ object AdMaxOpenUtils {
LogEx.logDebug(TAG, "showAppOpenAd continue") LogEx.logDebug(TAG, "showAppOpenAd continue")
val obj1 = JSONObject()
obj1.put("ad_unit", "openAd")
EventUtils.event("ad_prepare_show", ext = obj1)
AdMaxOpenUtils.onHidden = onHidden AdMaxOpenUtils.onHidden = onHidden
if (appOpenAd?.isReady == true) { if (appOpenAd?.isReady == true) {
...@@ -116,9 +118,6 @@ object AdMaxOpenUtils { ...@@ -116,9 +118,6 @@ object AdMaxOpenUtils {
loadingListener = { loadingListener = {
LogEx.logDebug(TAG, "loadingListener callback") LogEx.logDebug(TAG, "loadingListener callback")
loaded?.invoke() loaded?.invoke()
val obj1 = JSONObject()
obj1.put("ad_unit", "openAd")
EventUtils.event("ad_prepare_show", ext = obj1)
appOpenAd?.showAd() appOpenAd?.showAd()
loadingListener = null loadingListener = null
} }
......
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