From c34803a6daaba2804bbdcb79bc2d1bbc1b5c1034 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 12 四月 2022 18:06:22 +0800 Subject: [PATCH] 阿里百川本地化 --- BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java | 207 +-------------------------------------------------- 1 files changed, 4 insertions(+), 203 deletions(-) diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java index 7318ef1..498dfd7 100644 --- a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java +++ b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java @@ -13,18 +13,12 @@ import com.bytedance.sdk.openadsdk.TTAdManager; import com.bytedance.sdk.openadsdk.TTAdNative; import com.bytedance.sdk.openadsdk.TTNativeExpressAd; -import com.google.gson.Gson; import com.qq.e.ads.cfg.VideoOption; import com.qq.e.ads.nativ.ADSize; import com.qq.e.ads.nativ.NativeExpressAD; import com.qq.e.ads.nativ.NativeExpressADView; -import com.qq.e.ads.nativ.express2.AdEventListener; -import com.qq.e.ads.nativ.express2.NativeExpressAD2; -import com.qq.e.ads.nativ.express2.NativeExpressADData2; -import com.qq.e.ads.nativ.express2.VideoOption2; import com.qq.e.comm.util.AdError; import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; -import com.weikou.beibeivideo.ui.recommend.SearchActivity; import com.weikou.beibeivideo.util.BeibeiConstant; import com.weikou.beibeivideo.util.DimenUtils; @@ -71,7 +65,7 @@ * @param adLoadListener */ public void loadAd(int widthDP, int heightDP, String pid, int count, final IAdLoadListener adLoadListener) { - if (sourceType == AdUtil.AD_TYPE.gdt) { + if (sourceType == AdUtil.AD_TYPE.gdt||sourceType == AdUtil.AD_TYPE.gdt2) { loadGDT(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { @Override public void onSuccess(List<NativeExpressADView> adList) { @@ -82,30 +76,7 @@ } adLoadListener.onSuccess(adContainerList); } - - @Override - public void onSuccess2(List<NativeExpressADData2> adList) { - - } }, mContext); - } else if (sourceType == AdUtil.AD_TYPE.gdt2) { - loadGDT2(pid, widthDP, heightDP, count, new IGDTAdLoadListener() { - @Override - public void onSuccess(List<NativeExpressADView> adList) { - - } - - @Override - public void onSuccess2(List<NativeExpressADData2> adList) { - List<ExpressAdContainer> adContainerList = new ArrayList<>(); - if (adList != null) - for (NativeExpressADData2 ad : adList) { - adContainerList.add(new ExpressAdContainer(ad)); - } - adLoadListener.onSuccess(adContainerList); - } - }, mContext); - } else if (sourceType == AdUtil.AD_TYPE.csj) { loadCSJ(pid, widthDP, heightDP, count, new ICSJAdLoadListener() { @Override @@ -354,7 +325,7 @@ private void loadGDT(String positionId, int widthDP, int heightDP, int count, final IGDTAdLoadListener adLoadListener, Context context) { - NativeExpressAD nativeExpressAD = new NativeExpressAD(context, new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), + NativeExpressAD nativeExpressAD = new NativeExpressAD(context, new ADSize(widthDP, ADSize.AUTO_HEIGHT), positionId, new NativeExpressAD.NativeExpressADListener() { @Override @@ -394,16 +365,6 @@ } @Override - public void onADOpenOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override - public void onADCloseOverlay(NativeExpressADView nativeExpressADView) { - - } - - @Override public void onNoAD(AdError adError) { if (adLoadListener != null) adLoadListener.onSuccess(null); @@ -413,47 +374,7 @@ .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 鐜涓嬪彲浠ヨ嚜鍔ㄦ挱鏀捐棰� .setAutoPlayMuted(true) // 鑷姩鎾斁鏃朵负闈欓煶 .build()); // - nativeExpressAD.setVideoPlayPolicy(VideoOption.VideoPlayPolicy.AUTO); nativeExpressAD.loadAD(count); - } - - /** - * 2.0鐗堟湰骞跨偣閫氬師鐢� - * - * @param positionId - * @param widthDP - * @param heightDP - * @param count - * @param adLoadListener - * @param context - */ - private void loadGDT2(String positionId, int widthDP, int heightDP, int count, final IGDTAdLoadListener adLoadListener, Context context) { - - Log.i(TAG, String.format("loadGDT2:positionId-%s widthDP-%s heightDP-%s", positionId, widthDP, heightDP)); - - NativeExpressAD2 nativeExpressAD2 = new NativeExpressAD2(context, positionId, new NativeExpressAD2.AdLoadListener() { - @Override - public void onLoadSuccess(List<NativeExpressADData2> list) { - if (adLoadListener != null) - adLoadListener.onSuccess2(list); - } - - @Override - public void onNoAD(AdError adError) { - if (adLoadListener != null) - adLoadListener.onSuccess2(null); - } - }); - - nativeExpressAD2.setAdSize(widthDP, heightDP); - VideoOption2.Builder builder = new VideoOption2.Builder(); - builder.setAutoPlayPolicy(VideoOption2.AutoPlayPolicy.WIFI) // WIFI 鐜涓嬪彲浠ヨ嚜鍔ㄦ挱鏀捐棰� - .setAutoPlayMuted(true) // 鑷姩鎾斁鏃朵负闈欓煶 - .setDetailPageMuted(false) // 瑙嗛璇︽儏椤垫挱鏀炬椂涓嶉潤闊� - .setMaxVideoDuration(0) // 璁剧疆杩斿洖瑙嗛骞垮憡鐨勬渶澶ц棰戞椂闀匡紙闂尯闂达紝鍙崟鐙缃級锛屽崟浣�:绉掞紝榛樿涓� 0 浠h〃鏃犻檺鍒讹紝鍚堟硶杈撳叆涓猴細5<=maxVideoDuration<=60. 姝よ缃細褰卞搷骞垮憡濉厖锛岃璋ㄦ厧璁剧疆 - .setMinVideoDuration(0); // 璁剧疆杩斿洖瑙嗛骞垮憡鐨勬渶灏忚棰戞椂闀匡紙闂尯闂达紝鍙崟鐙缃級锛屽崟浣�:绉掞紝榛樿涓� 0 浠h〃鏃犻檺鍒讹紝 姝よ缃細褰卞搷骞垮憡濉厖锛岃璋ㄦ厧璁剧疆 - nativeExpressAD2.setVideoOption2(builder.build()); - nativeExpressAD2.loadAd(count); } /** @@ -472,7 +393,6 @@ .setSupportDeepLink(true) .setExpressViewAcceptedSize(width, height) .setAdCount(count) //璇锋眰骞垮憡鏁伴噺涓�1鍒�3鏉� - .setDownloadType(CSJConstant.CSJ_AD_DOWNLOAD_NOTIFY? TTAdConstant.DOWNLOAD_TYPE_POPUP :TTAdConstant.DOWNLOAD_TYPE_NO_POPUP) .build(); if (mTTAdNative == null) { if (adLoadListener != null) @@ -517,49 +437,6 @@ ((ViewGroup) ad.getGdt().getParent()).removeAllViews(); } fl_ad.addView(ad.getGdt()); - } else if (ad.getGdt2() != null) { - if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt2().getAdView()) { - return; - } - fl_ad.removeAllViews(); - - ad.getGdt2().setAdEventListener(new AdEventListener() { - @Override - public void onClick() { - - } - - @Override - public void onExposed() { - - } - - @Override - public void onRenderSuccess() { - try { - if (ad.getGdt2().getAdView().getParent() != null) { - ((ViewGroup) ad.getGdt2().getAdView().getParent()).removeAllViews(); - } - fl_ad.addView(ad.getGdt2().getAdView()); - } catch (Exception e) { - - } - } - - @Override - public void onRenderFail() { - Log.i(TAG, "onRenderFail"); - } - - @Override - public void onAdClosed() { - if (adEventListener != null) { - adEventListener.closeAd(ad); - } - } - }); - ad.getGdt2().render(); - } else if (ad.getCsj() != null) { if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getCsj().getExpressAdView()) { return; @@ -619,42 +496,6 @@ list.add(ad); if (adRenderListener != null) adRenderListener.onRenderSuccess(list); - } else if (ad.getGdt2() != null) { - ad.getGdt2().setAdEventListener(new AdEventListener() { - @Override - public void onClick() { - - } - - @Override - public void onExposed() { - - } - - @Override - public void onRenderSuccess() { - List<ExpressAdContainer> list = new ArrayList<>(); - list.add(ad); - if (adRenderListener != null) - adRenderListener.onRenderSuccess(list); - } - - @Override - public void onRenderFail() { - List<ExpressAdContainer> list = new ArrayList<>(); - list.add(ad); - if (adRenderListener != null) - adRenderListener.onRenderFail(list); - } - - @Override - public void onAdClosed() { - if (adEventListener != null) - adEventListener.closeAd(ad); - } - }); - ad.getGdt2().render(); - } else if (ad.getCsj() != null) { Log.i(TAG, "骞垮憡鏇濆厜:csj"); ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() { @@ -730,35 +571,7 @@ if (ad.getGdt() != null) { return; - } else if (ad.getGdt2() != null) { - ad.getGdt2().setAdEventListener(new AdEventListener() { - @Override - public void onClick() { - - } - - @Override - public void onExposed() { - - } - - @Override - public void onRenderSuccess() { - - } - - @Override - public void onRenderFail() { - } - - @Override - public void onAdClosed() { - if (adEventListener != null) - adEventListener.closeAd(ad); - } - }); - - } else if (ad.getCsj() != null) { + } else if (ad.getCsj() != null) { ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() { @Override public void onAdClicked(View view, int i) { @@ -833,17 +646,7 @@ } fl_ad.removeAllViews(); fl_ad.addView(ad.getGdt()); - } else if (ad.getGdt2() != null) { - if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getGdt2().getAdView()) { - return; - } - if (ad.getGdt2().getAdView().getParent() != null) { - ((ViewGroup) ad.getGdt2().getAdView().getParent()).removeAllViews(); - } - fl_ad.removeAllViews(); - fl_ad.addView(ad.getGdt2().getAdView()); - - } else if (ad.getCsj() != null) { + }else if (ad.getCsj() != null) { if (fl_ad.getChildCount() > 0 && fl_ad.getChildAt(0) == ad.getCsj().getExpressAdView()) { return; } @@ -872,8 +675,6 @@ interface IGDTAdLoadListener { public void onSuccess(List<NativeExpressADView> adList); - - public void onSuccess2(List<NativeExpressADData2> adList); } interface ICSJAdLoadListener { -- Gitblit v1.8.0