Commit d966e4f8 authored by jyx's avatar jyx

更新GromoreSDK版本

parent b1db4aa0
......@@ -64,6 +64,7 @@ android {
buildConfigField "String", "GROMORE_APP_ID", GROMORE_APP_ID
buildConfigField "String", "GROMORE_SPLASH_CODE", GROMORE_SPLASH_CODE
buildConfigField "String", "GROMORE_VIDEO_CODE", GROMORE_VIDEO_CODE
buildConfigField "String", "GROMORE_EXPRESS_CODE", GROMORE_EXPRESS_CODE
buildConfigField "String", "WEIXIN_APP_PAY_ID", WEIXIN_APP_PAY_ID
//混淆
......@@ -83,6 +84,7 @@ android {
buildConfigField "String", "GROMORE_APP_ID", GROMORE_APP_ID
buildConfigField "String", "GROMORE_SPLASH_CODE", GROMORE_SPLASH_CODE
buildConfigField "String", "GROMORE_VIDEO_CODE", GROMORE_VIDEO_CODE
buildConfigField "String", "GROMORE_EXPRESS_CODE", GROMORE_EXPRESS_CODE
buildConfigField "String", "WEIXIN_APP_PAY_ID", WEIXIN_APP_PAY_ID
//混淆
......@@ -234,7 +236,7 @@ dependencies {
// umeng 接入
// 穿山甲聚合 接入【穿山甲、快手】
// 穿山甲
// 穿山甲短剧
implementation("com.pangle.cn:pangrowth-sdk:3.7.0.1") {
exclude group: 'com.pangle.cn', module: 'pangrowth-game-sdk'
exclude group: 'com.pangle.cn', module: 'pangrowth-novel-sdk'
......@@ -245,6 +247,8 @@ dependencies {
exclude group: 'com.tencent.mm.opensdk', module: 'wechat-sdk-android'
}
implementation "com.pangle.cn:mediation-sdk:5.3.6.0"
// 腾讯播放器
implementation "com.tencent.liteav:LiteAVSDK_Player:latest.release"
......
......@@ -9,7 +9,7 @@ import androidx.multidex.MultiDexApplication;
import com.downloader.PRDownloader;
import com.downloader.PRDownloaderConfig;
import com.mints.helivideo.ad.TTGroMoreAdManagerHolder;
import com.mints.helivideo.ad.TTAdManagerHolder;
import com.mints.helivideo.common.Constant;
import com.mints.helivideo.manager.TXCSDKService;
import com.mints.helivideo.manager.UmengManager;
......@@ -41,23 +41,6 @@ public class MintsApplication extends MultiDexApplication {
private LoanService loanService;
private V6Service v6Service;
// private HttpProxyCacheServer proxy = null;
//
// public static class StaticParams {
// public static HttpProxyCacheServer getProxy() {
// MintsApplication app = (MintsApplication) MintsApplication.getContext();
// return app.proxy == null ? app.newProxy() : app.proxy;
// }
// }
//
// private HttpProxyCacheServer newProxy() {
// return new HttpProxyCacheServer.Builder(this)
// .maxCacheSize(1024 * 1024 * 1024)
// .maxCacheFilesCount(30)
// .build();
// }
/**
* 获取全局context
*/
......@@ -96,7 +79,7 @@ public class MintsApplication extends MultiDexApplication {
initMiitHelper();
TTGroMoreAdManagerHolder.init(this);
TTAdManagerHolder.init(this);
TXCSDKService.init(this);
......
package com.mints.helivideo.ad;
import android.content.Context;
import android.util.Log;
import com.bytedance.hume.readapk.HumeSDK;
import com.bytedance.sdk.openadsdk.TTAdConfig;
import com.bytedance.sdk.openadsdk.TTAdManager;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTCustomController;
import com.bytedance.sdk.openadsdk.mediation.init.MediationConfigUserInfoForSegment;
import com.bytedance.sdk.openadsdk.mediation.init.MediationPrivacyConfig;
import com.mints.helivideo.BuildConfig;
import com.mints.helivideo.MintsApplication;
import com.mints.helivideo.common.Constant;
import com.mints.helivideo.utils.DeviceUuidFactory;
import java.util.HashMap;
import java.util.Map;
/**
* 可以用一个单例来保存TTAdManager实例,在需要初始化sdk的时候调用
*/
public class TTAdManagerHolder {
private static final String TT_AD_APPID = BuildConfig.GROMORE_APP_ID;
private static final String TT_AD_NAME = Constant.MINTS_APP_NAME;
private static final String TAG = "TTAdManagerHolder";
private static boolean sInit;
public static TTAdManager get() {
return TTAdSdk.getAdManager();
}
public static void init(final Context context) {
//初始化穿山甲SDK
doInit(context);
}
//step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明
private static void doInit(Context context) {
if (!sInit) {
TTAdSdk.init(context, buildConfig(context), new TTAdSdk.InitCallback() {
@Override
public void success() {
Log.i(TAG, "success: " + TTAdSdk.isInitSuccess());
}
@Override
public void fail(int code, String msg) {
Log.i(TAG, "fail: code = " + code + " msg = " + msg);
}
});
sInit = true;
}
}
private static TTAdConfig buildConfig(Context context) {
return new TTAdConfig.Builder()
/**
* 注:需要替换成在媒体平台申请的appID ,切勿直接复制
*/
.appId(TT_AD_APPID)
.appName(TT_AD_NAME)
/**
* 上线前需要关闭debug开关,否则会影响性能
*/
.debug(false)
/**
* 使用聚合功能此开关必须设置为true,默认为false,不会初始化聚合模板,聚合功能会吟唱
*/
.useMediation(true)
// .customController(getTTCustomController()) //如果您需要设置隐私策略请参考该api
// .setMediationConfig(new MediationConfig.Builder() //可设置聚合特有参数详细设置请参考该api
// .setMediationConfigUserInfoForSegment(getUserInfoForSegment())//如果您需要配置流量分组信息请参考该api
// .build())
.build();
}
private static MediationConfigUserInfoForSegment getUserInfoForSegment(){
MediationConfigUserInfoForSegment userInfo = new MediationConfigUserInfoForSegment();
userInfo.setUserId(new DeviceUuidFactory().getDeviceUuid().toString());
userInfo.setGender(MediationConfigUserInfoForSegment.GENDER_MALE);
// userInfo.setChannel("msdk-channel");
userInfo.setSubChannel(HumeSDK.getChannel(MintsApplication.getContext()));
// userInfo.setAge(999);
// userInfo.setUserValueGroup("msdk-demo-user-value-group");
Map<String, String> customInfos = new HashMap<>();
// customInfos.put("aaaa", "test111");
// customInfos.put("bbbb", "test222");
userInfo.setCustomInfos(customInfos);
return userInfo;
}
private static TTCustomController getTTCustomController(){
return new TTCustomController() {
@Override
public boolean isCanUseWifiState() {
return super.isCanUseWifiState();
}
@Override
public String getMacAddress() {
return super.getMacAddress();
}
@Override
public boolean isCanUseWriteExternal() {
return super.isCanUseWriteExternal();
}
@Override
public String getDevOaid() {
return super.getDevOaid();
}
@Override
public boolean isCanUseAndroidId() {
return super.isCanUseAndroidId();
}
@Override
public String getAndroidId() {
return super.getAndroidId();
}
@Override
public MediationPrivacyConfig getMediationPrivacyConfig() {
return new MediationPrivacyConfig() {
@Override
public boolean isLimitPersonalAds() {
return super.isLimitPersonalAds();
}
@Override
public boolean isProgrammaticRecommend() {
return super.isProgrammaticRecommend();
}
};
}
@Override
public boolean isCanUsePermissionRecordAudio() {
return super.isCanUsePermissionRecordAudio();
}
};
}
}
package com.mints.helivideo.ad;
import android.content.Context;
import android.provider.Settings;
import com.bytedance.hume.readapk.HumeSDK;
import com.bytedance.msdk.api.v2.GMAdConfig;
import com.bytedance.msdk.api.v2.GMAdConstant;
import com.bytedance.msdk.api.v2.GMConfigUserInfoForSegment;
import com.bytedance.msdk.api.v2.GMMediationAdSdk;
import com.bytedance.msdk.api.v2.GMPangleOption;
import com.bytedance.msdk.api.v2.GMPrivacyConfig;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.mints.helivideo.BuildConfig;
import com.mints.helivideo.MintsApplication;
import com.mints.helivideo.common.Constant;
import com.mints.helivideo.utils.DeviceUuidFactory;
import com.mints.helivideo.video.DPHolderManager;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Handler;
/**
* 穿山甲广告
*/
public class TTGroMoreAdManagerHolder {
public static final String TT_AD_APPID = BuildConfig.GROMORE_APP_ID;
public static final String TT_AD_NAME = Constant.MINTS_APP_NAME;
private static boolean sInit;
public static com.bytedance.sdk.openadsdk.TTAdManager get() {
if (!sInit) {
throw new RuntimeException("TTAdSdk is not init, please check.");
}
return TTAdSdk.getAdManager();
}
public static void init(Context context) {
doInit(context);
}
//step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明
private static void doInit(Context context) {
if (!sInit) {
GMMediationAdSdk.initialize(context, buildV2Config(context));
sInit = true;
}
}
public static String getVersion() {
return TTAdSdk.getAdManager().getSDKVersion();
}
public static GMAdConfig buildV2Config(Context context) {
GMConfigUserInfoForSegment userInfo = new GMConfigUserInfoForSegment();
userInfo.setUserId(new DeviceUuidFactory().getDeviceUuid().toString());
userInfo.setSubChannel(HumeSDK.getChannel(MintsApplication.getContext()));
Map<String, String> customInfos = new HashMap<>();
userInfo.setCustomInfos(customInfos);
return new GMAdConfig.Builder()
.setAppId(TT_AD_APPID)
.setAppName(TT_AD_NAME)
.setDebug(BuildConfig.DEBUG)//默认false,测试阶段打开,可以通过日志排查问题
.setPublisherDid(getAndroidId(context))
.setOpenAdnTest(BuildConfig.DEBUG)//开启第三方ADN测试时需要设置为true,会每次重新拉去最新配置,release 包情况下必须关闭.默认false
.setConfigUserInfoForSegment(userInfo)
.setPangleOption(new GMPangleOption.Builder()
.setIsPaid(false)
.setTitleBarTheme(GMAdConstant.TITLE_BAR_THEME_DARK)
.setAllowShowNotify(true)
.setAllowShowPageWhenScreenLock(false)
.setDirectDownloadNetworkType(GMAdConstant.NETWORK_STATE_WIFI, GMAdConstant.NETWORK_STATE_3G)
.setIsUseTextureView(false)
.setNeedClearTaskReset()
.setKeywords("")
.build())
.setPrivacyConfig(new GMPrivacyConfig() {
// 重写相应的函数,设置需要设置的权限开关,不重写的将采用默认值
// 例如,重写isCanUsePhoneState函数返回true,表示允许使用ReadPhoneState权限。
@Override
public boolean isCanUsePhoneState() {
return true;
}
})
.build();
}
public static String getAndroidId(Context context) {
String androidId = null;
try {
androidId = Settings.System.getString(context.getContentResolver(), Settings.System.ANDROID_ID);
} catch (Exception e) {
e.printStackTrace();
}
return androidId;
}
}
package com.mints.helivideo.ad.express
import android.widget.FrameLayout
/**
*
* @des 信息流回调
*/
interface ExpressAdCallback {
fun loadSuccess(adView: FrameLayout?)
fun renderSuccess(adView: FrameLayout?): Boolean
fun loadFail()
}
\ No newline at end of file
package com.mints.helivideo.ad.splash
import android.app.Activity
import android.view.View
import android.widget.FrameLayout
import com.bytedance.msdk.api.AdError
import com.bytedance.msdk.api.v2.ad.splash.GMSplashAd
import com.bytedance.msdk.api.v2.ad.splash.GMSplashAdListener
import com.bytedance.msdk.api.v2.ad.splash.GMSplashAdLoadCallback
import com.bytedance.msdk.api.v2.slot.GMAdSlotSplash
import com.bytedance.sdk.openadsdk.AdSlot
import com.bytedance.sdk.openadsdk.TTAdNative
import com.bytedance.sdk.openadsdk.TTAdSdk
import com.bytedance.sdk.openadsdk.TTSplashAd
import com.bytedance.sdk.openadsdk.mediation.MediationConstant
import com.bytedance.sdk.openadsdk.mediation.ad.MediationAdSlot
import com.bytedance.sdk.openadsdk.mediation.ad.MediationSplashRequestInfo
import com.mints.helivideo.BuildConfig
import com.mints.helivideo.ad.AdStatusListener
import com.mints.helivideo.utils.LogUtil
import com.mints.helivideo.utils.UIUtils
import com.mints.library.utils.json.JsonUtil
import java.lang.ref.WeakReference
/**
......@@ -19,9 +21,13 @@ import java.lang.ref.WeakReference
*/
object SplashManager {
// 兜底配置
// val pangleSplashBottom = object :
// MediationSplashRequestInfo(MediationConstant.ADN_PANGLE, "887382976", "5001121", "") {} //ok
private val TAG = SplashManager::class.java.simpleName
private var mTTSplashAd: GMSplashAd? = null
private var mTTSplashAd: TTSplashAd? = null
private const val AD_TIME_OUT = 5000 //开屏广告加载超时时间
private var isLoadSuccess = 0 //0-加载失败/未加载 1-加载中 2-加载成功
......@@ -33,49 +39,46 @@ object SplashManager {
*/
fun preLoadAd(activity: Activity) {
val weakActivity = WeakReference<Activity>(activity)
LogUtil.d(TAG, "gromore应用内开屏广告-> 1、进入预加载")
LogUtil.d(TAG, "gromore 开屏广告-> 1、进入预加载")
if (isLoadSuccess == 1) {
return
}
mTTSplashAd = GMSplashAd(weakActivity.get(), BuildConfig.GROMORE_SPLASH_CODE)
mTTSplashAd?.setAdSplashListener(mSplashAdListener)
val adSlot = GMAdSlotSplash.Builder()
.setImageAdSize(UIUtils.getScreenWidth(weakActivity.get()), UIUtils.getScreenHeight(weakActivity.get())) // 单位px
.setSplashPreLoad(true)//开屏gdt开屏广告预加载
.setMuted(false) //声音开启
.setTimeOut(AD_TIME_OUT)//设置超时
val adNativeLoader = TTAdSdk.getAdManager().createAdNative(weakActivity.get())
val adslot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_SPLASH_CODE)
.setImageAcceptedSize(
UIUtils.getScreenWidth(activity),
UIUtils.getScreenHeight(activity)
)
.setMediationAdSlot(
MediationAdSlot.Builder()
// .setMediationSplashRequestInfo(pangleSplashBottom)
.build()
)
.build()
//自定义兜底方案 选择使用
// val gmNetworkRequestInfo =
// PangleNetworkRequestInfo(TTGroMoreAdManagerHolder.CURRENT_USE_APPID, "102165872")
// //step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理
// mTTSplashAd?.loadAd(adSlot, gmNetworkRequestInfo, object : GMSplashAdLoadCallback {
mTTSplashAd?.loadAd(adSlot, object : GMSplashAdLoadCallback {
override fun onSplashAdLoadFail(adError: AdError) {
adNativeLoader.loadSplashAd(adslot, object : TTAdNative.SplashAdListener {
override fun onError(p0: Int, p1: String?) {
LogUtil.d(
TAG,
"gromore应用内开屏广告--> 3、Gromore onSplashAdLoadFail adErrorCode=${adError.code} " + adError.message + "list ==>" + JsonUtil.toJson(
mTTSplashAd?.adLoadInfoList
)
"gromore 开屏广告--> 3、Gromore onSplashAdLoadFail adErrorCode=${p0} " + p1
)
isLoadSuccess = 0
}
override fun onSplashAdLoadSuccess() {
LogUtil.d(TAG, "gromore应用内开屏广告--> 3、Gromore onSplashAdLoadSuccess ")
isLoadSuccess = 2
override fun onTimeout() {
LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onAdLoadTimeout")
isLoadSuccess = 0
}
override fun onAdLoadTimeout() {
LogUtil.d(TAG, "gromore应用内开屏广告--> 3、Gromore onAdLoadTimeout ")
isLoadSuccess = 0
override fun onSplashAdLoad(p0: TTSplashAd?) {
LogUtil.d(TAG, "gromore 开屏广告--> 3、Gromore onSplashAdLoadSuccess")
isLoadSuccess = 2
mTTSplashAd = p0
}
})
})
}
/**
......@@ -84,13 +87,16 @@ object SplashManager {
fun showAd(view: FrameLayout, adStatusListener: AdStatusListener?) {
this.adStatusListener = adStatusListener
isShowAd = false
if (mTTSplashAd != null && mTTSplashAd!!.isReady && isLoadSuccess == 2) {
LogUtil.d(TAG, "gromore应用内开屏广告--> 准备调用show")
mTTSplashAd?.showAd(view)
if (mTTSplashAd != null && isLoadSuccess == 2) {
LogUtil.d(TAG, "gromore 开屏广告--> 准备调用show")
mTTSplashAd?.let {
it.setSplashInteractionListener(adInteractionListener)
view.addView(it.splashView)
}
} else {
LogUtil.d(
TAG,
"gromore应用内开屏广告--> 准备调用show 失败 mTTSplashAd=${mTTSplashAd} isReady=${mTTSplashAd!!.isReady} isLoadSuccess=${isLoadSuccess}"
"gromore 开屏广告--> 准备调用show 失败 mTTSplashAd=${mTTSplashAd} isLoadSuccess=${isLoadSuccess}"
)
adStatusListener?.adFail()
}
......@@ -103,34 +109,23 @@ object SplashManager {
*/
fun isSuccessStatus() = isLoadSuccess == 2
var mSplashAdListener: GMSplashAdListener = object : GMSplashAdListener {
override fun onAdClicked() {
LogUtil.d(TAG, "gromore应用内开屏广告--> 7、onAdClicked ")
val adInteractionListener = object : TTSplashAd.AdInteractionListener {
override fun onAdClicked(p0: View?, p1: Int) {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdClicked ")
}
override fun onAdShow() {
override fun onAdShow(p0: View?, p1: Int) {
isShowAd = true
LogUtil.d(TAG, "gromore应用内开屏广告--> 6、onAdShow ")
}
override fun onAdShowFail(adError: AdError) {
LogUtil.d(
TAG,
"gromore应用内开屏广告--> 6、onAdShowFail ${adError.code} ${adError.message}"
)
adStatusListener?.adFail()
LogUtil.d(TAG, "gromore 开屏广告--> 6、onAdShow ")
}
override fun onAdSkip() {
LogUtil.d(TAG, "gromore应用内开屏广告--> 7、onAdSkip ")
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdSkip ")
adStatusListener?.adClose(null)
}
override fun onAdDismiss() {
LogUtil.d(TAG, "gromore应用内开屏广告--> 7、onAdDismiss ")
override fun onAdTimeOver() {
LogUtil.d(TAG, "gromore 开屏广告--> 7、onAdDismiss ")
adStatusListener?.adClose(null)
}
}
......@@ -141,7 +136,6 @@ object SplashManager {
fun getAdStatus() = isShowAd
fun onDestroy() {
mTTSplashAd?.destroy()
isLoadSuccess = 0
}
}
\ No newline at end of file
......@@ -2,8 +2,10 @@ package com.mints.helivideo.utils;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
......@@ -265,4 +267,21 @@ public class UIUtils {
}
}
}
public static int dp2px(int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
Resources.getSystem().getDisplayMetrics());
}
public static float getDensity(Context context) {
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics displayMetrics = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(displayMetrics);
return displayMetrics.density;
}
public static float getAdWidth(Context context) {
return getScreenWidth(context) / getDensity(context) - 40;
}
}
......@@ -46,3 +46,4 @@ RELEASE_UMENG_KEY=64b8de13a1a164591b5133df
GROMORE_APP_ID="5412556"
GROMORE_SPLASH_CODE="102398740"
GROMORE_VIDEO_CODE="102398300"
GROMORE_EXPRESS_CODE="102398300"
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