Commit 8175cb30 authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent ace01f89
...@@ -70,19 +70,19 @@ object BannerManager { ...@@ -70,19 +70,19 @@ object BannerManager {
if (it.size > 0) { if (it.size > 0) {
val ad: TTNativeExpressAd = it[0] val ad: TTNativeExpressAd = it[0]
bannerAd = ad 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 : bannerAd?.setExpressInteractionListener(object :
TTNativeExpressAd.ExpressAdInteractionListener { TTNativeExpressAd.ExpressAdInteractionListener {
override fun onAdClicked(view: View?, type: Int) { override fun onAdClicked(view: View?, type: Int) {
} }
override fun onAdShow(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) { override fun onRenderFail(view: View?, msg: String?, code: Int) {
......
...@@ -150,7 +150,7 @@ class DrawExpressManager { ...@@ -150,7 +150,7 @@ class DrawExpressManager {
private fun showAd(ttFeedAd: TTFeedAd?) { private fun showAd(ttFeedAd: TTFeedAd?) {
ttFeedAd?.let { 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 ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>() val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE4 vo["adType"] = Constant.GRO_MORE_ADTYPE4
......
...@@ -143,7 +143,7 @@ class HomeDrawExpressManager { ...@@ -143,7 +143,7 @@ class HomeDrawExpressManager {
private fun showAd(ttFeedAd: TTFeedAd?) { private fun showAd(ttFeedAd: TTFeedAd?) {
ttFeedAd?.let { 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 ecpm = it.mediationManager.showEcpm.ecpm
val vo = HashMap<String, Any>() val vo = HashMap<String, Any>()
vo["adType"] = Constant.GRO_MORE_ADTYPE4 vo["adType"] = Constant.GRO_MORE_ADTYPE4
......
...@@ -55,13 +55,13 @@ class ExpressManager { ...@@ -55,13 +55,13 @@ class ExpressManager {
val isPreingOversped = TimeRender.isOverspedMin(adPreingTime, AdManager.AD_REQUEST_TIME_OUT) val isPreingOversped = TimeRender.isOverspedMin(adPreingTime, AdManager.AD_REQUEST_TIME_OUT)
LogUtil.d( LogUtil.d(
TAG, TAG,
"gromore信息流--> 1、进入预加载 isLoadSuccess=$isLoadSuccess isOversped=$isOversped isPreingOversped=$isPreingOversped" "gromore信息流--> 1、进入预加载 isLoadSuccess=$isLoadSuccess isOversped=$isOversped isPreingOversped=$isPreingOversped"
) )
if ((isLoadSuccess == 0 // 加载失败 if ((isLoadSuccess == 0 // 加载失败
|| adLoadTime > 0 && isOversped // 超过45分钟 || adLoadTime > 0 && isOversped // 超过45分钟
|| adPreingTime > 0 && isPreingOversped && isLoadSuccess == 1) // 预加载超时 || adPreingTime > 0 && isPreingOversped && isLoadSuccess == 1) // 预加载超时
) { ) {
LogUtil.d(TAG, "gromore信息流--> 2、执行预加载去了=$isLoadSuccess") LogUtil.d(TAG, "gromore信息流--> 2、执行预加载去了=$isLoadSuccess")
adPreingTime = System.currentTimeMillis() adPreingTime = System.currentTimeMillis()
...@@ -82,16 +82,16 @@ class ExpressManager { ...@@ -82,16 +82,16 @@ class ExpressManager {
val adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity) val adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity)
val adslot = AdSlot.Builder() val adslot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_EXPRESS_CODE) .setCodeId(BuildConfig.GROMORE_EXPRESS_CODE)
/** /**
* 注: * 注:
* 1:单位为px * 1:单位为px
* 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0 * 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数) * 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/ */
.setImageAcceptedSize(UIUtils.getAdWidth(MintsApplication.getContext()).toInt(), 0) .setImageAcceptedSize(UIUtils.getAdWidth(MintsApplication.getContext()).toInt(), 0)
.setAdCount(3)//请求广告数量为1到3条 (优先采用平台配置的数量) .setAdCount(3)//请求广告数量为1到3条 (优先采用平台配置的数量)
.build() .build()
adNativeLoader.loadFeedAd(adslot, object : TTAdNative.FeedAdListener { adNativeLoader.loadFeedAd(adslot, object : TTAdNative.FeedAdListener {
override fun onError(p0: Int, p1: String?) { override fun onError(p0: Int, p1: String?) {
...@@ -119,13 +119,6 @@ class ExpressManager { ...@@ -119,13 +119,6 @@ class ExpressManager {
private fun showAd() { private fun showAd() {
mTTFeedAd?.let { 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) { if (it.mediationManager.isExpress) {
//--------------信息流模板广告渲染---------------- //--------------信息流模板广告渲染----------------
showExpressView(it) showExpressView(it)
...@@ -145,8 +138,8 @@ class ExpressManager { ...@@ -145,8 +138,8 @@ class ExpressManager {
} }
view?.let { view?.let {
it.layoutParams = ViewGroup.LayoutParams( it.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT ViewGroup.LayoutParams.MATCH_PARENT
) )
frameLayout?.removeAllViews() frameLayout?.removeAllViews()
frameLayout?.addView(it) frameLayout?.addView(it)
...@@ -168,8 +161,8 @@ class ExpressManager { ...@@ -168,8 +161,8 @@ class ExpressManager {
if (isLoadSuccess == 2 && !isOversped) { if (isLoadSuccess == 2 && !isOversped) {
LogUtil.d( LogUtil.d(
TAG, TAG,
"gromore信息流--> 4、展示广告 LoadSuccess=$isLoadSuccess isOversped=$isOversped" "gromore信息流--> 4、展示广告 LoadSuccess=$isLoadSuccess isOversped=$isOversped"
) )
isLoadSuccess = 0 isLoadSuccess = 0
callback?.loadSuccess(frameLayout) callback?.loadSuccess(frameLayout)
...@@ -186,19 +179,19 @@ class ExpressManager { ...@@ -186,19 +179,19 @@ class ExpressManager {
override fun onRenderSuccess(p0: View?, p1: Float, p2: Float, p3: Boolean) { override fun onRenderSuccess(p0: View?, p1: Float, p2: Float, p3: Boolean) {
Log.i(TAG, "onRenderSuccess") Log.i(TAG, "onRenderSuccess")
it.setDislikeCallback(ForegroundOrBackground.getTopActivity(), it.setDislikeCallback(ForegroundOrBackground.getTopActivity(),
object : TTAdDislike.DislikeInteractionCallback { object : TTAdDislike.DislikeInteractionCallback {
override fun onShow() { override fun onShow() {
Log.i(TAG, "express dislike 点击show") Log.i(TAG, "express dislike 点击show")
} }
override fun onSelected(position: Int, value: String?, enforce: Boolean) { override fun onSelected(position: Int, value: String?, enforce: Boolean) {
Log.i(TAG, "express 点击 $value") Log.i(TAG, "express 点击 $value")
} }
override fun onCancel() { override fun onCancel() {
Log.i(TAG, "express dislike 点击了取消") Log.i(TAG, "express dislike 点击了取消")
} }
}) })
it.adView?.let { view -> it.adView?.let { view ->
if (view.parent != null) { if (view.parent != null) {
(view.parent as ViewGroup).removeView(view) (view.parent as ViewGroup).removeView(view)
...@@ -226,6 +219,14 @@ class ExpressManager { ...@@ -226,6 +219,14 @@ class ExpressManager {
override fun onAdShow() { override fun onAdShow() {
Log.i(TAG, "onAdShow") Log.i(TAG, "onAdShow")
Log.i(TAG, "ad mediaExtraInfo ${it.mediaExtraInfo}") 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)
}
} }
}) })
...@@ -249,62 +250,62 @@ class ExpressManager { ...@@ -249,62 +250,62 @@ class ExpressManager {
private fun getSmallAdView(parent: ViewGroup?): View? { private fun getSmallAdView(parent: ViewGroup?): View? {
val convertView = val convertView =
LayoutInflater.from(ForegroundOrBackground.getTopActivity()) LayoutInflater.from(ForegroundOrBackground.getTopActivity())
.inflate( .inflate(
R.layout.mediation_listitem_ad_small_pic, R.layout.mediation_listitem_ad_small_pic,
parent, parent,
false false
) )
val adViewHolder = SmallAdViewHolder() val adViewHolder = SmallAdViewHolder()
adViewHolder.mTitle = adViewHolder.mTitle =
convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView
adViewHolder.mSource = adViewHolder.mSource =
convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView
adViewHolder.mDescription = adViewHolder.mDescription =
convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView
adViewHolder.mSmallImage = adViewHolder.mSmallImage =
convertView.findViewById<View>(R.id.iv_listitem_image) as ImageView convertView.findViewById<View>(R.id.iv_listitem_image) as ImageView
adViewHolder.mIcon = adViewHolder.mIcon =
convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView
adViewHolder.mDislike = adViewHolder.mDislike =
convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView
adViewHolder.mCreativeButton = adViewHolder.mCreativeButton =
convertView.findViewById<View>(R.id.btn_listitem_creative) as Button convertView.findViewById<View>(R.id.btn_listitem_creative) as Button
adViewHolder.app_info = adViewHolder.app_info =
convertView.findViewById<LinearLayout>(R.id.app_info) convertView.findViewById<LinearLayout>(R.id.app_info)
adViewHolder.app_name = adViewHolder.app_name =
convertView.findViewById<TextView>(R.id.app_name) convertView.findViewById<TextView>(R.id.app_name)
adViewHolder.author_name = adViewHolder.author_name =
convertView.findViewById<TextView>(R.id.author_name) convertView.findViewById<TextView>(R.id.author_name)
adViewHolder.package_size = adViewHolder.package_size =
convertView.findViewById<TextView>(R.id.package_size) convertView.findViewById<TextView>(R.id.package_size)
adViewHolder.permissions_url = adViewHolder.permissions_url =
convertView.findViewById<TextView>(R.id.permissions_url) convertView.findViewById<TextView>(R.id.permissions_url)
adViewHolder.permissions_content = adViewHolder.permissions_content =
convertView.findViewById<TextView>(R.id.permissions_content) convertView.findViewById<TextView>(R.id.permissions_content)
adViewHolder.privacy_agreement = adViewHolder.privacy_agreement =
convertView.findViewById<TextView>(R.id.privacy_agreement) convertView.findViewById<TextView>(R.id.privacy_agreement)
adViewHolder.version_name = adViewHolder.version_name =
convertView.findViewById<TextView>(R.id.version_name) convertView.findViewById<TextView>(R.id.version_name)
val viewBinder = val viewBinder =
MediationViewBinder.Builder(R.layout.mediation_listitem_ad_small_pic) MediationViewBinder.Builder(R.layout.mediation_listitem_ad_small_pic)
.titleId(R.id.tv_listitem_ad_title) .titleId(R.id.tv_listitem_ad_title)
.sourceId(R.id.tv_listitem_ad_source).descriptionTextId( .sourceId(R.id.tv_listitem_ad_source).descriptionTextId(
R.id.tv_listitem_ad_desc R.id.tv_listitem_ad_desc
) )
.mainImageId(R.id.iv_listitem_image) .mainImageId(R.id.iv_listitem_image)
.logoLayoutId(R.id.tt_ad_logo) .logoLayoutId(R.id.tt_ad_logo)
.callToActionId(R.id.btn_listitem_creative) .callToActionId(R.id.btn_listitem_creative)
.iconImageId(R.id.iv_listitem_icon).build() .iconImageId(R.id.iv_listitem_icon).build()
adViewHolder.viewBinder = viewBinder adViewHolder.viewBinder = viewBinder
bindData(convertView, adViewHolder) bindData(convertView, adViewHolder)
if (mTTFeedAd?.imageList?.size != 0) { if (mTTFeedAd?.imageList?.size != 0) {
mTTFeedAd?.let { ttfeedad -> mTTFeedAd?.let { ttfeedad ->
ttfeedad.imageList[0]?.imageUrl?.let { ttfeedad.imageList[0]?.imageUrl?.let {
Glide.with(ForegroundOrBackground.getTopActivity()).load(it) Glide.with(ForegroundOrBackground.getTopActivity()).load(it)
.into(adViewHolder.mSmallImage!!) .into(adViewHolder.mSmallImage!!)
} }
} }
} }
...@@ -314,64 +315,64 @@ class ExpressManager { ...@@ -314,64 +315,64 @@ class ExpressManager {
private fun getLargeAdView(parent: ViewGroup?): View { private fun getLargeAdView(parent: ViewGroup?): View {
val adViewHolder = LargeAdViewHolder() val adViewHolder = LargeAdViewHolder()
var convertView: View = var convertView: View =
LayoutInflater.from(ForegroundOrBackground.getTopActivity()) LayoutInflater.from(ForegroundOrBackground.getTopActivity())
.inflate( .inflate(
R.layout.mediation_listitem_ad_large_pic, R.layout.mediation_listitem_ad_large_pic,
parent, parent,
false false
) )
adViewHolder.mTitle = adViewHolder.mTitle =
convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView
adViewHolder.mDescription = adViewHolder.mDescription =
convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView
adViewHolder.mSource = adViewHolder.mSource =
convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView
adViewHolder.mLargeImage = adViewHolder.mLargeImage =
convertView.findViewById<View>(R.id.iv_listitem_image) as ImageView convertView.findViewById<View>(R.id.iv_listitem_image) as ImageView
adViewHolder.mIcon = adViewHolder.mIcon =
convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView
adViewHolder.mDislike = adViewHolder.mDislike =
convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView
adViewHolder.mCreativeButton = adViewHolder.mCreativeButton =
convertView.findViewById<View>(R.id.btn_listitem_creative) as Button convertView.findViewById<View>(R.id.btn_listitem_creative) as Button
adViewHolder.mLogo = adViewHolder.mLogo =
convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型 convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
adViewHolder.app_info = adViewHolder.app_info =
convertView.findViewById<LinearLayout>(R.id.app_info) convertView.findViewById<LinearLayout>(R.id.app_info)
adViewHolder.app_name = adViewHolder.app_name =
convertView.findViewById<TextView>(R.id.app_name) convertView.findViewById<TextView>(R.id.app_name)
adViewHolder.author_name = adViewHolder.author_name =
convertView.findViewById<TextView>(R.id.author_name) convertView.findViewById<TextView>(R.id.author_name)
adViewHolder.package_size = adViewHolder.package_size =
convertView.findViewById<TextView>(R.id.package_size) convertView.findViewById<TextView>(R.id.package_size)
adViewHolder.permissions_url = adViewHolder.permissions_url =
convertView.findViewById<TextView>(R.id.permissions_url) convertView.findViewById<TextView>(R.id.permissions_url)
adViewHolder.permissions_content = adViewHolder.permissions_content =
convertView.findViewById<TextView>(R.id.permissions_content) convertView.findViewById<TextView>(R.id.permissions_content)
adViewHolder.privacy_agreement = adViewHolder.privacy_agreement =
convertView.findViewById<TextView>(R.id.privacy_agreement) convertView.findViewById<TextView>(R.id.privacy_agreement)
adViewHolder.version_name = adViewHolder.version_name =
convertView.findViewById<TextView>(R.id.version_name) convertView.findViewById<TextView>(R.id.version_name)
val viewBinder = val viewBinder =
MediationViewBinder.Builder(R.layout.mediation_listitem_ad_large_pic) MediationViewBinder.Builder(R.layout.mediation_listitem_ad_large_pic)
.titleId(R.id.tv_listitem_ad_title) .titleId(R.id.tv_listitem_ad_title)
.descriptionTextId(R.id.tv_listitem_ad_desc).sourceId( .descriptionTextId(R.id.tv_listitem_ad_desc).sourceId(
R.id.tv_listitem_ad_source R.id.tv_listitem_ad_source
) )
.mainImageId(R.id.iv_listitem_image) .mainImageId(R.id.iv_listitem_image)
.callToActionId(R.id.btn_listitem_creative) .callToActionId(R.id.btn_listitem_creative)
.logoLayoutId(R.id.tt_ad_logo) .logoLayoutId(R.id.tt_ad_logo)
.iconImageId(R.id.iv_listitem_icon).build() .iconImageId(R.id.iv_listitem_icon).build()
adViewHolder.viewBinder = viewBinder adViewHolder.viewBinder = viewBinder
bindData(convertView, adViewHolder) bindData(convertView, adViewHolder)
if (mTTFeedAd?.imageList?.size != 0) { if (mTTFeedAd?.imageList?.size != 0) {
mTTFeedAd?.let { ttfeedad -> mTTFeedAd?.let { ttfeedad ->
ttfeedad.imageList[0]?.imageUrl?.let { ttfeedad.imageList[0]?.imageUrl?.let {
Glide.with(ForegroundOrBackground.getTopActivity()).load(it) Glide.with(ForegroundOrBackground.getTopActivity()).load(it)
.into(adViewHolder.mLargeImage!!) .into(adViewHolder.mLargeImage!!)
} }
} }
} }
...@@ -381,64 +382,64 @@ class ExpressManager { ...@@ -381,64 +382,64 @@ class ExpressManager {
private fun getGroupAdView(parent: ViewGroup?): View? { private fun getGroupAdView(parent: ViewGroup?): View? {
val adViewHolder = GroupAdViewHolder() val adViewHolder = GroupAdViewHolder()
var convertView: View = LayoutInflater.from(ForegroundOrBackground.getTopActivity()) var convertView: View = LayoutInflater.from(ForegroundOrBackground.getTopActivity())
.inflate( .inflate(
R.layout.mediation_listitem_ad_group_pic, R.layout.mediation_listitem_ad_group_pic,
parent, parent,
false false
) )
adViewHolder.mTitle = adViewHolder.mTitle =
convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView
adViewHolder.mSource = adViewHolder.mSource =
convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView
adViewHolder.mDescription = adViewHolder.mDescription =
convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView
adViewHolder.mGroupImage1 = adViewHolder.mGroupImage1 =
convertView.findViewById<View>(R.id.iv_listitem_image1) as ImageView convertView.findViewById<View>(R.id.iv_listitem_image1) as ImageView
adViewHolder.mGroupImage2 = adViewHolder.mGroupImage2 =
convertView.findViewById<View>(R.id.iv_listitem_image2) as ImageView convertView.findViewById<View>(R.id.iv_listitem_image2) as ImageView
adViewHolder.mGroupImage3 = adViewHolder.mGroupImage3 =
convertView.findViewById<View>(R.id.iv_listitem_image3) as ImageView convertView.findViewById<View>(R.id.iv_listitem_image3) as ImageView
adViewHolder.mIcon = adViewHolder.mIcon =
convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView
adViewHolder.mDislike = adViewHolder.mDislike =
convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView
adViewHolder.mCreativeButton = adViewHolder.mCreativeButton =
convertView.findViewById<View>(R.id.btn_listitem_creative) as Button convertView.findViewById<View>(R.id.btn_listitem_creative) as Button
adViewHolder.mLogo = adViewHolder.mLogo =
convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型 convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
adViewHolder.app_info = adViewHolder.app_info =
convertView.findViewById<LinearLayout>(R.id.app_info) convertView.findViewById<LinearLayout>(R.id.app_info)
adViewHolder.app_name = adViewHolder.app_name =
convertView.findViewById<TextView>(R.id.app_name) convertView.findViewById<TextView>(R.id.app_name)
adViewHolder.author_name = adViewHolder.author_name =
convertView.findViewById<TextView>(R.id.author_name) convertView.findViewById<TextView>(R.id.author_name)
adViewHolder.package_size = adViewHolder.package_size =
convertView.findViewById<TextView>(R.id.package_size) convertView.findViewById<TextView>(R.id.package_size)
adViewHolder.permissions_url = adViewHolder.permissions_url =
convertView.findViewById<TextView>(R.id.permissions_url) convertView.findViewById<TextView>(R.id.permissions_url)
adViewHolder.permissions_content = adViewHolder.permissions_content =
convertView.findViewById<TextView>(R.id.permissions_content) convertView.findViewById<TextView>(R.id.permissions_content)
adViewHolder.privacy_agreement = adViewHolder.privacy_agreement =
convertView.findViewById<TextView>(R.id.privacy_agreement) convertView.findViewById<TextView>(R.id.privacy_agreement)
adViewHolder.version_name = adViewHolder.version_name =
convertView.findViewById<TextView>(R.id.version_name) convertView.findViewById<TextView>(R.id.version_name)
val viewBinder = val viewBinder =
MediationViewBinder.Builder(R.layout.mediation_listitem_ad_group_pic) MediationViewBinder.Builder(R.layout.mediation_listitem_ad_group_pic)
.titleId(R.id.tv_listitem_ad_title) .titleId(R.id.tv_listitem_ad_title)
.descriptionTextId(R.id.tv_listitem_ad_desc).sourceId( .descriptionTextId(R.id.tv_listitem_ad_desc).sourceId(
R.id.tv_listitem_ad_source R.id.tv_listitem_ad_source
) )
.mainImageId(R.id.iv_listitem_image1) .mainImageId(R.id.iv_listitem_image1)
.logoLayoutId(R.id.tt_ad_logo).callToActionId( .logoLayoutId(R.id.tt_ad_logo).callToActionId(
R.id.btn_listitem_creative R.id.btn_listitem_creative
).iconImageId(R.id.iv_listitem_icon) ).iconImageId(R.id.iv_listitem_icon)
.groupImage1Id(R.id.iv_listitem_image1).groupImage2Id( .groupImage1Id(R.id.iv_listitem_image1).groupImage2Id(
R.id.iv_listitem_image2 R.id.iv_listitem_image2
) )
.groupImage3Id(R.id.iv_listitem_image3).build() .groupImage3Id(R.id.iv_listitem_image3).build()
adViewHolder.viewBinder = viewBinder adViewHolder.viewBinder = viewBinder
bindData(convertView, adViewHolder) bindData(convertView, adViewHolder)
...@@ -448,15 +449,15 @@ class ExpressManager { ...@@ -448,15 +449,15 @@ class ExpressManager {
val image3: String? = mTTFeedAd?.imageList?.get(2)?.imageUrl val image3: String? = mTTFeedAd?.imageList?.get(2)?.imageUrl
if (image1 != null) { if (image1 != null) {
Glide.with(ForegroundOrBackground.getTopActivity()).load(image1) Glide.with(ForegroundOrBackground.getTopActivity()).load(image1)
.into(adViewHolder.mGroupImage1!!) .into(adViewHolder.mGroupImage1!!)
} }
if (image2 != null) { if (image2 != null) {
Glide.with(ForegroundOrBackground.getTopActivity()).load(image2) Glide.with(ForegroundOrBackground.getTopActivity()).load(image2)
.into(adViewHolder.mGroupImage2!!) .into(adViewHolder.mGroupImage2!!)
} }
if (image3 != null) { if (image3 != null) {
Glide.with(ForegroundOrBackground.getTopActivity()).load(image3) Glide.with(ForegroundOrBackground.getTopActivity()).load(image3)
.into(adViewHolder.mGroupImage3!!) .into(adViewHolder.mGroupImage3!!)
} }
} }
return convertView return convertView
...@@ -467,55 +468,55 @@ class ExpressManager { ...@@ -467,55 +468,55 @@ class ExpressManager {
var convertView: View? = null var convertView: View? = null
try { try {
convertView = LayoutInflater.from(ForegroundOrBackground.getTopActivity()) convertView = LayoutInflater.from(ForegroundOrBackground.getTopActivity())
.inflate( .inflate(
R.layout.mediation_listitem_ad_large_video, R.layout.mediation_listitem_ad_large_video,
parent, parent,
false false
) )
adViewHolder.mTitle = adViewHolder.mTitle =
convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView
adViewHolder.mDescription = adViewHolder.mDescription =
convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView
adViewHolder.mSource = adViewHolder.mSource =
convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView
adViewHolder.videoView = adViewHolder.videoView =
convertView.findViewById<View>(R.id.iv_listitem_video) as FrameLayout convertView.findViewById<View>(R.id.iv_listitem_video) as FrameLayout
adViewHolder.mIcon = adViewHolder.mIcon =
convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView
adViewHolder.mDislike = adViewHolder.mDislike =
convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView
adViewHolder.mCreativeButton = adViewHolder.mCreativeButton =
convertView.findViewById<View>(R.id.btn_listitem_creative) as Button convertView.findViewById<View>(R.id.btn_listitem_creative) as Button
adViewHolder.mLogo = adViewHolder.mLogo =
convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型 convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
adViewHolder.app_info = adViewHolder.app_info =
convertView.findViewById<LinearLayout>(R.id.app_info) convertView.findViewById<LinearLayout>(R.id.app_info)
adViewHolder.app_name = adViewHolder.app_name =
convertView.findViewById<TextView>(R.id.app_name) convertView.findViewById<TextView>(R.id.app_name)
adViewHolder.author_name = adViewHolder.author_name =
convertView.findViewById<TextView>(R.id.author_name) convertView.findViewById<TextView>(R.id.author_name)
adViewHolder.package_size = adViewHolder.package_size =
convertView.findViewById<TextView>(R.id.package_size) convertView.findViewById<TextView>(R.id.package_size)
adViewHolder.permissions_url = adViewHolder.permissions_url =
convertView.findViewById<TextView>(R.id.permissions_url) convertView.findViewById<TextView>(R.id.permissions_url)
adViewHolder.permissions_content = adViewHolder.permissions_content =
convertView.findViewById<TextView>(R.id.permissions_content) convertView.findViewById<TextView>(R.id.permissions_content)
adViewHolder.privacy_agreement = adViewHolder.privacy_agreement =
convertView.findViewById<TextView>(R.id.privacy_agreement) convertView.findViewById<TextView>(R.id.privacy_agreement)
adViewHolder.version_name = adViewHolder.version_name =
convertView.findViewById<TextView>(R.id.version_name) convertView.findViewById<TextView>(R.id.version_name)
val viewBinder = val viewBinder =
MediationViewBinder.Builder(R.layout.mediation_listitem_ad_large_video) MediationViewBinder.Builder(R.layout.mediation_listitem_ad_large_video)
.titleId(R.id.tv_listitem_ad_title) .titleId(R.id.tv_listitem_ad_title)
.sourceId(R.id.tv_listitem_ad_source) .sourceId(R.id.tv_listitem_ad_source)
.descriptionTextId(R.id.tv_listitem_ad_desc) .descriptionTextId(R.id.tv_listitem_ad_desc)
.mediaViewIdId( .mediaViewIdId(
R.id.iv_listitem_video R.id.iv_listitem_video
) )
.callToActionId(R.id.btn_listitem_creative) .callToActionId(R.id.btn_listitem_creative)
.logoLayoutId(R.id.tt_ad_logo) .logoLayoutId(R.id.tt_ad_logo)
.iconImageId(R.id.iv_listitem_icon).build() .iconImageId(R.id.iv_listitem_icon).build()
adViewHolder.viewBinder = viewBinder adViewHolder.viewBinder = viewBinder
// 如果自己有需求进行视频播放操作,则按如下步骤进行。注意:不是所有adn都支持,因此需要进行判空操作。 // 如果自己有需求进行视频播放操作,则按如下步骤进行。注意:不是所有adn都支持,因此需要进行判空操作。
...@@ -565,36 +566,36 @@ class ExpressManager { ...@@ -565,36 +566,36 @@ class ExpressManager {
} }
override fun onDownloadActive( override fun onDownloadActive(
totalBytes: Long, totalBytes: Long,
currBytes: Long, currBytes: Long,
fileName: String?, fileName: String?,
appName: String? appName: String?
) { ) {
Log.i(TAG, "onDownloadActive") Log.i(TAG, "onDownloadActive")
} }
override fun onDownloadPaused( override fun onDownloadPaused(
totalBytes: Long, totalBytes: Long,
currBytes: Long, currBytes: Long,
fileName: String?, fileName: String?,
appName: String? appName: String?
) { ) {
Log.i(TAG, "onDownloadPaused") Log.i(TAG, "onDownloadPaused")
} }
override fun onDownloadFailed( override fun onDownloadFailed(
totalBytes: Long, totalBytes: Long,
currBytes: Long, currBytes: Long,
fileName: String?, fileName: String?,
appName: String? appName: String?
) { ) {
Log.i(TAG, "onDownloadFailed") Log.i(TAG, "onDownloadFailed")
} }
override fun onDownloadFinished( override fun onDownloadFinished(
totalBytes: Long, totalBytes: Long,
fileName: String?, fileName: String?,
appName: String? appName: String?
) { ) {
Log.i(TAG, "onDownloadFinished") Log.i(TAG, "onDownloadFinished")
} }
...@@ -625,9 +626,9 @@ class ExpressManager { ...@@ -625,9 +626,9 @@ class ExpressManager {
mVideoView?.setOnErrorListener { mp, what, extra -> mVideoView?.setOnErrorListener { mp, what, extra ->
if (customVideoReporter != null) { if (customVideoReporter != null) {
customVideoReporter?.reportVideoError( customVideoReporter?.reportVideoError(
mVideoView!!.currentPosition.toLong(), mVideoView!!.currentPosition.toLong(),
what, what,
extra extra
) )
} }
false false
...@@ -644,63 +645,63 @@ class ExpressManager { ...@@ -644,63 +645,63 @@ class ExpressManager {
private fun getVerticalAdView(parent: ViewGroup?): View? { private fun getVerticalAdView(parent: ViewGroup?): View? {
val adViewHolder = VerticalAdViewHolder() val adViewHolder = VerticalAdViewHolder()
var convertView = LayoutInflater.from(ForegroundOrBackground.getTopActivity()) var convertView = LayoutInflater.from(ForegroundOrBackground.getTopActivity())
.inflate( .inflate(
R.layout.mediation_listitem_ad_vertical_pic, R.layout.mediation_listitem_ad_vertical_pic,
parent, parent,
false false
) )
adViewHolder.mTitle = adViewHolder.mTitle =
convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_title) as TextView
adViewHolder.mSource = adViewHolder.mSource =
convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView convertView.findViewById<View>(R.id.tv_listitem_ad_source) as TextView
adViewHolder.mDescription = adViewHolder.mDescription =
convertView?.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView convertView?.findViewById<View>(R.id.tv_listitem_ad_desc) as TextView
adViewHolder.mVerticalImage = adViewHolder.mVerticalImage =
convertView.findViewById<ImageView>(R.id.iv_listitem_image) convertView.findViewById<ImageView>(R.id.iv_listitem_image)
adViewHolder.mIcon = adViewHolder.mIcon =
convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView convertView.findViewById<View>(R.id.iv_listitem_icon) as ImageView
adViewHolder.mDislike = adViewHolder.mDislike =
convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView convertView.findViewById<View>(R.id.iv_listitem_dislike) as ImageView
adViewHolder.mCreativeButton = adViewHolder.mCreativeButton =
convertView.findViewById<View>(R.id.btn_listitem_creative) as Button convertView.findViewById<View>(R.id.btn_listitem_creative) as Button
// adViewHolder.mLogo = // adViewHolder.mLogo =
// convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型 // convertView.findViewById<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
adViewHolder.app_info = adViewHolder.app_info =
convertView.findViewById<LinearLayout>(R.id.app_info) convertView.findViewById<LinearLayout>(R.id.app_info)
adViewHolder.app_name = adViewHolder.app_name =
convertView.findViewById<TextView>(R.id.app_name) convertView.findViewById<TextView>(R.id.app_name)
adViewHolder.author_name = adViewHolder.author_name =
convertView.findViewById<TextView>(R.id.author_name) convertView.findViewById<TextView>(R.id.author_name)
adViewHolder.package_size = adViewHolder.package_size =
convertView.findViewById<TextView>(R.id.package_size) convertView.findViewById<TextView>(R.id.package_size)
adViewHolder.permissions_url = adViewHolder.permissions_url =
convertView.findViewById<TextView>(R.id.permissions_url) convertView.findViewById<TextView>(R.id.permissions_url)
adViewHolder.permissions_content = adViewHolder.permissions_content =
convertView.findViewById<TextView>(R.id.permissions_content) convertView.findViewById<TextView>(R.id.permissions_content)
adViewHolder.privacy_agreement = adViewHolder.privacy_agreement =
convertView.findViewById<TextView>(R.id.privacy_agreement) convertView.findViewById<TextView>(R.id.privacy_agreement)
adViewHolder.version_name = adViewHolder.version_name =
convertView.findViewById<TextView>(R.id.version_name) convertView.findViewById<TextView>(R.id.version_name)
val viewBinder = val viewBinder =
MediationViewBinder.Builder(R.layout.mediation_listitem_ad_vertical_pic) MediationViewBinder.Builder(R.layout.mediation_listitem_ad_vertical_pic)
.titleId(R.id.tv_listitem_ad_title) .titleId(R.id.tv_listitem_ad_title)
.descriptionTextId(R.id.tv_listitem_ad_desc) .descriptionTextId(R.id.tv_listitem_ad_desc)
.mainImageId(R.id.iv_listitem_image) .mainImageId(R.id.iv_listitem_image)
.iconImageId(R.id.iv_listitem_icon) .iconImageId(R.id.iv_listitem_icon)
.callToActionId(R.id.btn_listitem_creative) .callToActionId(R.id.btn_listitem_creative)
.sourceId(R.id.tv_listitem_ad_source) .sourceId(R.id.tv_listitem_ad_source)
.logoLayoutId(R.id.tt_ad_logo) //logoView 建议传入GroupView类型 .logoLayoutId(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
.build() .build()
adViewHolder.viewBinder = viewBinder adViewHolder.viewBinder = viewBinder
bindData(convertView, adViewHolder) bindData(convertView, adViewHolder)
if (mTTFeedAd?.imageList?.size != 0) { if (mTTFeedAd?.imageList?.size != 0) {
mTTFeedAd?.let { ttfeedad -> mTTFeedAd?.let { ttfeedad ->
ttfeedad.imageList[0]?.imageUrl?.let { ttfeedad.imageList[0]?.imageUrl?.let {
Glide.with(ForegroundOrBackground.getTopActivity()).load(it) Glide.with(ForegroundOrBackground.getTopActivity()).load(it)
.into(adViewHolder.mVerticalImage!!) .into(adViewHolder.mVerticalImage!!)
} }
} }
} }
...@@ -711,13 +712,13 @@ class ExpressManager { ...@@ -711,13 +712,13 @@ class ExpressManager {
mTTFeedAd?.let { mTTFeedAd?.let {
if (it.mediationManager?.hasDislike() == true) { if (it.mediationManager?.hasDislike() == true) {
val ttAdDislike: TTAdDislike = val ttAdDislike: TTAdDislike =
it.getDislikeDialog(ForegroundOrBackground.getTopActivity()) it.getDislikeDialog(ForegroundOrBackground.getTopActivity())
adViewHolder.mDislike?.visibility = View.VISIBLE adViewHolder.mDislike?.visibility = View.VISIBLE
adViewHolder.mDislike?.setOnClickListener(View.OnClickListener { adViewHolder.mDislike?.setOnClickListener(View.OnClickListener {
//使用接口来展示 //使用接口来展示
ttAdDislike.showDislikeDialog() ttAdDislike.showDislikeDialog()
ttAdDislike.setDislikeInteractionCallback(object : ttAdDislike.setDislikeInteractionCallback(object :
TTAdDislike.DislikeInteractionCallback { TTAdDislike.DislikeInteractionCallback {
override fun onShow() { override fun onShow() {
Log.i(TAG, "dislike 点击show") Log.i(TAG, "dislike 点击show")
} }
...@@ -768,28 +769,28 @@ class ExpressManager { ...@@ -768,28 +769,28 @@ class ExpressManager {
creativeViewList.add(adViewHolder.mCreativeButton) creativeViewList.add(adViewHolder.mCreativeButton)
//重要! 这个涉及到广告计费,必须正确调用。**** convertView必须是com.bytedance.msdk.api.format.TTNativeAdView **** //重要! 这个涉及到广告计费,必须正确调用。**** convertView必须是com.bytedance.msdk.api.format.TTNativeAdView ****
it.registerViewForInteraction( it.registerViewForInteraction(
ForegroundOrBackground.getTopActivity(), ForegroundOrBackground.getTopActivity(),
convertView as ViewGroup, convertView as ViewGroup,
clickViewList, clickViewList,
creativeViewList, creativeViewList,
null, null,
object : TTNativeAd.AdInteractionListener { object : TTNativeAd.AdInteractionListener {
override fun onAdClicked(view: View?, ad: TTNativeAd?) { override fun onAdClicked(view: View?, ad: TTNativeAd?) {
Log.i(TAG, "onAdClicked") Log.i(TAG, "onAdClicked")
} }
override fun onAdCreativeClick(view: View?, ad: TTNativeAd?) { override fun onAdCreativeClick(view: View?, ad: TTNativeAd?) {
Log.i(TAG, "onAdCreativeClick") Log.i(TAG, "onAdCreativeClick")
} }
override fun onAdShow(ad: TTNativeAd?) { override fun onAdShow(ad: TTNativeAd?) {
Log.i(TAG, "onAdShow") Log.i(TAG, "onAdShow")
ad?.let { ad?.let {
// PrintUtil.printShowInfo(ad.mediationManager) // PrintUtil.printShowInfo(ad.mediationManager)
}
} }
} },
}, adViewHolder.viewBinder
adViewHolder.viewBinder
) )
adViewHolder.mTitle?.text = it.title //title为广告的简单信息提示 adViewHolder.mTitle?.text = it.title //title为广告的简单信息提示
...@@ -797,12 +798,12 @@ class ExpressManager { ...@@ -797,12 +798,12 @@ class ExpressManager {
adViewHolder.mDescription?.text = it.description //description为广告的较长的说明 adViewHolder.mDescription?.text = it.description //description为广告的较长的说明
adViewHolder.mSource?.text = adViewHolder.mSource?.text =
if (TextUtils.isEmpty(it.source)) "广告来源" else it.source if (TextUtils.isEmpty(it.source)) "广告来源" else it.source
val icon: TTImage? = it.icon val icon: TTImage? = it.icon
if (icon != null) { if (icon != null) {
Glide.with(ForegroundOrBackground.getTopActivity()).load(icon.imageUrl) Glide.with(ForegroundOrBackground.getTopActivity()).load(icon.imageUrl)
.into(adViewHolder.mIcon!!) .into(adViewHolder.mIcon!!)
} }
val adCreativeButton = adViewHolder.mCreativeButton val adCreativeButton = adViewHolder.mCreativeButton
when (it.interactionType) { when (it.interactionType) {
...@@ -840,7 +841,7 @@ class ExpressManager { ...@@ -840,7 +841,7 @@ class ExpressManager {
adViewHolder.privacy_agreement?.text = "隐私url:" + appInfo.privacyUrl adViewHolder.privacy_agreement?.text = "隐私url:" + appInfo.privacyUrl
adViewHolder.version_name?.text = "版本号:" + appInfo.appVersion adViewHolder.version_name?.text = "版本号:" + appInfo.appVersion
adViewHolder.permissions_content!!.text = adViewHolder.permissions_content!!.text =
"权限内容:" + getPermissionsContent(appInfo.permissionsMap) "权限内容:" + getPermissionsContent(appInfo.permissionsMap)
} }
} }
...@@ -852,7 +853,7 @@ class ExpressManager { ...@@ -852,7 +853,7 @@ class ExpressManager {
val keyList = permissionsMap.keys val keyList = permissionsMap.keys
for (s in keyList) { for (s in keyList) {
stringBuffer.append( stringBuffer.append(
"""$s : ${permissionsMap[s]} """ """$s : ${permissionsMap[s]} """
) )
} }
return stringBuffer.toString() return stringBuffer.toString()
......
...@@ -13,6 +13,7 @@ import com.duben.speedplayletu.utils.ForegroundOrBackground ...@@ -13,6 +13,7 @@ import com.duben.speedplayletu.utils.ForegroundOrBackground
import com.duben.speedplayletu.utils.LogUtil import com.duben.speedplayletu.utils.LogUtil
import com.duben.speedplayletu.utils.UIUtils import com.duben.speedplayletu.utils.UIUtils
import com.duben.speedplayletu.BuildConfig import com.duben.speedplayletu.BuildConfig
private val TAG = MainExpressManager::class.java.simpleName private val TAG = MainExpressManager::class.java.simpleName
/** /**
...@@ -33,21 +34,21 @@ class MainExpressManager { ...@@ -33,21 +34,21 @@ class MainExpressManager {
val adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity) val adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity)
val adslot = AdSlot.Builder() val adslot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_EXPRESS_CODE) .setCodeId(BuildConfig.GROMORE_EXPRESS_CODE)
/** /**
* 注: * 注:
* 1:单位为px * 1:单位为px
* 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0 * 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数) * 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/ */
// .setImageAcceptedSize( // .setImageAcceptedSize(
// UIUtils.getAdWidth2(MintsApplication.getContext()).toInt(), // UIUtils.getAdWidth2(MintsApplication.getContext()).toInt(),
//// UIUtils.dip2px(MintsApplication.getContext(), 192f) //// UIUtils.dip2px(MintsApplication.getContext(), 192f)
// 0 // 0
// ) // )
.setImageAcceptedSize(UIUtils.getScreenWidth(activity), 0) .setImageAcceptedSize(UIUtils.getScreenWidth(activity), 0)
.setAdCount(2)//请求广告数量为1到3条 (优先采用平台配置的数量) .setAdCount(2)//请求广告数量为1到3条 (优先采用平台配置的数量)
.build() .build()
adNativeLoader.loadFeedAd(adslot, object : TTAdNative.FeedAdListener { adNativeLoader.loadFeedAd(adslot, object : TTAdNative.FeedAdListener {
override fun onError(p0: Int, p1: String?) { override fun onError(p0: Int, p1: String?) {
...@@ -56,8 +57,8 @@ class MainExpressManager { ...@@ -56,8 +57,8 @@ class MainExpressManager {
override fun onFeedAdLoad(ads: MutableList<TTFeedAd>?) { override fun onFeedAdLoad(ads: MutableList<TTFeedAd>?) {
LogUtil.d( LogUtil.d(
TAG, TAG,
"gromore首页信息流--> 3、Gromore onAdLoaded" "gromore首页信息流--> 3、Gromore onAdLoaded"
) )
ads?.let { ads?.let {
if (it.isEmpty()) { if (it.isEmpty()) {
...@@ -75,17 +76,11 @@ class MainExpressManager { ...@@ -75,17 +76,11 @@ class MainExpressManager {
} }
private fun showAd( private fun showAd(
ttNativeAd: TTFeedAd?, ttNativeAd: TTFeedAd?,
expressAdCallback: ExpressAdCallback expressAdCallback: ExpressAdCallback
) { ) {
ttNativeAd?.let { 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) { if (it.mediationManager.isExpress) {
//--------------信息流模板广告渲染---------------- //--------------信息流模板广告渲染----------------
showExpressView(it, expressAdCallback) showExpressView(it, expressAdCallback)
...@@ -120,19 +115,19 @@ class MainExpressManager { ...@@ -120,19 +115,19 @@ class MainExpressManager {
override fun onRenderSuccess(p0: View?, p1: Float, p2: Float, p3: Boolean) { override fun onRenderSuccess(p0: View?, p1: Float, p2: Float, p3: Boolean) {
Log.i(TAG, "onRenderSuccess") Log.i(TAG, "onRenderSuccess")
it.setDislikeCallback(ForegroundOrBackground.getTopActivity(), it.setDislikeCallback(ForegroundOrBackground.getTopActivity(),
object : TTAdDislike.DislikeInteractionCallback { object : TTAdDislike.DislikeInteractionCallback {
override fun onShow() { override fun onShow() {
Log.i(TAG, "express dislike 点击show") Log.i(TAG, "express dislike 点击show")
} }
override fun onSelected(position: Int, value: String?, enforce: Boolean) { override fun onSelected(position: Int, value: String?, enforce: Boolean) {
Log.i(TAG, "express 点击 $value") Log.i(TAG, "express 点击 $value")
} }
override fun onCancel() { override fun onCancel() {
Log.i(TAG, "express dislike 点击了取消") Log.i(TAG, "express dislike 点击了取消")
} }
}) })
it.adView?.let { view -> it.adView?.let { view ->
if (view.parent != null) { if (view.parent != null) {
(view.parent as ViewGroup).removeView(view) (view.parent as ViewGroup).removeView(view)
...@@ -154,6 +149,13 @@ class MainExpressManager { ...@@ -154,6 +149,13 @@ class MainExpressManager {
override fun onAdShow() { override fun onAdShow() {
Log.i(TAG, "onAdShow") Log.i(TAG, "onAdShow")
Log.i(TAG, "ad mediaExtraInfo ${it.mediaExtraInfo}") 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 { ...@@ -118,13 +118,6 @@ class MyExpressManager {
private fun showAd() { private fun showAd() {
mTTFeedAd?.let { 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) { if (it.mediationManager.isExpress) {
//--------------信息流模板广告渲染---------------- //--------------信息流模板广告渲染----------------
showExpressView(it) showExpressView(it)
...@@ -226,6 +219,13 @@ class MyExpressManager { ...@@ -226,6 +219,13 @@ class MyExpressManager {
override fun onAdShow() { override fun onAdShow() {
Log.i(TAG, "onAdShow") Log.i(TAG, "onAdShow")
Log.i(TAG, "ad mediaExtraInfo ${it.mediaExtraInfo}") 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 { ...@@ -163,7 +163,7 @@ object SplashManager {
LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ") LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ")
mTTSplashAd?.let { 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>() val vo = HashMap<String, Any>()
vo["cpmFen"] = it.mediationManager.showEcpm.ecpm vo["cpmFen"] = it.mediationManager.showEcpm.ecpm
vo["adType"] = Constant.GRO_MORE_ADTYPE0 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