Commit 8175cb30 authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent ace01f89
......@@ -70,19 +70,19 @@ object BannerManager {
if (it.size > 0) {
val ad: TTNativeExpressAd = it[0]
bannerAd = ad
if (bannerAd != null && bannerAd!!.mediationManager != null && bannerAd!!.mediationManager.showEcpm != null) {
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE3
vo["cpmFen"] = bannerAd!!.mediationManager.showEcpm.ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
bannerAd?.setExpressInteractionListener(object :
TTNativeExpressAd.ExpressAdInteractionListener {
override fun onAdClicked(view: View?, type: Int) {
}
override fun onAdShow(view: View?, type: Int) {
if (bannerAd != null && bannerAd!!.mediationManager != null && bannerAd!!.mediationManager.showEcpm != null
&& bannerAd!!.mediationManager.showEcpm.ecpm != null) {
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE3
vo["cpmFen"] = bannerAd!!.mediationManager.showEcpm.ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
}
override fun onRenderFail(view: View?, msg: String?, code: Int) {
......
......@@ -150,7 +150,7 @@ class DrawExpressManager {
private fun showAd(ttFeedAd: TTFeedAd?) {
ttFeedAd?.let {
if (it.mediationManager != null && it.mediationManager.showEcpm != null) {
if (it.mediationManager != null && it.mediationManager.showEcpm != null&& it.mediationManager.showEcpm.ecpm != null) {
val ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE4
......
......@@ -143,7 +143,7 @@ class HomeDrawExpressManager {
private fun showAd(ttFeedAd: TTFeedAd?) {
ttFeedAd?.let {
if (it.mediationManager != null && it.mediationManager.showEcpm != null) {
if (it.mediationManager != null && it.mediationManager.showEcpm != null&& it.mediationManager.showEcpm.ecpm != null) {
val ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE4
......
......@@ -13,6 +13,7 @@ import com.duben.speedplayletu.utils.ForegroundOrBackground
import com.duben.speedplayletu.utils.LogUtil
import com.duben.speedplayletu.utils.UIUtils
import com.duben.speedplayletu.BuildConfig
private val TAG = MainExpressManager::class.java.simpleName
/**
......@@ -33,21 +34,21 @@ class MainExpressManager {
val adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity)
val adslot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_EXPRESS_CODE)
/**
* 注:
* 1:单位为px
* 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
.setCodeId(BuildConfig.GROMORE_EXPRESS_CODE)
/**
* 注:
* 1:单位为px
* 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
// .setImageAcceptedSize(
// UIUtils.getAdWidth2(MintsApplication.getContext()).toInt(),
//// UIUtils.dip2px(MintsApplication.getContext(), 192f)
// 0
// )
.setImageAcceptedSize(UIUtils.getScreenWidth(activity), 0)
.setAdCount(2)//请求广告数量为1到3条 (优先采用平台配置的数量)
.build()
.setImageAcceptedSize(UIUtils.getScreenWidth(activity), 0)
.setAdCount(2)//请求广告数量为1到3条 (优先采用平台配置的数量)
.build()
adNativeLoader.loadFeedAd(adslot, object : TTAdNative.FeedAdListener {
override fun onError(p0: Int, p1: String?) {
......@@ -56,8 +57,8 @@ class MainExpressManager {
override fun onFeedAdLoad(ads: MutableList<TTFeedAd>?) {
LogUtil.d(
TAG,
"gromore首页信息流--> 3、Gromore onAdLoaded"
TAG,
"gromore首页信息流--> 3、Gromore onAdLoaded"
)
ads?.let {
if (it.isEmpty()) {
......@@ -75,17 +76,11 @@ class MainExpressManager {
}
private fun showAd(
ttNativeAd: TTFeedAd?,
expressAdCallback: ExpressAdCallback
ttNativeAd: TTFeedAd?,
expressAdCallback: ExpressAdCallback
) {
ttNativeAd?.let {
if (it.mediationManager != null && it.mediationManager.showEcpm != null) {
val ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE1
vo["cpmFen"] = ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
if (it.mediationManager.isExpress) {
//--------------信息流模板广告渲染----------------
showExpressView(it, expressAdCallback)
......@@ -120,19 +115,19 @@ class MainExpressManager {
override fun onRenderSuccess(p0: View?, p1: Float, p2: Float, p3: Boolean) {
Log.i(TAG, "onRenderSuccess")
it.setDislikeCallback(ForegroundOrBackground.getTopActivity(),
object : TTAdDislike.DislikeInteractionCallback {
override fun onShow() {
Log.i(TAG, "express dislike 点击show")
}
object : TTAdDislike.DislikeInteractionCallback {
override fun onShow() {
Log.i(TAG, "express dislike 点击show")
}
override fun onSelected(position: Int, value: String?, enforce: Boolean) {
Log.i(TAG, "express 点击 $value")
}
override fun onSelected(position: Int, value: String?, enforce: Boolean) {
Log.i(TAG, "express 点击 $value")
}
override fun onCancel() {
Log.i(TAG, "express dislike 点击了取消")
}
})
override fun onCancel() {
Log.i(TAG, "express dislike 点击了取消")
}
})
it.adView?.let { view ->
if (view.parent != null) {
(view.parent as ViewGroup).removeView(view)
......@@ -154,6 +149,13 @@ class MainExpressManager {
override fun onAdShow() {
Log.i(TAG, "onAdShow")
Log.i(TAG, "ad mediaExtraInfo ${it.mediaExtraInfo}")
if (it.mediationManager != null && it.mediationManager.showEcpm != null && it.mediationManager.showEcpm.ecpm != null) {
val ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE1
vo["cpmFen"] = ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
}
})
......
......@@ -118,13 +118,6 @@ class MyExpressManager {
private fun showAd() {
mTTFeedAd?.let {
if (it.mediationManager != null && it.mediationManager.showEcpm != null) {
val ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE1
vo["cpmFen"] = ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
if (it.mediationManager.isExpress) {
//--------------信息流模板广告渲染----------------
showExpressView(it)
......@@ -226,6 +219,13 @@ class MyExpressManager {
override fun onAdShow() {
Log.i(TAG, "onAdShow")
Log.i(TAG, "ad mediaExtraInfo ${it.mediaExtraInfo}")
if (it.mediationManager != null && it.mediationManager.showEcpm != null && it.mediationManager.showEcpm.ecpm != null) {
val ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE1
vo["cpmFen"] = ecpm
TrackManager.getInstance().cmtEcpm(vo)
}
}
})
......
......@@ -163,7 +163,7 @@ object SplashManager {
LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ")
mTTSplashAd?.let {
if (it.mediationManager != null && it.mediationManager.showEcpm != null) {
if (it.mediationManager != null && it.mediationManager.showEcpm != null&& it.mediationManager.showEcpm.ecpm != null) {
val vo = HashMap<String, Any>()
vo["cpmFen"] = it.mediationManager.showEcpm.ecpm
vo["adType"] = Constant.GRO_MORE_ADTYPE0
......
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