Skip to content

Commit f334384

Browse files
committed
升级适配adn至最新版本
1 parent cf2d935 commit f334384

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+305
-381
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

3-
def version = '1.0'
3+
def version = '1.1'
44

55
ext {
66
//统一版本号,同时使用在渠道版本号信息中

easyads/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ dependencies {
6363
androidTestImplementation 'com.android.support.test:runner:1.0.2'
6464
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
6565
// the needed aars are here
66-
compileOnly(name: 'open_ad_sdk_3803', ext: 'aar')
67-
compileOnly(name: 'GDTSDK_4422', ext: 'aar')
68-
compileOnly(name: 'Baidu_MobAds_SDK_9131', ext: 'aar')
69-
compileOnly(name: 'kssdk-ad_3310', ext: 'aar')
66+
compileOnly(name: 'open_ad_sdk_4908', ext: 'aar')
67+
compileOnly(name: 'GDTSDK_4492', ext: 'aar')
68+
compileOnly(name: 'Baidu_MobAds_SDK_9241', ext: 'aar')
69+
compileOnly(name: 'kssdk-ad-3334', ext: 'aar')
7070
}
7171

7272

-981 KB
Binary file not shown.
1.69 MB
Binary file not shown.

easyads/libs/GDTSDK_4422.aar

-1.56 MB
Binary file not shown.

easyads/libs/GDTSDK_4492.aar

1.77 MB
Binary file not shown.

easyads/libs/kssdk-ad-3334.aar

3.8 MB
Binary file not shown.

easyads/libs/kssdk-ad_3310.aar

-2.21 MB
Binary file not shown.

easyads/libs/open_ad_sdk_3803.aar

-5.73 MB
Binary file not shown.

easyads/libs/open_ad_sdk_4908.aar

6.66 MB
Binary file not shown.

easyads/src/main/java/com/easyads/core/inter/EasyAdInterstitial.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void setCsjExpressViewAcceptedSize(float expressViewWidth, float expressV
5050
this.csjExpressViewHeight = expressViewHeight;
5151
}
5252

53+
@Deprecated
5354
public void setCsjNew(boolean csjNew) {
5455
isCsjNew = csjNew;
5556
}

easybd/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ group = 'com.github.bayescom'
88

99
//maven依赖的项目名称
1010
def pomName = "easyads-bd"
11-
def VersionCode = 918
11+
def VersionCode = 9241
1212
def VersionName = "${rootProject.ext.EasyAds_version}_" + VersionCode
1313

1414
def outputName = pomName + "_" + VersionName + ".aar"

easybd/libs/Baidu_MobAds_SDK_918.aar

-1.08 MB
Binary file not shown.

easybd/libs/Baidu_MobAds_SDK_9241.aar

1.69 MB
Binary file not shown.

easybd/src/main/java/com/easyads/supplier/baidu/BDNativeExpressAdapter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.baidu.mobads.sdk.api.XAdNativeResponse;
1616

1717
import java.lang.ref.SoftReference;
18+
import java.util.ArrayList;
1819
import java.util.List;
1920

2021
/**
@@ -89,7 +90,10 @@ public void onDislikeClick() {
8990
* registerViewForInteraction()与BaiduNativeManager配套使用
9091
* 警告:调用该函数来发送展现,勿漏!
9192
*/
92-
nativeResponse.registerViewForInteraction(setting.getAdContainer(), this);
93+
94+
List<View> clickViews = new ArrayList<>();
95+
List<View> creativeViews = new ArrayList<>();
96+
nativeResponse.registerViewForInteraction(setting.getAdContainer(),clickViews, creativeViews,this);
9397

9498
nativeResponse.setAdPrivacyListener(new NativeResponse.AdPrivacyListener() {
9599
@Override

easycsj/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'com.github.dcendents.android-maven'
77
group = 'com.github.bayescom'
88

99
def pomName = "easyads-csj"
10-
def VersionCode = 4105
10+
def VersionCode = 4908
1111
def VersionName = "${rootProject.ext.EasyAds_version}_" + VersionCode
1212

1313
def outputName = pomName + "_" + VersionName + ".aar"

easycsj/libs/open_ad_sdk_4105.aar

-5.43 MB
Binary file not shown.

easycsj/libs/open_ad_sdk_4908.aar

6.66 MB
Binary file not shown.

easycsj/src/main/java/com/easyads/supplier/csj/CsjBannerAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ private void startLoadAD() {
170170
// 可选参数 设置是否支持deeplink
171171
.setSupportDeepLink(true)
172172
//请求原生广告时候需要设置,参数为TYPE_BANNER或TYPE_INTERACTION_AD
173-
.setDownloadType(EasyCsjManger.getInstance().csj_downloadType)
174173
.build();
175174
ttAdNative.loadBannerExpressAd(adSlot, this);
176175
}

easycsj/src/main/java/com/easyads/supplier/csj/CsjFullScreenVideoAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ private void startLoadAD() {
5959
//模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可
6060
.setExpressViewAcceptedSize(500, 500)
6161
.setSupportDeepLink(true)
62-
.setDownloadType(EasyCsjManger.getInstance().csj_downloadType)
6362
.setOrientation(orientation)//必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL
6463
.build();
6564

Lines changed: 90 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
package com.easyads.supplier.csj;
22

33
import android.app.Activity;
4-
import android.view.View;
54

6-
import com.easyads.EasyAdsManger;
5+
import com.bytedance.sdk.openadsdk.AdSlot;
6+
import com.bytedance.sdk.openadsdk.TTAdConstant;
7+
import com.bytedance.sdk.openadsdk.TTAdNative;
8+
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
79
import com.easyads.core.inter.EAInterstitialSetting;
810
import com.easyads.custom.EAInterstitialCustomAdapter;
11+
import com.easyads.itf.BaseEnsureListener;
912
import com.easyads.model.EasyAdError;
1013
import com.easyads.utils.EALog;
11-
import com.bytedance.sdk.openadsdk.AdSlot;
12-
import com.bytedance.sdk.openadsdk.TTAdNative;
13-
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
14-
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
14+
import com.easyads.utils.EAUtil;
1515

1616
import java.lang.ref.SoftReference;
17-
import java.util.List;
1817

19-
public class CsjInterstitialAdapter extends EAInterstitialCustomAdapter implements TTAdNative.NativeExpressAdListener {
18+
public class CsjInterstitialAdapter extends EAInterstitialCustomAdapter {
2019
private EAInterstitialSetting setting;
21-
private TTNativeExpressAd mTTAd;
20+
// private TTNativeExpressAd mTTAd;
2221
private long startTime = 0;
2322

24-
private boolean isNewVersion;//是否为 新模板渲染插屏,穿山甲自3.5.5.0版本后新增
2523
public TTFullScreenVideoAd newVersionAd;
2624

2725
public CsjInterstitialAdapter(SoftReference<Activity> activity, EAInterstitialSetting setting) {
@@ -31,9 +29,7 @@ public CsjInterstitialAdapter(SoftReference<Activity> activity, EAInterstitialSe
3129

3230
@Override
3331
public void doDestroy() {
34-
if (mTTAd != null) {
35-
mTTAd.destroy();
36-
}
32+
3733
}
3834

3935
@Override
@@ -55,181 +51,108 @@ public void fail(String code, String msg) {
5551

5652
@Override
5753
protected void doShowAD() {
58-
if (isNewVersion) {
59-
newVersionAd.showFullScreenVideoAd(getActivity());
60-
return;
61-
}
62-
mTTAd.showInteractionExpressAd(getActivity());
63-
}
64-
65-
66-
@Override
67-
public void onError(int i, String s) {
68-
handleFailed(i, s);
69-
}
70-
71-
@Override
72-
public void onNativeExpressAdLoad(List<TTNativeExpressAd> ads) {
73-
try {
74-
EALog.high(TAG + "onNativeExpressAdLoad");
75-
if (ads == null || ads.size() == 0) {
76-
handleFailed(EasyAdError.ERROR_DATA_NULL, "ads.size() == 0");
77-
return;
78-
}
79-
mTTAd = ads.get(0);
80-
if (null == mTTAd) {
81-
handleFailed(EasyAdError.ERROR_DATA_NULL, "null == mTTAd");
82-
return;
83-
}
84-
mTTAd.setExpressInteractionListener(new TTNativeExpressAd.AdInteractionListener() {
85-
@Override
86-
public void onAdDismiss() {
87-
EALog.high(TAG + "onAdDismiss");
88-
89-
if (null != setting) {
90-
setting.adapterDidClosed(sdkSupplier);
54+
EAUtil.switchMainThread(new BaseEnsureListener() {
55+
@Override
56+
public void ensure() {
57+
try {
58+
String nullTip = TAG + "请先加载广告或者广告已经展示过";
59+
if (newVersionAd != null) {
60+
newVersionAd.showFullScreenVideoAd(getActivity(), TTAdConstant.RitScenes.GAME_GIFT_BONUS, null);
61+
newVersionAd = null;
62+
} else {
63+
EALog.e(nullTip);
9164
}
65+
} catch (Exception e) {
66+
e.printStackTrace();
67+
handleFailed(EasyAdError.parseErr(EasyAdError.ERROR_EXCEPTION_SHOW));
9268
}
93-
94-
@Override
95-
public void onAdClicked(View view, int type) {
96-
EALog.high(TAG + "onAdClicked");
97-
98-
handleClick();
99-
}
100-
101-
@Override
102-
public void onAdShow(View view, int type) {
103-
EALog.high(TAG + "onAdShow");
104-
handleExposure();
105-
}
106-
107-
@Override
108-
public void onRenderFail(View view, String msg, int code) {
109-
EALog.high(TAG + "ExpressView render fail:" + (System.currentTimeMillis() - startTime));
110-
handleFailed(EasyAdError.parseErr(EasyAdError.ERROR_RENDER_FAILED, TAG + code + ", " + msg));
111-
}
112-
113-
@Override
114-
public void onRenderSuccess(View view, float width, float height) {
115-
EALog.high(TAG + "ExpressView render suc:" + (System.currentTimeMillis() - startTime));
116-
//返回view的宽高 单位 dp
117-
}
118-
});
119-
startTime = System.currentTimeMillis();
120-
mTTAd.render();
121-
handleSucceed();
122-
} catch (Throwable e) {
123-
e.printStackTrace();
124-
handleFailed(EasyAdError.parseErr(EasyAdError.ERROR_EXCEPTION_LOAD));
125-
}
69+
}
70+
});
12671
}
12772

12873

12974
private void startLoadAD() {
130-
131-
//此处使用渠道配置参数versionTag,来确定是否为新插屏广告,以方便动态设置
132-
if (sdkSupplier.versionTag == 1) {
133-
isNewVersion = false;
134-
} else if (sdkSupplier.versionTag == 2) {
135-
isNewVersion = true;
136-
} else {//如果未设置versionTag信息,取广告位上的设置
137-
if (setting != null) {
138-
isNewVersion = setting.isCsjNew();
139-
} else {//广告位为配置默认为新版本
140-
isNewVersion = true;
141-
}
142-
}
143-
EALog.simple(TAG + "当前广告是否为'新插屏': " + isNewVersion);
144-
145-
14675
TTAdNative ttAdNative = CsjUtil.getADManger(this).createAdNative(getActivity());
14776
AdSlot adSlot = new AdSlot.Builder()
14877
.setCodeId(sdkSupplier.adspotId)
14978
.setSupportDeepLink(true)
15079
.setExpressViewAcceptedSize(setting.getCsjExpressViewWidth(), setting.getCsjExpressViewHeight())
151-
.setDownloadType(EasyCsjManger.getInstance().csj_downloadType)
15280
.build();
153-
if (isNewVersion) {
154-
ttAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
155-
@Override
156-
public void onError(int i, String s) {
157-
handleFailed(i, s);
158-
}
81+
ttAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
82+
@Override
83+
public void onError(int i, String s) {
84+
handleFailed(i, s);
85+
}
15986

160-
@Override
161-
public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ttFullScreenVideoAd) {
162-
try {
163-
EALog.high(TAG + "onFullScreenVideoAdLoad");
87+
@Override
88+
public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ttFullScreenVideoAd) {
89+
try {
90+
EALog.high(TAG + "onFullScreenVideoAdLoad");
91+
92+
newVersionAd = ttFullScreenVideoAd;
93+
if (newVersionAd == null) {
94+
handleFailed(EasyAdError.ERROR_DATA_NULL, "new ints ad null");
95+
return;
96+
}
97+
newVersionAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
98+
@Override
99+
public void onAdShow() {
100+
EALog.high(TAG + "newVersionAd onAdShow");
101+
handleExposure();
102+
}
164103

165-
newVersionAd = ttFullScreenVideoAd;
166-
if (newVersionAd == null) {
167-
handleFailed(EasyAdError.ERROR_DATA_NULL, "new ints ad null");
168-
return;
104+
@Override
105+
public void onAdVideoBarClick() {
106+
EALog.high(TAG + "newVersionAd onAdVideoBarClick");
107+
handleClick();
169108
}
170-
newVersionAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
171-
@Override
172-
public void onAdShow() {
173-
EALog.high(TAG + "newVersionAd onAdShow");
174-
handleExposure();
175-
}
176-
177-
@Override
178-
public void onAdVideoBarClick() {
179-
EALog.high(TAG + "newVersionAd onAdVideoBarClick");
180-
handleClick();
181-
}
182-
183-
@Override
184-
public void onAdClose() {
185-
EALog.high(TAG + "newVersionAd onAdClose");
186-
187-
if (setting != null)
188-
setting.adapterDidClosed(sdkSupplier);
189-
}
190-
191-
@Override
192-
public void onVideoComplete() {
193-
EALog.high(TAG + "newVersionAd onVideoComplete");
194-
}
195-
196-
@Override
197-
public void onSkippedVideo() {
198-
EALog.high(TAG + "newVersionAd onSkippedVideo");
199-
}
200-
});
201-
handleSucceed();
202-
203-
} catch (Throwable e) {
204-
e.printStackTrace();
205-
handleFailed(EasyAdError.ERROR_EXCEPTION_LOAD, "");
206-
}
207-
}
208109

209-
@Override
210-
public void onFullScreenVideoCached() {
211-
EALog.high(TAG + "onFullScreenVideoCached");
110+
@Override
111+
public void onAdClose() {
112+
EALog.high(TAG + "newVersionAd onAdClose");
212113

213-
}
114+
if (setting != null)
115+
setting.adapterDidClosed(sdkSupplier);
116+
}
214117

215-
@Override
216-
public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) {
217-
try {
218-
String ad = "";
219-
if (ttFullScreenVideoAd != null) {
220-
ad = ttFullScreenVideoAd.toString();
118+
@Override
119+
public void onVideoComplete() {
120+
EALog.high(TAG + "newVersionAd onVideoComplete");
221121
}
222-
EALog.high(TAG + "onFullScreenVideoCached( " + ad + ")");
223-
} catch (Throwable e) {
224-
e.printStackTrace();
225-
}
226122

123+
@Override
124+
public void onSkippedVideo() {
125+
EALog.high(TAG + "newVersionAd onSkippedVideo");
126+
}
127+
});
128+
handleSucceed();
129+
130+
} catch (Throwable e) {
131+
e.printStackTrace();
132+
handleFailed(EasyAdError.ERROR_EXCEPTION_LOAD, "");
227133
}
228-
});
229-
} else {
230-
ttAdNative.loadInteractionExpressAd(adSlot, this);
231-
}
232-
}
134+
}
135+
136+
@Override
137+
public void onFullScreenVideoCached() {
138+
EALog.high(TAG + "onFullScreenVideoCached");
139+
140+
}
233141

142+
@Override
143+
public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) {
144+
try {
145+
String ad = "";
146+
if (ttFullScreenVideoAd != null) {
147+
ad = ttFullScreenVideoAd.toString();
148+
}
149+
EALog.high(TAG + "onFullScreenVideoCached( " + ad + ")");
150+
} catch (Throwable e) {
151+
e.printStackTrace();
152+
}
153+
154+
}
155+
});
156+
}
234157

235158
}

0 commit comments

Comments
 (0)