Commit dd0e18e0 authored by wangxuewei's avatar wangxuewei

[提交人]:王雪伟

[提交简述] :多多菜园
[实现方案] :1.0.3_预加载广告
parent 868b20b8
...@@ -47,12 +47,12 @@ class BaseApplication : MultiDexApplication() { ...@@ -47,12 +47,12 @@ class BaseApplication : MultiDexApplication() {
// .Build() // .Build()
// ); // );
//TODO Android 9及以上必须设置 (聚合快手时必须添加) //TODO Android 9及以上必须设置 (聚合快手时必须添加)
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// val processName = Application.getProcessName() val processName = Application.getProcessName()
// if (packageName != processName) { if (packageName != processName) {
// WebView.setDataDirectorySuffix(processName) WebView.setDataDirectorySuffix(processName)
// } }
// } }
UMConfigure.setLogEnabled(true) UMConfigure.setLogEnabled(true)
UMConfigure.init(this, "5f9bb48945b2b751a91fb2d5", "", UMConfigure.DEVICE_TYPE_PHONE, "") UMConfigure.init(this, "5f9bb48945b2b751a91fb2d5", "", UMConfigure.DEVICE_TYPE_PHONE, "")
......
...@@ -92,7 +92,7 @@ dependencies { ...@@ -92,7 +92,7 @@ dependencies {
api 'com.tencent.bugly:crashreport:latest.release' api 'com.tencent.bugly:crashreport:latest.release'
api 'com.tencent.bugly:nativecrashreport:latest.release' api 'com.tencent.bugly:nativecrashreport:latest.release'
api('cn.vlion.inland:inlandmix:9.8.5') { api('cn.vlion.inland:inlandmix:9.8.8') {
exclude group: 'cn.vlion.inland', module: 'inlandb' exclude group: 'cn.vlion.inland', module: 'inlandb'
exclude group: 'cn.vlion.inland', module: 'inlandg' exclude group: 'cn.vlion.inland', module: 'inlandg'
exclude group: 'cn.vlion.inland', module: 'inlands' exclude group: 'cn.vlion.inland', module: 'inlands'
...@@ -106,7 +106,7 @@ dependencies { ...@@ -106,7 +106,7 @@ dependencies {
exclude group: 'com.github.bumptech.glide' exclude group: 'com.github.bumptech.glide'
exclude group: 'com.tuia' exclude group: 'com.tuia'
exclude group: 'cn.vlion.inland', module: 'inlandhy' exclude group: 'cn.vlion.inland', module: 'inlandhy'
exclude group: 'com.mintegral.msdk' // exclude group: 'com.mintegral.msdk'
exclude group: 'cn.vlion.inlandsh' exclude group: 'cn.vlion.inlandsh'
} }
......
...@@ -555,6 +555,7 @@ object AdManager { ...@@ -555,6 +555,7 @@ object AdManager {
} }
override fun onAdFail() { override fun onAdFail() {
1
Log.d(TAG, "onAdFail totalEntity.size" + totalEntity.size) Log.d(TAG, "onAdFail totalEntity.size" + totalEntity.size)
AdCache.rewardList.put(slotName, totalEntity) AdCache.rewardList.put(slotName, totalEntity)
if (totalEntity.size > 0) { if (totalEntity.size > 0) {
...@@ -566,6 +567,8 @@ object AdManager { ...@@ -566,6 +567,8 @@ object AdManager {
} else {//未超时 走缓存 } else {//未超时 走缓存
playCacheRewardAd(mActivity, newsEntitys, listener, this) playCacheRewardAd(mActivity, newsEntitys, listener, this)
} }
} else {
Utils.showToast(mActivity, "视频加载失败...")
} }
} }
} }
......
...@@ -405,6 +405,7 @@ object GDTAdUtils { ...@@ -405,6 +405,7 @@ object GDTAdUtils {
//=============================================预加载=========================================== //=============================================预加载===========================================
private var zxVideoListener: ZXADVideoListener? = null private var zxVideoListener: ZXADVideoListener? = null
private var ZXADPlayListener: ZXADCallback? = null
fun loadCacheRewardAd( fun loadCacheRewardAd(
activity: Activity, activity: Activity,
entity: CacheAdEntity.CodeConfig entity: CacheAdEntity.CodeConfig
...@@ -459,11 +460,14 @@ object GDTAdUtils { ...@@ -459,11 +460,14 @@ object GDTAdUtils {
override fun onError(p0: AdError?) { override fun onError(p0: AdError?) {
Log.d(TAG, "广点通 激励视频 onError" + p0?.errorMsg) Log.d(TAG, "广点通 激励视频 onError" + p0?.errorMsg)
zxVideoListener?.onError() zxVideoListener?.onError()
ZXADPlayListener?.onAdFail()
} }
override fun onADShow() { override fun onADShow() {
Log.d(TAG, "广点通 激励视频 onADShow") Log.d(TAG, "广点通 激励视频 onADShow")
ZXADPlayListener?.onAdSuccess()
zxVideoListener?.onAdShow() zxVideoListener?.onAdShow()
} }
}) // 有声播放 }) // 有声播放
cacheRewardVideoAD.loadAD() cacheRewardVideoAD.loadAD()
...@@ -480,10 +484,11 @@ object GDTAdUtils { ...@@ -480,10 +484,11 @@ object GDTAdUtils {
callback: ZXADCallback callback: ZXADCallback
) { ) {
zxVideoListener = listener zxVideoListener = listener
ZXADPlayListener = callback
var rewardVideoAD = getRewardVideo(activity, newsEntity.codeId) var rewardVideoAD = getRewardVideo(activity, newsEntity.codeId)
if (rewardVideoAD != null) { if (rewardVideoAD != null) {
if (!rewardVideoAD.hasShown()) { if (!rewardVideoAD.hasShown()) {
callback.onAdSuccess() // callback.onAdSuccess()
rewardVideoAD.showAD() rewardVideoAD.showAD()
} else { } else {
// playCacheRewardAd(activity, newsEntity, listener, callback) // playCacheRewardAd(activity, newsEntity, listener, callback)
......
...@@ -287,6 +287,7 @@ object RSADUtils { ...@@ -287,6 +287,7 @@ object RSADUtils {
// private val mRsAdCache: ConcurrentLinkedQueue<VideoManager> = // private val mRsAdCache: ConcurrentLinkedQueue<VideoManager> =
// ConcurrentLinkedQueue<VideoManager>() // ConcurrentLinkedQueue<VideoManager>()
private var zxVideoListener: ZXADVideoListener? = null private var zxVideoListener: ZXADVideoListener? = null
private var zxPlayListener: ZXADCallback? = null
//预加载激励视频 //预加载激励视频
fun loadCacheRewardAd( fun loadCacheRewardAd(
...@@ -321,12 +322,14 @@ object RSADUtils { ...@@ -321,12 +322,14 @@ object RSADUtils {
override fun onVideoPlayStart(adId: String) { override fun onVideoPlayStart(adId: String) {
Log.e(TAG, "2瑞狮 onVideoPlayStart:adId=$adId") Log.e(TAG, "2瑞狮 onVideoPlayStart:adId=$adId")
zxVideoListener?.onAdShow() zxVideoListener?.onAdShow()
zxPlayListener?.onAdSuccess()
} }
override fun onVideoPlayFailed(adId: String, code: Int, msg: String) { override fun onVideoPlayFailed(adId: String, code: Int, msg: String) {
Log.e(TAG, "瑞狮 onVideoPlayFailed:adId=" + adId + "code=" + code + "msg=" + msg) Log.e(TAG, "瑞狮 onVideoPlayFailed:adId=" + adId + "code=" + code + "msg=" + msg)
AdManager.initCacheAdList(activity) AdManager.initCacheAdList(activity)
zxVideoListener?.onError() zxVideoListener?.onError()
zxPlayListener?.onAdFail()
} }
override fun onVideoClosed(adId: String) { override fun onVideoClosed(adId: String) {
...@@ -353,7 +356,7 @@ object RSADUtils { ...@@ -353,7 +356,7 @@ object RSADUtils {
//广告请求失败 //广告请求失败
override fun onRequestFailed(adId: String, code: Int, errorMsg: String) { override fun onRequestFailed(adId: String, code: Int, errorMsg: String) {
AdManager.initCacheAdList(activity) AdManager.initCacheAdList(activity)
zxPlayListener?.onAdFail()
Log.e( Log.e(
TAG, TAG,
"onRequestFailed:adId=" + adId + "code=" + code + "errorMsg=" + errorMsg "onRequestFailed:adId=" + adId + "code=" + code + "errorMsg=" + errorMsg
...@@ -367,9 +370,10 @@ object RSADUtils { ...@@ -367,9 +370,10 @@ object RSADUtils {
newsEntity: NewsEntity, newsEntity: NewsEntity,
listener: ZXADVideoListener, callback: ZXADCallback listener: ZXADVideoListener, callback: ZXADCallback
) { ) {
zxVideoListener = listener
zxVideoListener = listener zxVideoListener = listener
if (VideoManager.getInstance().isReady) { if (VideoManager.getInstance().isReady) {
callback.onAdSuccess() // callback.onAdSuccess()
VideoManager.getInstance().showVideo(); VideoManager.getInstance().showVideo();
} else { } else {
callback.onAdFail() callback.onAdFail()
......
...@@ -281,6 +281,7 @@ object SMADUtils { ...@@ -281,6 +281,7 @@ object SMADUtils {
private val mSgmAdCache: ConcurrentLinkedQueue<Map<WindRewardAdRequest, WindRewardedVideoAd>> = private val mSgmAdCache: ConcurrentLinkedQueue<Map<WindRewardAdRequest, WindRewardedVideoAd>> =
ConcurrentLinkedQueue() ConcurrentLinkedQueue()
private var zxVideoListener: ZXADVideoListener? = null private var zxVideoListener: ZXADVideoListener? = null
private var zxPlayListener: ZXADCallback? = null
//只能在播放完之后缓存 //只能在播放完之后缓存
fun loadCacheRewardAd( fun loadCacheRewardAd(
...@@ -299,6 +300,7 @@ object SMADUtils { ...@@ -299,6 +300,7 @@ object SMADUtils {
Log.d(TAG, "Sigmob 激励 onVideoAdPlayError" + p0?.message) Log.d(TAG, "Sigmob 激励 onVideoAdPlayError" + p0?.message)
AdManager.initCacheAdList(activity) AdManager.initCacheAdList(activity)
zxVideoListener?.onError() zxVideoListener?.onError()
zxPlayListener?.onAdFail()
} }
override fun onVideoAdPreLoadFail(p0: String?) { override fun onVideoAdPreLoadFail(p0: String?) {
...@@ -324,6 +326,7 @@ object SMADUtils { ...@@ -324,6 +326,7 @@ object SMADUtils {
override fun onVideoAdLoadSuccess(p0: String?) { override fun onVideoAdLoadSuccess(p0: String?) {
Log.d(TAG, "Sigmob 激励 onVideoAdLoadSuccess") Log.d(TAG, "Sigmob 激励 onVideoAdLoadSuccess")
zxVideoListener?.onSuccess() zxVideoListener?.onSuccess()
zxPlayListener?.onAdSuccess()
} }
override fun onVideoAdPreLoadSuccess(p0: String?) { override fun onVideoAdPreLoadSuccess(p0: String?) {
...@@ -338,6 +341,7 @@ object SMADUtils { ...@@ -338,6 +341,7 @@ object SMADUtils {
override fun onVideoAdLoadError(p0: WindAdError?, p1: String?) { override fun onVideoAdLoadError(p0: WindAdError?, p1: String?) {
Log.d(TAG, "Sigmob 激励 onVideoAdLoadError" + p1) Log.d(TAG, "Sigmob 激励 onVideoAdLoadError" + p1)
AdManager.initCacheAdList(activity) AdManager.initCacheAdList(activity)
zxPlayListener?.onAdFail()
} }
}) })
...@@ -352,6 +356,7 @@ object SMADUtils { ...@@ -352,6 +356,7 @@ object SMADUtils {
callback: ZXADCallback callback: ZXADCallback
) { ) {
zxVideoListener = listener zxVideoListener = listener
zxPlayListener = callback
if (mSgmAdCache.size > 0) { if (mSgmAdCache.size > 0) {
var rewardVideoADMap = mSgmAdCache.poll() var rewardVideoADMap = mSgmAdCache.poll()
rewardVideoADMap.forEach { rewardVideoADMap.forEach {
...@@ -359,7 +364,7 @@ object SMADUtils { ...@@ -359,7 +364,7 @@ object SMADUtils {
it.value it.value
if (it.value.isReady(it.key.placementId)) { if (it.value.isReady(it.key.placementId)) {
//广告播放 //广告播放
callback.onAdSuccess() // callback.onAdSuccess()
it.value.show(activity, it.key) it.value.show(activity, it.key)
} else { } else {
callback.onAdFail() callback.onAdFail()
......
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