Commit 9387f1f1 authored by mengcuiguang's avatar mengcuiguang

添加gromore代码位,区分新插屏是全屏还是插屏

parent 7a380a6c
......@@ -15,14 +15,18 @@ import com.bytedance.msdk.api.fullVideo.TTFullVideoAdListener;
import com.bytedance.msdk.api.fullVideo.TTFullVideoAdLoadCallback;
import com.mints.flowbox.BuildConfig;
import com.mints.flowbox.ad.wifi.WifiAdStatusListener;
import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.common.Constant;
import com.mints.flowbox.manager.CsjGroMoreManager;
import com.mints.flowbox.manager.TrackManager;
import com.mints.flowbox.manager.UserManager;
import com.mints.flowbox.mvp.model.WeightBean;
import com.mints.flowbox.utils.LogUtil;
import com.mints.flowbox.utils.VideoOptionUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
/**
* gromore全屏广告
......@@ -36,12 +40,19 @@ public class FullGroManager {
private TTFullVideoAd mTTFullVideoAd;
private Activity activity;
private boolean isLoadSuccess = false;
private boolean isMain = false;
private String fullId;
public void loadFullAd(Activity activity) {
private ArrayList<WeightBean> weightList;
private int fullInterstitialWeight = 70;
private int interstitialWeight = 30;
public void loadFullAd(Activity activity, boolean isMain) {
// 加载到广告且未展示 则返回
if (isLoadSuccess) return;
this.activity = activity;
this.isMain = isMain;
if (TTMediationAdSdk.configLoadSuccess()) {
loadAd();
......@@ -57,6 +68,11 @@ public class FullGroManager {
}
activity = null;
isLoadSuccess = false;
if (weightList != null) {
weightList.clear();
}
weightList = null;
}
/**
......@@ -71,6 +87,8 @@ public class FullGroManager {
};
private void loadAd() {
fullId = getFullId(getRandomWeightType());
/**
* 选择的模板类型
* 如果服务端配置了模板类型跟随服务端配置
......@@ -81,7 +99,8 @@ public class FullGroManager {
* 注:每次加载全屏视频广告的时候需要新建一个TTFullVideoAd,否则可能会出现广告填充问题
* ( 例如:mTTFullVideoAd = new TTFullVideoAd(this, adUnitId);)
*/
mTTFullVideoAd = new TTFullVideoAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID());
// mTTFullVideoAd = new TTFullVideoAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID());
mTTFullVideoAd = new TTFullVideoAd(activity, fullId);
//声音控制 模板 2.0
TTVideoOption videoOption = VideoOptionUtil.getTTVideoOption2();
......@@ -114,6 +133,57 @@ public class FullGroManager {
});
}
private String getFullId(String type) {
String id = CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID();
switch (type) {
case Constant.GROMORE_NEW_FULL_AD:
if (isMain) {
id = CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID();
} else {
id = CsjGroMoreManager.INSTANCE.getAPP_OUT_AD_UNIT_FULL_NEW_INTERSTITIAL_ID();
}
break;
case Constant.GROMORE_NEW_INSERTSCREEN_AD:
if (isMain) {
id = CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT_NEW_INTERSTITIAL_ID();
} else {
id = CsjGroMoreManager.INSTANCE.getAPP_OUT_AD_UNIT_NEW_INTERSTITIAL_ID();
}
break;
}
return id;
}
private String getRandomWeightType() {
if (weightList != null) {
weightList.clear();
} else {
weightList = new ArrayList<>();
}
int weight = 0;
weightList.add(new WeightBean(fullInterstitialWeight, Constant.GROMORE_NEW_FULL_AD));
weight = weight + fullInterstitialWeight;
weightList.add(new WeightBean(interstitialWeight, Constant.GROMORE_NEW_INSERTSCREEN_AD));
weight = weight + interstitialWeight;
if (weightList != null && weightList.size() > 0 && weight > 0) {
LogUtil.d(TAG, "1、权重总值:" + weight);
Random r = new Random();
int randomWeight = r.nextInt(weight) + 1;
LogUtil.d(TAG, "2、权重随机值:" + randomWeight);
// ToastUtil.show(MintsApplication.getContext(),"权重随机值:" + randomWeight);
for (WeightBean weightBean : weightList) {
randomWeight -= weightBean.getWeight();
if (randomWeight <= 0) {
LogUtil.d(TAG, "3、权重结果:" + weightBean.getType());
return weightBean.getType();
}
}
}
return "";
}
public void showFullAd() {
if (BuildConfig.DEBUG) {
LogUtil.d(TAG, "showFullAd isLoadSuccess=" + isLoadSuccess + " isReady=" + mTTFullVideoAd.isReady());
......@@ -127,7 +197,7 @@ public class FullGroManager {
vo.put("ecpm", mTTFullVideoAd.getPreEcpm());
vo.put("adSource", mTTFullVideoAd.getAdNetworkPlatformId());
vo.put("adType", Constant.GRO_MORE_ADTYPE4);
vo.put("adid", CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID());
vo.put("adid", fullId);
TrackManager.getInstance().cmtGroMoreInfo(vo);
} else {
// 当加载到广告后 ,长时间未展示失效时 改变状态
......
......@@ -76,11 +76,12 @@ public class InterstitialGroManager {
* 注:每次加载插屏广告的时候需要新建一个TTInterstitialAd,否则可能会出现广告填充问题
* ( 例如:mInterstitialAd = new TTInterstitialAd(this, adUnitId);)
*/
if (isMain) {
mInterstitialAd = new TTInterstitialAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
} else {
mInterstitialAd = new TTInterstitialAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID());
}
// if (isMain) {
// mInterstitialAd = new TTInterstitialAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
// } else {
// mInterstitialAd = new TTInterstitialAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
// }
mInterstitialAd = new TTInterstitialAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
//模板1.0
TTVideoOption videoOption = VideoOptionUtil.getTTVideoOption();
......@@ -128,7 +129,7 @@ public class InterstitialGroManager {
if (isMain) {
vo.put("adid", CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
} else {
vo.put("adid", CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID());
vo.put("adid", CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
}
TrackManager.getInstance().cmtGroMoreInfo(vo);
} else {
......
......@@ -2,9 +2,8 @@ package com.mints.flowbox.ad.wifi
import android.app.Activity
import com.mints.flowbox.ad.full.FullGroManager
import com.mints.flowbox.ad.inscreen.InterstitialGroManager
import com.mints.flowbox.common.Constant
import java.util.*
import com.mints.flowbox.mvp.model.WeightBean
/**
......@@ -17,7 +16,7 @@ class WifiAdManager {
private var wifiAdStatusListener: WifiAdStatusListener? = null
// groMore插屏
private var interstitialGroManager: InterstitialGroManager? = null
// private var interstitialGroManager: InterstitialGroManager? = null
// groMore全屏
private var fullGroManager: FullGroManager? = null
......@@ -29,29 +28,31 @@ class WifiAdManager {
* 预加载广告,必须传入activity
*/
fun loadWifiAd(activity: Activity) {
currentAdType = getCurrentAdType()
when (currentAdType) {
Constant.GROMORE_INSERTSCREEN_AD -> {
preLoadInterstitialGroMore(activity)
}
Constant.GROMORE_FULL_AD -> {
preLoadFullGroMore(activity)
}
}
// currentAdType = getCurrentAdType()
//
// when (currentAdType) {
// Constant.GROMORE_INSERTSCREEN_AD -> {
// preLoadInterstitialGroMore(activity)
// }
// Constant.GROMORE_FULL_AD -> {
// preLoadFullGroMore(activity,true)
// }
// }
preLoadFullGroMore(activity,true)
}
/**
* 定义广告类型规则
*/
private fun getCurrentAdType(): String {
var tempAdType = ""
val randomInt = Random().nextInt(10)
if (randomInt % 2 == 0) {
tempAdType = Constant.GROMORE_INSERTSCREEN_AD
} else {
tempAdType = Constant.GROMORE_FULL_AD
}
// var tempAdType = ""
// val randomInt = Random().nextInt(10)
// if (randomInt % 2 == 0) {
// tempAdType = Constant.GROMORE_INSERTSCREEN_AD
// } else {
// tempAdType = Constant.GROMORE_FULL_AD
// }
// return tempAdType
return Constant.GROMORE_FULL_AD
......@@ -61,22 +62,22 @@ class WifiAdManager {
* 插屏
*/
private fun preLoadInterstitialGroMore(activity: Activity) {
if (interstitialGroManager != null) {
interstitialGroManager?.onDestroy()
}
interstitialGroManager = InterstitialGroManager()
interstitialGroManager?.loadInsertScreenAd(activity, false)
// if (interstitialGroManager != null) {
// interstitialGroManager?.onDestroy()
// }
// interstitialGroManager = InterstitialGroManager()
// interstitialGroManager?.loadInsertScreenAd(activity, false)
}
/**
* 全屏
*/
private fun preLoadFullGroMore(activity: Activity) {
private fun preLoadFullGroMore(activity: Activity,isMain: Boolean) {
if (fullGroManager != null) {
fullGroManager?.onDestroy()
}
fullGroManager = FullGroManager()
fullGroManager?.loadFullAd(activity)
fullGroManager?.loadFullAd(activity,isMain)
}
/**
......@@ -84,22 +85,22 @@ class WifiAdManager {
*/
fun showInterstitial() {
when (currentAdType) {
Constant.GROMORE_INSERTSCREEN_AD -> {
interstitialGroManager?.setWifiAdStatusListener(object : WifiAdStatusListener {
override fun adSuccess() {
}
override fun adFail() {
}
override fun adClose() {
wifiAdStatusListener?.adClose()
}
})
interstitialGroManager?.showInteractionAd()
}
// Constant.GROMORE_INSERTSCREEN_AD -> {
// interstitialGroManager?.setWifiAdStatusListener(object : WifiAdStatusListener {
// override fun adSuccess() {
//
// }
//
// override fun adFail() {
//
// }
//
// override fun adClose() {
// wifiAdStatusListener?.adClose()
// }
// })
// interstitialGroManager?.showInteractionAd()
// }
Constant.GROMORE_FULL_AD -> {
fullGroManager?.showFullAd()
}
......@@ -107,9 +108,9 @@ class WifiAdManager {
}
fun onDestroy() {
interstitialGroManager?.onDestroy()
interstitialGroManager?.setWifiAdStatusListener(null)
interstitialGroManager = null
// interstitialGroManager?.onDestroy()
// interstitialGroManager?.setWifiAdStatusListener(null)
// interstitialGroManager = null
fullGroManager?.onDestroy()
fullGroManager = null
......
......@@ -173,6 +173,10 @@ object Constant {
const val GROMORE_VEDIO_AD = "GROMORE_VEDIO_AD"
const val OW_VEDIO_AD = "OW_VEDIO_AD"
// 新插屏
const val GROMORE_NEW_FULL_AD = "GROMORE_NEW_FULL_AD"
const val GROMORE_NEW_INSERTSCREEN_AD = "GROMORE_NEW_INSERTSCREEN_AD"
// 信息流广告类型
const val CSJ_EXPRESS_AD = "CSJ_EXPRESS_AD"
const val YLH_EXPRESS_AD = "YLH_EXPRESS_AD"
......
......@@ -13,7 +13,7 @@ object CsjGroMoreManager {
* 老用户代码位-- ↓
* 应用内:
* 普通:
* 新插屏 -> 946333680
* 新插屏(全屏) -> 946333578
* 信息流 -> 946265897
* 网赚:
* 激励视频 -> 946265896
......@@ -22,7 +22,7 @@ object CsjGroMoreManager {
* 开屏 -> 887506685
* 应用外:
* 普通:
* 新插屏 -> 946333773
* 新插屏(全屏) -> 946333773
* 信息流 -> 946333992
* 锁屏:
* 信息流 -> 946334023
......@@ -30,9 +30,11 @@ object CsjGroMoreManager {
var APP_OUT_AD_UNIT_EXPRESS_ID = "946333992" // 应用外普通信息流
var APP_OUT_AD_UNIT_LOCK_EXPRESS_ID = "946334023" // 应用外锁屏信息流
var APP_OUT_AD_UNIT_INTERSTITIAL_ID = "946333773" // 应用外插屏
var APP_OUT_AD_UNIT_FULL_NEW_INTERSTITIAL_ID = "946333773" // 应用外新插屏(全屏)
var APP_OUT_AD_UNIT_NEW_INTERSTITIAL_ID = "" // 应用外新插屏(插屏)
var APP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID = "946333578" // 应用内 普通 插屏
var APP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID = "946333578" // 应用内 普通 新插屏(全屏)
var APP_IN_COMMON_AD_UNIT_NEW_INTERSTITIAL_ID = "" // 应用内 普通 新插屏(插屏)
var APP_IN_COMMON_AD_UNIT_EXPRESS_ID = "946265897" // 应用内 普通 信息流
var APP_IN_MAIN_AD_UNIT_VIDEO_ID = "946265896" // 应用内 网赚 激励视频
var APP_IN_MAIN_AD_UNIT_EXPRESS_ID = "946334121" // 应用内 网赚 信息流
......@@ -58,7 +60,7 @@ object CsjGroMoreManager {
if (idBean.gromoreAdcodes_ordinary != null) { // 应用内普通
APP_IN_COMMON_AD_UNIT_EXPRESS_ID = idBean.gromoreAdcodes_ordinary.groExpress
APP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID =
APP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID =
idBean.gromoreAdcodes_ordinary.groNewInterstitial
}
......@@ -68,7 +70,7 @@ object CsjGroMoreManager {
if (idBean.gromoreAdcodes_outer_ordinary != null) { // 应用外普通
APP_OUT_AD_UNIT_EXPRESS_ID = idBean.gromoreAdcodes_main.groExpress
APP_OUT_AD_UNIT_INTERSTITIAL_ID =
APP_OUT_AD_UNIT_FULL_NEW_INTERSTITIAL_ID =
idBean.gromoreAdcodes_outer_ordinary.groNewInterstitial
}
}
......
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