Commit 2106f8cc authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 70e9872b
...@@ -7,6 +7,7 @@ import com.bytedance.sdk.openadsdk.* ...@@ -7,6 +7,7 @@ import com.bytedance.sdk.openadsdk.*
import com.bytedance.sdk.openadsdk.mediation.MediationConstant import com.bytedance.sdk.openadsdk.mediation.MediationConstant
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot
import com.bytedance.sdk.openadsdk.mediation.ad.MediationSplashRequestInfo import com.bytedance.sdk.openadsdk.mediation.ad.MediationSplashRequestInfo
import com.duben.xixiplayletu.BuildConfig
import com.duben.xixiplayletu.MintsApplication import com.duben.xixiplayletu.MintsApplication
import com.duben.xixiplayletu.ad.AdStatusListener import com.duben.xixiplayletu.ad.AdStatusListener
import com.duben.xixiplayletu.common.Constant import com.duben.xixiplayletu.common.Constant
...@@ -14,8 +15,8 @@ import com.duben.xixiplayletu.manager.TrackManager ...@@ -14,8 +15,8 @@ import com.duben.xixiplayletu.manager.TrackManager
import com.duben.xixiplayletu.utils.LogUtil import com.duben.xixiplayletu.utils.LogUtil
import com.duben.xixiplayletu.utils.UIUtils import com.duben.xixiplayletu.utils.UIUtils
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import java.util.HashMap
import com.duben.xixiplayletu.BuildConfig
/** /**
* 应用内-网赚开屏 * 应用内-网赚开屏
*/ */
...@@ -30,7 +31,7 @@ object SplashManager { ...@@ -30,7 +31,7 @@ object SplashManager {
private val TAG = SplashManager::class.java.simpleName private val TAG = SplashManager::class.java.simpleName
private var mTTSplashAd: TTSplashAd? = null private var mTTSplashAd: CSJSplashAd? = null
private const val AD_TIME_OUT = 5000 //开屏广告加载超时时间 private const val AD_TIME_OUT = 5000 //开屏广告加载超时时间
private var isLoadSuccess = 0 //0-加载失败/未加载 1-加载中 2-加载成功 private var isLoadSuccess = 0 //0-加载失败/未加载 1-加载中 2-加载成功
...@@ -61,21 +62,19 @@ object SplashManager { ...@@ -61,21 +62,19 @@ object SplashManager {
) )
.build() .build()
adNativeLoader.loadSplashAd(adslot, object : TTAdNative.SplashAdListener { adNativeLoader.loadSplashAd(adslot, object : TTAdNative.CSJSplashAdListener {
override fun onError(p0: Int, p1: String?) { override fun onSplashLoadSuccess(p0: CSJSplashAd?) {
}
override fun onSplashLoadFail(p0: CSJAdError?) {
LogUtil.e( LogUtil.e(
TAG, TAG,
"gromore 开屏广告--> 3、Gromore onSplashAdLoadFail adErrorCode=${p0} " + p1 "gromore 开屏广告--> 3、Gromore onSplashLoadFail adErrorCode=${p0?.code} "
) )
isLoadSuccess = 0 isLoadSuccess = 0
} }
override fun onTimeout() { override fun onSplashRenderSuccess(p0: CSJSplashAd?) {
LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onAdLoadTimeout")
isLoadSuccess = 0
}
override fun onSplashAdLoad(p0: TTSplashAd?) {
LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onSplashAdLoadSuccess") LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onSplashAdLoadSuccess")
LogUtil.d("SplashNewActivity-->", "333333--> ad show") LogUtil.d("SplashNewActivity-->", "333333--> ad show")
...@@ -83,7 +82,15 @@ object SplashManager { ...@@ -83,7 +82,15 @@ object SplashManager {
mTTSplashAd = p0 mTTSplashAd = p0
} }
}) override fun onSplashRenderFail(p0: CSJSplashAd?, p1: CSJAdError?) {
LogUtil.e(
TAG,
"gromore 开屏广告--> 3、Gromore onSplashRenderFail adErrorCode=${p1?.code} "
)
isLoadSuccess = 0
}
},AD_TIME_OUT)
} }
/** /**
...@@ -95,48 +102,7 @@ object SplashManager { ...@@ -95,48 +102,7 @@ object SplashManager {
if (mTTSplashAd != null && isLoadSuccess == 2) { if (mTTSplashAd != null && isLoadSuccess == 2) {
LogUtil.d(TAG, "gromore 开屏广告--> 准备调用show") LogUtil.d(TAG, "gromore 开屏广告--> 准备调用show")
mTTSplashAd?.let { mTTSplashAd?.let {
it.setSplashInteractionListener(adInteractionListener) it.setSplashAdListener(adInteractionListener)
// it.setSplashClickEyeListener(object: ISplashClickEyeListener {
// override fun onSplashClickEyeAnimationStart() {
// }
//
// override fun onSplashClickEyeAnimationFinish() {
// }
//
// override fun isSupportSplashClickEye(isSupport: Boolean): Boolean {
// var dp = it.splashClickEyeSizeToDp
//
// // 点睛相关处理
// val minWindowSizeFromSdk: IntArray = it.getSplashClickEyeSizeToDp()
// val flContent=it.splashView
// val params: ViewGroup.LayoutParams = flContent.getLayoutParams() as ViewGroup.LayoutParams
// params.height = UIUtils.dp2px(activity, minWindowSizeFromSdk[1].toFloat())
// params.width = UIUtils.dp2px(activity, minWindowSizeFromSdk[0].toFloat())
// flContent.setLayoutParams(params)
// flContent.setBackgroundResource(R.color.common_half_alpha)
// flContent.translationX = 200f
// flContent.translationY = 200f
// it.splashClickEyeAnimationFinish()
// return false
// }
// })
// it.setSplashCardListener(object : ISplashCardListener {
// override fun onSplashEyeReady() {
// it.splashClickEyeAnimationFinish()
// }
//
// override fun onSplashClickEyeClose() {
// adStatusListener?.adClose(null)
// }
//
// override fun setSupportSplashClickEye(isSupport: Boolean) {
// }
//
// override fun getActivity(): Activity {
// return activity
// }
//
// })
view.addView(it.splashView) view.addView(it.splashView)
} }
} else { } else {
...@@ -155,12 +121,8 @@ object SplashManager { ...@@ -155,12 +121,8 @@ object SplashManager {
*/ */
fun isSuccessStatus() = isLoadSuccess == 2 fun isSuccessStatus() = isLoadSuccess == 2
val adInteractionListener = object : TTSplashAd.AdInteractionListener { val adInteractionListener = object : CSJSplashAd.SplashAdListener {
override fun onAdClicked(p0: View?, p1: Int) { override fun onSplashAdShow(p0: CSJSplashAd?) {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdClicked ")
}
override fun onAdShow(p0: View?, p1: Int) {
isShowAd = true isShowAd = true
LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ") LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ")
...@@ -174,12 +136,12 @@ object SplashManager { ...@@ -174,12 +136,12 @@ object SplashManager {
} }
} }
override fun onAdSkip() { override fun onSplashAdClick(p0: CSJSplashAd?) {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdSkip ") LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdDismiss ")
adStatusListener?.adClose(null) adStatusListener?.adClose(null)
} }
override fun onAdTimeOver() { override fun onSplashAdClose(p0: CSJSplashAd?, p1: Int) {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdDismiss ") LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdDismiss ")
adStatusListener?.adClose(null) adStatusListener?.adClose(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