Commit d44b5e48 authored by maxiaoliang's avatar maxiaoliang

修改广告代码

parent 19c437cc
......@@ -397,7 +397,7 @@
</activity>
<activity
android:name=".activity.SplashBackgroundActivity"
android:launchMode="singleTop">
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
......
......@@ -8,20 +8,11 @@ import com.zx.ad.AdManager
import com.zx.ad.callback.SplashAdListener
import com.zxbw.modulemain.R
import com.zxbw.modulemain.contract.SplashContract
import com.zxbw.modulemain.presenter.SplashPresenter
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.router.RounterApi
import com.zxhl.cms.router.RounterBus
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.widget.CenterDialog
import kotlinx.android.synthetic.main.activity_splash.*
class SplashBackgroundActivity: BaseActivity() {
......@@ -29,16 +20,12 @@ class SplashBackgroundActivity: BaseActivity() {
override fun onClick(v: View?) {
}
override fun layoutID(): Int = R.layout.activity_splash
override fun layoutID(): Int = R.layout.activity_layout_splash_backound
private var mPresenter: SplashContract.Presenter? = null
override fun init() {
if (!isTaskRoot) {
finish()
return
}
initSplashAd()
......@@ -53,11 +40,10 @@ class SplashBackgroundActivity: BaseActivity() {
}
override fun onAdSkip() {
finish()
}
override fun onError(errorMsg: String?) {
Log.e("MXL","MSG:"+errorMsg)
jumpMainPage()
}
})
......@@ -78,18 +64,5 @@ class SplashBackgroundActivity: BaseActivity() {
private var isPause = false
override fun onResume() {
super.onResume()
MobclickAgent.onResume(this)
}
override fun onPause() {
super.onPause()
MobclickAgent.onPause(this)
}
}
\ No newline at end of file
......@@ -130,7 +130,7 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
if (isInitial && isVisible) {
UserDataUtils.updateUserInfo(this)
getAds()
// showIntriAd()
// showIntriAd()
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小象省钱黑钻卡"
android:textColor="#FFD9C5A7"
android:layout_marginTop="15dp"
android:textSize="23sp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="一 张 巨 省 钱 的 黑 钻 卡"
android:textSize="10sp"
android:textColor="#FFD7CDC1"/>
</LinearLayout>
<FrameLayout
android:id="@+id/id_splash_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
......@@ -34,8 +34,8 @@ object CSJAdManager {
}
fun adInit(context: Context, appId: String, initCallback: TTAdSdk.InitCallback?) {
TTAdManagerHolder.init(context, appId, initCallback)
// TTAdManagerHolder.init(context, "5001121")
TTAdManagerHolder.init(context, appId, initCallback)
// TTAdManagerHolder.init(context, "5335826", initCallback)
}
private var splashAd: TTSplashAd? = null
......@@ -46,6 +46,7 @@ object CSJAdManager {
fun loadSplashAd(context: Context, entity: NewsEntity, loadCallBack: AdLoadCallBack) {
//本次针对穿山甲处理,当加入其它平台时需要测试未初始化的情况下,是否有error回调
if (!TTAdSdk.isInitSuccess()) {
Log.e("MXL", "TTAdSdk.isInitSuccess")
adInit(context, entity.codeAppId, object : TTAdSdk.InitCallback {
override fun success() {
loadSplashAd2(context, entity, loadCallBack)
......@@ -143,27 +144,34 @@ object CSJAdManager {
})
}
private var innterstitialAd: TTInteractionAd? = null
private var innterstitialAd: TTFullScreenVideoAd? = null
//加载插屏广告
fun loadIntertialAd(context: Context, entity: NewsEntity, loadCallBack: AdLoadCallBack) {
mTTAdNative = TTAdManagerHolder.get().createAdNative(context)
// val adSlot = AdSlot.Builder()
// .setCodeId("949814576")
// .setSupportDeepLink(true)
// .setAdCount(2) //请求广告数量为1到3条
// // .setExpressViewAcceptedSize(300f, 300f) //期望模板广告view的size,单位dp
// .setAdLoadType(TTAdLoadType.LOAD) //推荐使用,用于标注此次的广告请求用途为预加载(当做缓存)还是实时加载,方便后续为开发者优化相关策略
// .build()
//step4:创建广告请求参数AdSlot,具体参数含义参考文档
val adSlot = AdSlot.Builder()
.setCodeId(entity.codeId)
.setSupportDeepLink(true)
.setAdCount(1) //请求广告数量为1到3条
//.setExpressViewAcceptedSize(300f, 300f) //期望模板广告view的size,单位dp
// .setAdLoadType(TTAdLoadType.LOAD) //推荐使用,用于标注此次的广告请求用途为预加载(当做缓存)还是实时加载,方便后续为开发者优化相关策略
.setCodeId(entity.codeId) //此次加载广告的用途是实时加载,当用来作为缓存时,请使用:TTAdLoadType.PRELOAD
.setAdLoadType(TTAdLoadType.LOAD)
.build()
mTTAdNative?.loadFullScreenVideoAd(adSlot,object :TTAdNative.FullScreenVideoAdListener{
mTTAdNative?.loadFullScreenVideoAd(adSlot, object : TTAdNative.FullScreenVideoAdListener {
override fun onError(p0: Int, p1: String?) {
AdEventUtils.onEventPullFail(entity)
Log.e("MXL", "CSJ Interaction Ad Fail" + p1)
loadCallBack.OnAdLoadFail("CSJ Interaction error p0:${p0} p1:${p1}")
}
override fun onFullScreenVideoAdLoad(p0: TTFullScreenVideoAd?) {
override fun onFullScreenVideoAdLoad(ad: TTFullScreenVideoAd?) {
AdEventUtils.onEventPullSuccess(entity)
// innterstitialAd=p0
innterstitialAd = ad
loadCallBack.OnAdLoadSuccess(ADType.PLATFORM_AD_TT, entity)
}
......@@ -175,29 +183,58 @@ object CSJAdManager {
}
})
}
fun showIntereiAd(context: Activity,entity: NewsEntity,listener: InterertionAdListener){
if(innterstitialAd==null){
fun showIntereiAd(context: Activity, entity: NewsEntity, listener: InterertionAdListener) {
if (innterstitialAd == null) {
listener.onAdError("CSJ innterstitialAd Is Null")
return
}
if (!context.isFinishing) {
innterstitialAd?.setAdInteractionListener(object :TTInteractionAd.AdInteractionListener{
override fun onAdClicked() {
}
//step6:在获取到广告后展示
//该方法直接展示广告
//mttFullVideoAd.showFullScreenVideoAd(FullScreenVideoActivity.this);
override fun onAdShow() {
listener.onAdShow()
}
innterstitialAd?.showFullScreenVideoAd(context)
innterstitialAd = null
innterstitialAd?.setFullScreenVideoAdInteractionListener(object :
TTFullScreenVideoAd.FullScreenVideoAdInteractionListener {
override fun onAdShow() {
AdEventUtils.onEventShowSuccess(entity)
listener.onAdShow()
}
override fun onAdDismiss() {
listener.onAdClose()
}
override fun onAdVideoBarClick() {
}
override fun onAdClose() {
listener.onAdClose()
}
override fun onVideoComplete() {
}
override fun onSkippedVideo() {
}
// override fun onAdClicked() {
//
// }
//
// override fun onAdShow() {
//
// }
//
// override fun onAdDismiss() {
//
// }
})
})
}
}
private var rewardVideoAd: TTRewardVideoAd? = null
/**
......@@ -211,7 +248,7 @@ object CSJAdManager {
.setExpressViewAcceptedSize(500f, 500f)
.setOrientation(TTAdConstant.VERTICAL) //必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL
.setAdLoadType(TTAdLoadType.UNKNOWN)//推荐使用,用于标注此次的广告请求用途为预加载(当做缓存)还是实时加载,方便后续为开发者优化相关策略
.build();
.build()
mTTAdNative?.loadRewardVideoAd(adSlot, object : TTAdNative.RewardVideoAdListener {
override fun onError(p0: Int, p1: String?) {
......@@ -322,7 +359,7 @@ object CSJAdManager {
.setSupportDeepLink(false)
.setExpressViewAcceptedSize(expressViewWidth, expressViewHeight)
// .setImageAcceptedSize(640, 0)
// .setAdLoadType(TTAdLoadType.PRELOAD)
// .setAdLoadType(TTAdLoadType.PRELOAD)
.setAdCount(1)
.build()
//调用feed广告异步请求接口
......
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