71 lines
2.2 KiB
Kotlin
71 lines
2.2 KiB
Kotlin
package com.gogame.minesweeper.ad
|
|
|
|
import android.app.Activity
|
|
import android.util.Log
|
|
import com.thinkup.core.api.AdError
|
|
import com.thinkup.core.api.TUAdInfo
|
|
import com.thinkup.interstitial.api.TUInterstitialListener
|
|
|
|
class AdInstShower {
|
|
private var mPlace: String
|
|
private var showListener: ShowListener? = null
|
|
private var activity: Activity? = null
|
|
|
|
constructor(activity: Activity, place: String, showListener: ShowListener?) {
|
|
this.mPlace = place
|
|
this.showListener = showListener
|
|
this.activity = activity
|
|
init()
|
|
}
|
|
|
|
constructor(place: String, showListener: ShowListener?) {
|
|
this.mPlace = place
|
|
this.showListener = showListener
|
|
init()
|
|
}
|
|
|
|
private fun init() {
|
|
val atInterstitial = InstAdCacheManager.instance.getAdCache(mPlace)
|
|
atInterstitial?.setAdListener(object : TUInterstitialListener {
|
|
override fun onInterstitialAdLoaded() {
|
|
|
|
}
|
|
|
|
override fun onInterstitialAdLoadFail(p0: AdError?) {
|
|
|
|
}
|
|
|
|
override fun onInterstitialAdClicked(p0: TUAdInfo?) {
|
|
showListener?.onAdClicked()
|
|
Log.d("ocean", "广告点击回调")
|
|
}
|
|
|
|
override fun onInterstitialAdShow(p0: TUAdInfo?) {
|
|
showListener?.onAdShown(p0)
|
|
Log.d("ocean", "广告展示回调")
|
|
}
|
|
|
|
override fun onInterstitialAdClose(p0: TUAdInfo?) {
|
|
showListener?.onAdClosed()
|
|
Log.d("ocean", "广告关闭回调")
|
|
}
|
|
|
|
override fun onInterstitialAdVideoStart(p0: TUAdInfo?) {
|
|
Log.d("ocean", "视频广告开始播放回调")
|
|
}
|
|
|
|
override fun onInterstitialAdVideoEnd(p0: TUAdInfo?) {
|
|
Log.d("ocean", "视频广告播放结束回调")
|
|
}
|
|
|
|
override fun onInterstitialAdVideoError(adError: AdError?) {
|
|
Log.d("ocean", "视频广告播放失败回调->${adError.toString()}")
|
|
showListener?.onAdShowFailed(AdShowFailed(adError.toString()))
|
|
}
|
|
|
|
})
|
|
if (atInterstitial?.isAdReady == true) {
|
|
atInterstitial.show(activity)
|
|
}
|
|
}
|
|
} |