Skip to content

Commit

Permalink
升级适配adn至最新版本
Browse files Browse the repository at this point in the history
  • Loading branch information
flayone committed Nov 25, 2022
1 parent cf2d935 commit f334384
Show file tree
Hide file tree
Showing 50 changed files with 305 additions and 381 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

def version = '1.0'
def version = '1.1'

ext {
//统一版本号,同时使用在渠道版本号信息中
Expand Down
8 changes: 4 additions & 4 deletions easyads/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// the needed aars are here
compileOnly(name: 'open_ad_sdk_3803', ext: 'aar')
compileOnly(name: 'GDTSDK_4422', ext: 'aar')
compileOnly(name: 'Baidu_MobAds_SDK_9131', ext: 'aar')
compileOnly(name: 'kssdk-ad_3310', ext: 'aar')
compileOnly(name: 'open_ad_sdk_4908', ext: 'aar')
compileOnly(name: 'GDTSDK_4492', ext: 'aar')
compileOnly(name: 'Baidu_MobAds_SDK_9241', ext: 'aar')
compileOnly(name: 'kssdk-ad-3334', ext: 'aar')
}


Expand Down
Binary file removed easyads/libs/Baidu_MobAds_SDK_9131.aar
Binary file not shown.
Binary file added easyads/libs/Baidu_MobAds_SDK_9241.aar
Binary file not shown.
Binary file removed easyads/libs/GDTSDK_4422.aar
Binary file not shown.
Binary file added easyads/libs/GDTSDK_4492.aar
Binary file not shown.
Binary file added easyads/libs/kssdk-ad-3334.aar
Binary file not shown.
Binary file removed easyads/libs/kssdk-ad_3310.aar
Binary file not shown.
Binary file removed easyads/libs/open_ad_sdk_3803.aar
Binary file not shown.
Binary file added easyads/libs/open_ad_sdk_4908.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void setCsjExpressViewAcceptedSize(float expressViewWidth, float expressV
this.csjExpressViewHeight = expressViewHeight;
}

@Deprecated
public void setCsjNew(boolean csjNew) {
isCsjNew = csjNew;
}
Expand Down
2 changes: 1 addition & 1 deletion easybd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ group = 'com.github.bayescom'

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

def outputName = pomName + "_" + VersionName + ".aar"
Expand Down
Binary file removed easybd/libs/Baidu_MobAds_SDK_918.aar
Binary file not shown.
Binary file added easybd/libs/Baidu_MobAds_SDK_9241.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.baidu.mobads.sdk.api.XAdNativeResponse;

