From a62905c725c5ffd88f29dfac644591cde18751e1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 10 九月 2020 13:40:09 +0800 Subject: [PATCH] 广告优化 --- BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java | 69 ++++++++++++++++++++++------------ 1 files changed, 45 insertions(+), 24 deletions(-) diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java index cb1609d..c0af154 100644 --- a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java +++ b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java @@ -32,22 +32,20 @@ * 淇℃伅娴佸箍鍛婄鐞� */ public class ExpressAdManager { - public final static int SOURCE_GDT = 1;//骞跨偣閫� - public final static int SOURCE_GDT2 = 11;//骞跨偣閫�2.0 - public final static int SOURCE_CSJ = 2;//绌垮北鐢� + final static String TAG = "ExpressAdManager"; - int sourceType = SOURCE_GDT; + AdUtil.AD_TYPE sourceType = AdUtil.AD_TYPE.gdt; private TTAdNative mTTAdNative; private Context mContext; - public ExpressAdManager(int adSource, Context context) { + public ExpressAdManager(AdUtil.AD_TYPE adSource, Context context) { sourceType = adSource; this.mContext = context; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { TTAdManager ttAdManager = TTAdManagerHolder.get(); mTTAdNative = ttAdManager.createAdNative(context); // TTAdManagerHolder.get().requestPermissionIfNecessary(context); @@ -66,7 +64,7 @@ * @param adLoadListener */ public void loadAd(int widthDP, int heightDP, String pid, int count, final IAdLoadListener adLoadListener) { - if (sourceType == SOURCE_GDT) { + if (sourceType == AdUtil.AD_TYPE.gdt) { loadGDT(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { @Override public void onSuccess(List<NativeExpressADView> adList) { @@ -83,7 +81,7 @@ } }, mContext); - } else if (sourceType == SOURCE_GDT2) { + } else if (sourceType == AdUtil.AD_TYPE.gdt2) { loadGDT2(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { @Override public void onSuccess(List<NativeExpressADView> adList) { @@ -101,7 +99,7 @@ } }, mContext); - } else if (sourceType == SOURCE_CSJ) { + } else if (sourceType == AdUtil.AD_TYPE.csj) { loadCSJ(pid, widthDP, heightDP, count, new ICSJAdLoadListener() { @Override public void onSuccess(List<TTNativeExpressAd> adList) { @@ -130,12 +128,12 @@ int width = deviceWidth - 6; int height = (int) (width * 0.8); String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = CSJConstant.RECOMMEND_BIG_IMG_AD; height = (int) (width * 0.56); - } else if (sourceType == SOURCE_GDT) { + } else if (sourceType == AdUtil.AD_TYPE.gdt) { pid = BeibeiConstant.GDT_RECOMMAND_NATIVE; - } else if (sourceType == SOURCE_GDT2) { + } else if (sourceType == AdUtil.AD_TYPE.gdt2) { pid = GDTConstant.PID_HOME_RECOMMEND_BIG_IMG; } //鑾峰彇灞忓箷鐨勫 @@ -152,9 +150,9 @@ public void loadRecommendSmallAd(final IAdLoadListener adLoadListener) { //鍔犺浇澶у浘 String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = "945375047"; - } else if (sourceType == SOURCE_GDT) { + } else if (sourceType == AdUtil.AD_TYPE.gdt) { pid = BeibeiConstant.GDT_RECOMMAND_MIN_NATIVE; } //鑾峰彇灞忓箷鐨勫 @@ -174,9 +172,9 @@ public void loadVideoDetailPlayerBottomAd(final IAdLoadListener adLoadListener) { //鍔犺浇澶у浘 String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = "945375047"; - } else if (sourceType == SOURCE_GDT2) { + } else if (sourceType == AdUtil.AD_TYPE.gdt2) { pid = GDTConstant.PID_2_VIDEO_DETAIL_PLAY_EXPRESS1; } //鑾峰彇灞忓箷鐨勫 @@ -196,9 +194,9 @@ public void loadVideoDetailRelativeVideoBottomAd(final IAdLoadListener adLoadListener) { //鍔犺浇澶у浘 String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = "945375047"; - } else if (sourceType == SOURCE_GDT2) { + } else if (sourceType == AdUtil.AD_TYPE.gdt2) { pid = GDTConstant.PID_2_VIDEO_DETAIL_PLAY_EXPRESS2; } if (mContext == null) @@ -220,9 +218,9 @@ public void loadRecommendCategorySmallAd(final IAdLoadListener adLoadListener) { //鍔犺浇澶у浘 String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = "945375047"; - } else if (sourceType == SOURCE_GDT) { + } else if (sourceType == AdUtil.AD_TYPE.gdt) { pid = BeibeiConstant.GDT_RECOMMEND_CATEGORY_MIN_NATIVE; } //鑾峰彇灞忓箷鐨勫 @@ -242,9 +240,9 @@ public void loadSearchResultSmallAd(int count, final IAdLoadListener adLoadListener) { //鍔犺浇澶у浘 String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = "945379581"; - } else if (sourceType == SOURCE_GDT) { + } else if (sourceType == AdUtil.AD_TYPE.gdt) { pid = BeibeiConstant.GDT_SEARCH_RESULT_MIN_NATIVE; } //鑾峰彇灞忓箷鐨勫 @@ -267,9 +265,9 @@ //鍔犺浇澶у浘 String pid = null; - if (sourceType == SOURCE_CSJ) { + if (sourceType == AdUtil.AD_TYPE.csj) { pid = "945406595"; - } else if (sourceType == SOURCE_GDT2) { + } else if (sourceType == AdUtil.AD_TYPE.gdt2) { if (columns == 3) pid = GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN3; else if (columns == 2) @@ -294,6 +292,29 @@ /** + * 鍔犺浇APP閫�鍑哄箍鍛� + * + * @param adLoadListener + */ + public void loadAppExitAd(final IAdLoadListener adLoadListener) { + //鍔犺浇澶у浘 + String pid = null; + if (sourceType == AdUtil.AD_TYPE.csj) { + pid = CSJConstant.APP_EXIT; + } else if (sourceType == AdUtil.AD_TYPE.gdt) { + pid = BeibeiConstant.GDT_EXIT_DIALOG; + } + //鑾峰彇灞忓箷鐨勫 + int deviceWidth = DimenUtils.getScreenWidth(mContext); + deviceWidth = DimenUtils.px2dip(mContext, deviceWidth); + int width = deviceWidth * 3 / 4; + int height = (int) (width / 1.78f); + + loadAd(width, height, pid, 1, adLoadListener); + } + + + /** * 鍔犺浇骞跨偣閫氬箍鍛� * * @param positionId -- Gitblit v1.8.0