Commit 44569fae authored by jyx's avatar jyx

修复信息流加载失败问题

parent 7e4866d2
......@@ -14,38 +14,20 @@ object ExpressManager {
* 加载应用内信息流
* @param isMain 是否是网赚信息流
*/
fun loadExpress(isMain: Boolean) {
fun loadExpress(isMain: Boolean = false, _frameLayout: FrameLayout? = null) {
if (AppConfig.groMoreVideoAdCount > 0) {
GroMoreCarrierExpressManager.instance.loadADFrameLayout(isMain)
GroMoreCarrierExpressManager.instance.loadADFrameLayout(isMain, _frameLayout)
} else {
PreLoadExpressManager.loadADFrameLayout()
}
}
/**
* 加载应用信息流
* @param isMain 是否是网赚信息流
* 加载应用信息流
* @param isScreen 是否是锁屏信息流
*/
fun loadExpress(isMain: Boolean, _frameLayout: FrameLayout? = null) {
if (AppConfig.groMoreVideoAdCount > 0) {
GroMoreCarrierExpressManager.instance.loadADFrameLayout(isMain, _frameLayout)
} else {
PreLoadExpressManager.loadADFrameLayout()
}
}
/** 加载应用外信息流 */
fun loadAppOutExpress(isScreen: Boolean = false) {
if (AppConfig.groMoreVideoAdCount > 0) {
AppOutGroMoreCarrierExpressManager.instance.loadADFrameLayout(isScreen)
}
}
/** 加载应用外信息流 */
fun loadAppOutExpress(isScreen: Boolean = false, _frameLayout: FrameLayout? = null) {
if (AppConfig.groMoreVideoAdCount > 0) {
AppOutGroMoreCarrierExpressManager.instance.loadADFrameLayout(isScreen, _frameLayout)
}
AppOutGroMoreCarrierExpressManager.instance.loadADFrameLayout(isScreen, _frameLayout)
}
/** 获取应用内信息流 */
......@@ -59,10 +41,7 @@ object ExpressManager {
/** 获取应用外信息流 */
fun getAppOutExpressFrameLayout(): FrameLayout? {
if (AppConfig.groMoreVideoAdCount > 0) {
return AppOutGroMoreCarrierExpressManager.instance.getADFrameLayout()
}
return null
return AppOutGroMoreCarrierExpressManager.instance.getADFrameLayout()
}
val lp = RelativeLayout.LayoutParams(
......
package com.mints.flowbox.ad.express
import com.mints.flowbox.BuildConfig
import com.mints.flowbox.utils.LogUtil
import com.mints.flowbox.utils.TimeRender
/**
*
* @author jyx
* @date 2021/7/26
* @des 预加载信息流
*/
class PreOutExpressManager {
private val TAG = PreOutExpressManager::class.java.simpleName
private val adLoadTime: Long = 0 // 广告展示时间,45分钟后当前广告失效,重新预加载广告
private var adPreingTime: Long = 0 // 防止预加载超时 2分钟
private var isLoadSuccess = 0 //0-加载失败/未加载 1-加载中 2-加载成功
fun preloadExpress() {
val isOversped = TimeRender.isOversped45Min(adLoadTime, 45)
val isPreingOversped = TimeRender.isOversped45Min(adPreingTime, 2)
if (BuildConfig.DEBUG) {
LogUtil.d(
TAG,
"信息流预加载 ------> \n 1、进入预加载 isLoadSuccess=" + isLoadSuccess + " isOversped=" + isOversped
+ " isPreingOversped=" + isPreingOversped
)
}
if (isLoadSuccess == 0 // 加载失败
|| (adLoadTime > 0 && isOversped) // 广告超过45分钟
|| (adPreingTime > 0 && isPreingOversped && isLoadSuccess == 1) // 预加载超时2分钟
) {
LogUtil.d(TAG, "信息流预加载 ------> \n 2、执行预加载去了=$isLoadSuccess")
adPreingTime = System.currentTimeMillis()
isLoadSuccess = 1
ExpressManager.loadAppOutExpress(true)
}
}
fun getExpress() {
}
}
\ No newline at end of file
......@@ -21,9 +21,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
private val TAG = PreLoadExpressManager::class.java.simpleName
// @Volatile
// private var currentIndex = 0
@Volatile
private var mAdFrameLayout: FrameLayout? = null
......@@ -51,18 +48,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
fun loadADFrameLayout() {
mAdFrameLayout?.removeAllViews()
// when (++currentIndex) {
// 1 -> {
// TTPreLoadExpressManager.getInstance().loadTtFrameLayout(mAdFrameLayout)
// }
// 2 -> {
// YlhPreLoadExpressManager.loadYlhFrameLayout()
// }
// 3 -> {
// KsPreLoadExpressManager.loadKsFrameLayout(mAdFrameLayout as ViewGroup)
// }
// }
when (getRandomWeight()) {
Constant.CSJ_EXPRESS_AD -> TTPreLoadExpressManager.getInstance()
.loadTtFrameLayout(mAdFrameLayout)
......@@ -123,8 +108,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
}
fun getADFrameLayout(): FrameLayout? {
// if (currentIndex >= 3) currentIndex = 0
return mAdFrameLayout
}
......@@ -135,9 +118,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
}
override fun onTTAdLoadSuc(view: FrameLayout?) {
// if (currentIndex == 1) {
// mAdFrameLayout = adFrameLayout
// }
if (view != null) {
AppConfig.isPreExpressAwardActivity = true
}
......@@ -145,9 +125,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
}
override fun onYlhAdLoadSuc(view: NativeExpressADView?) {
// if (currentIndex == 2) {
// mAdFrameLayout?.addView(view)
// }
if (view != null) {
AppConfig.isPreExpressAwardActivity = true
}
......@@ -155,9 +132,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
}
override fun onKSAdLoadSuc(view: View?) {
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
if (view != null) {
AppConfig.isPreExpressAwardActivity = true
}
......@@ -165,9 +139,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
}
override fun onGMAdLoadSuc(view: View?) {
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
if (view != null) {
AppConfig.isPreExpressAwardActivity = true
}
......
......@@ -41,11 +41,8 @@ import com.mints.flowbox.ui.widgets.dialog.PowerDialog;
import com.mints.flowbox.utils.LogUtil;
import com.mints.library.utils.CommonUtils;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
/**
* GroMore开屏广告Activity示例
*/
......@@ -113,7 +110,7 @@ public class SplashGroMoreActivity extends BaseActivity implements SplashView {
TrackManager.getInstance().firstApiWithUid();
// 预加载弹窗信息流
ExpressManager.INSTANCE.loadExpress(true);
ExpressManager.INSTANCE.loadExpress(true, null);
mMainHandler = new Handler(Looper.getMainLooper());
......
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