import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -89,7 +90,10 @@ public void onDislikeClick() {
* registerViewForInteraction()与BaiduNativeManager配套使用
* 警告:调用该函数来发送展现,勿漏!
*/
nativeResponse.registerViewForInteraction(setting.getAdContainer(), this);

List<View> clickViews = new ArrayList<>();
List<View> creativeViews = new ArrayList<>();
nativeResponse.registerViewForInteraction(setting.getAdContainer(),clickViews, creativeViews,this);

nativeResponse.setAdPrivacyListener(new NativeResponse.AdPrivacyListener() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion easycsj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.bayescom'

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

def outputName = pomName + "_" + VersionName + ".aar"
Expand Down
Binary file removed easycsj/libs/open_ad_sdk_4105.aar
Binary file not shown.
Binary file added easycsj/libs/open_ad_sdk_4908.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ private void startLoadAD() {
// 可选参数 设置是否支持deeplink
.setSupportDeepLink(true)
//请求原生广告时候需要设置,参数为TYPE_BANNER或TYPE_INTERACTION_AD
.setDownloadType(EasyCsjManger.getInstance().csj_downloadType)
.build();
ttAdNative.loadBannerExpressAd(adSlot, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ private void startLoadAD() {
//模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可
.setExpressViewAcceptedSize(500, 500)
.setSupportDeepLink(true)
.setDownloadType(EasyCsjManger.getInstance().csj_downloadType)
.setOrientation(orientation)//必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
package com.easyads.supplier.csj;

import android.app.Activity;
import android.view.View;

import com.easyads.EasyAdsManger;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.easyads.core.inter.EAInterstitialSetting;
import com.easyads.custom.EAInterstitialCustomAdapter;
import com.easyads.itf.BaseEnsureListener;
import com.easyads.model.EasyAdError;
import com.easyads.utils.EALog;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
import com.easyads.utils.EAUtil;

import java.lang.ref.SoftReference;
import java.util.List;

public class CsjInterstitialAdapter extends EAInterstitialCustomAdapter implements TTAdNative.NativeExpressAdListener {
public class CsjInterstitialAdapter extends EAInterstitialCustomAdapter {
private EAInterstitialSetting setting;
private TTNativeExpressAd mTTAd;
// private TTNativeExpressAd mTTAd;
private long startTime = 0;

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

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

@Override
public void doDestroy() {
if (mTTAd != null) {
mTTAd.destroy();
}

}

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

@Override
protected void doShowAD() {
if (isNewVersion) {
newVersionAd.showFullScreenVideoAd(getActivity());
return;
}
mTTAd.showInteractionExpressAd(getActivity());
}


@Override
public void onError(int i, String s) {
handleFailed(i, s);
}

@Override
public void onNativeExpressAdLoad(List<TTNativeExpressAd> ads) {
try {
EALog.high(TAG + "onNativeExpressAdLoad");
if (ads == null || ads.size() == 0) {
handleFailed(EasyAdError.ERROR_DATA_NULL, "ads.size() == 0");
return;
}
mTTAd = ads.get(0);
if (null == mTTAd) {
handleFailed(EasyAdError.ERROR_DATA_NULL, "null == mTTAd");
return;
}
mTTAd.setExpressInteractionListener(new TTNativeExpressAd.AdInteractionListener() {
@Override
public void onAdDismiss() {
EALog.high(TAG + "onAdDismiss");

if (null != setting) {
setting.adapterDidClosed(sdkSupplier);
EAUtil.switchMainThread(new BaseEnsureListener() {
@Override
public void ensure() {
try {
String nullTip = TAG + "请先加载广告或者广告已经展示过";
if (newVersionAd != null) {
newVersionAd.showFullScreenVideoAd(getActivity(), TTAdConstant.RitScenes.GAME_GIFT_BONUS, null);
newVersionAd = null;
} else {
EALog.e(nullTip);
}
} catch (Exception e) {
e.printStackTrace();
handleFailed(EasyAdError.parseErr(EasyAdError.ERROR_EXCEPTION_SHOW));
}

@Override
public void onAdClicked(View view, int type) {
EALog.high(TAG + "onAdClicked");

handleClick();
}

@Override
public void onAdShow(View view, int type) {
EALog.high(TAG + "onAdShow");
handleExposure();
}

@Override
public void onRenderFail(View view, String msg, int code) {
EALog.high(TAG + "ExpressView render fail:" + (System.currentTimeMillis() - startTime));
handleFailed(EasyAdError.parseErr(EasyAdError.ERROR_RENDER_FAILED, TAG + code + ", " + msg));
}

@Override
public void onRenderSuccess(View view, float width, float height) {
EALog.high(TAG + "ExpressView render suc:" + (System.currentTimeMillis() - startTime));
//返回view的宽高 单位 dp
}
});
startTime = System.currentTimeMillis();
mTTAd.render();
handleSucceed();
} catch (Throwable e) {
e.printStackTrace();
handleFailed(EasyAdError.parseErr(EasyAdError.ERROR_EXCEPTION_LOAD));
}
}
});
}


private void startLoadAD() {

//此处使用渠道配置参数versionTag,来确定是否为新插屏广告,以方便动态设置
if (sdkSupplier.versionTag == 1) {
isNewVersion = false;
} else if (sdkSupplier.versionTag == 2) {
isNewVersion = true;
} else {//如果未设置versionTag信息,取广告位上的设置
if (setting != null) {
isNewVersion = setting.isCsjNew();
} else {//广告位为配置默认为新版本
isNewVersion = true;
}
}
EALog.simple(TAG + "当前广告是否为'新插屏': " + isNewVersion);


TTAdNative ttAdNative = CsjUtil.getADManger(this).createAdNative(getActivity());
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(sdkSupplier.adspotId)
.setSupportDeepLink(true)
.setExpressViewAcceptedSize(setting.getCsjExpressViewWidth(), setting.getCsjExpressViewHeight())
.setDownloadType(EasyCsjManger.getInstance().csj_downloadType)
.build();
if (isNewVersion) {
ttAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
@Override
public void onError(int i, String s) {
handleFailed(i, s);
}
ttAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
@Override
public void onError(int i, String s) {
handleFailed(i, s);
}

@Override
public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ttFullScreenVideoAd) {
try {
EALog.high(TAG + "onFullScreenVideoAdLoad");
@Override
public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ttFullScreenVideoAd) {
try {
EALog.high(TAG + "onFullScreenVideoAdLoad");

newVersionAd = ttFullScreenVideoAd;
if (newVersionAd == null) {
handleFailed(EasyAdError.ERROR_DATA_NULL, "new ints ad null");
return;
}
newVersionAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
@Override
public void onAdShow() {
EALog.high(TAG + "newVersionAd onAdShow");
handleExposure();
}

newVersionAd = ttFullScreenVideoAd;
if (newVersionAd == null) {
handleFailed(EasyAdError.ERROR_DATA_NULL, "new ints ad null");
return;
@Override
public void onAdVideoBarClick() {
EALog.high(TAG + "newVersionAd onAdVideoBarClick");
handleClick();
}
newVersionAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
@Override
public void onAdShow() {
EALog.high(TAG + "newVersionAd onAdShow");
handleExposure();
}

@Override
public void onAdVideoBarClick() {
EALog.high(TAG + "newVersionAd onAdVideoBarClick");
handleClick();
}

@Override
public void onAdClose() {
EALog.high(TAG + "newVersionAd onAdClose");

if (setting != null)
setting.adapterDidClosed(sdkSupplier);
}

@Override
public void onVideoComplete() {
EALog.high(TAG + "newVersionAd onVideoComplete");
}

@Override
public void onSkippedVideo() {
EALog.high(TAG + "newVersionAd onSkippedVideo");
}
});
handleSucceed();

} catch (Throwable e) {
e.printStackTrace();
handleFailed(EasyAdError.ERROR_EXCEPTION_LOAD, "");
}
}

@Override
public void onFullScreenVideoCached() {
EALog.high(TAG + "onFullScreenVideoCached");
@Override
public void onAdClose() {
EALog.high(TAG + "newVersionAd onAdClose");

}
if (setting != null)
setting.adapterDidClosed(sdkSupplier);
}

@Override
public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) {
try {
String ad = "";
if (ttFullScreenVideoAd != null) {
ad = ttFullScreenVideoAd.toString();
@Override
public void onVideoComplete() {
EALog.high(TAG + "newVersionAd onVideoComplete");
}
EALog.high(TAG + "onFullScreenVideoCached( " + ad + ")");
} catch (Throwable e) {
e.printStackTrace();
}

@Override
public void onSkippedVideo() {
EALog.high(TAG + "newVersionAd onSkippedVideo");
}
});
handleSucceed();

} catch (Throwable e) {
e.printStackTrace();
handleFailed(EasyAdError.ERROR_EXCEPTION_LOAD, "");
}
});
} else {
ttAdNative.loadInteractionExpressAd(adSlot, this);
}
}
}

@Override
public void onFullScreenVideoCached() {
EALog.high(TAG + "onFullScreenVideoCached");

}

@Override
public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) {
try {
String ad = "";
if (ttFullScreenVideoAd != null) {
ad = ttFullScreenVideoAd.toString();
}
EALog.high(TAG + "onFullScreenVideoCached( " + ad + ")");
} catch (Throwable e) {
e.printStackTrace();
}

}
});
}

}
Loading

0 comments on commit f334384

Please sign in to comment.