Commit df5f72b2 authored by mengcuiguang's avatar mengcuiguang

添加插屏广告关闭事件监听

parent 75dcdd43
......@@ -6,7 +6,6 @@ import android.util.Log;
import com.bytedance.msdk.api.AdError;
import com.bytedance.msdk.api.AdSlot;
import com.bytedance.msdk.api.GDTExtraOption;
import com.bytedance.msdk.api.TTAdConstant;
import com.bytedance.msdk.api.TTMediationAdSdk;
import com.bytedance.msdk.api.TTSettingConfigCallback;
......@@ -15,7 +14,7 @@ import com.bytedance.msdk.api.fullVideo.TTFullVideoAd;
import com.bytedance.msdk.api.fullVideo.TTFullVideoAdListener;
import com.bytedance.msdk.api.fullVideo.TTFullVideoAdLoadCallback;
import com.mints.flowbox.BuildConfig;
import com.mints.flowbox.ad.inscreen.InterstitialGroManager;
import com.mints.flowbox.ad.wifi.WifiAdStatusListener;
import com.mints.flowbox.common.Constant;
import com.mints.flowbox.manager.CsjGroMoreManager;
import com.mints.flowbox.manager.TrackManager;
......@@ -32,6 +31,8 @@ public class FullGroManager {
private static final String TAG = FullGroManager.class.getSimpleName();
private WifiAdStatusListener wifiAdStatusListener;
private TTFullVideoAd mTTFullVideoAd;
private Activity activity;
private boolean isLoadSuccess = false;
......@@ -149,6 +150,9 @@ public class FullGroManager {
@Override
public void onFullVideoAdClosed() {
if(wifiAdStatusListener!=null){
wifiAdStatusListener.adClose();
}
Log.d(TAG, "onFullVideoAdClosed");
}
......@@ -167,4 +171,8 @@ public class FullGroManager {
Log.d(TAG, "onSkippedVideo");
}
};
public void setWifiAdStatusListener(WifiAdStatusListener wifiAdStatusListener) {
this.wifiAdStatusListener = wifiAdStatusListener;
}
}
package com.mints.flowbox.ad.inscreen
import android.app.Activity
import com.mints.flowbox.ad.wifi.WifiAdStatusListener
import com.mints.flowbox.common.AppConfig
import com.mints.flowbox.common.Constant
import com.mints.flowbox.utils.LogUtil
/**
* 插屏广告管理
*/
class InsertScreenAdManager {
var insertScreenAdStatusListener2: InsertScreenAdStatusListener? = null
var wifiAdStatusListener: WifiAdStatusListener? = null
// groMore
private var interstitialGroManager: InterstitialGroManager? = null
......@@ -40,16 +40,20 @@ class InsertScreenAdManager {
}
interstitialGroManager = InterstitialGroManager()
interstitialGroManager?.loadInsertScreenAd(activity)
interstitialGroManager?.setInsertScreenAdStatusListener(object :
InsertScreenAdStatusListener {
interstitialGroManager?.setWifiAdStatusListener(object :
WifiAdStatusListener {
override fun adSuccess() {
insertScreenAdStatusListener2?.adSuccess()
wifiAdStatusListener?.adSuccess()
}
override fun adFail() {
insertScreenAdStatusListener2?.adFail()
wifiAdStatusListener?.adFail()
preLoadYlh(activity)
}
override fun adClose() {
}
})
}
......@@ -61,14 +65,18 @@ class InsertScreenAdManager {
}
interstitialYlhManager = InterstitialYlhManager()
interstitialYlhManager?.loadYlhInteractionAd(activity)
interstitialYlhManager?.setInsertScreenAdStatusListener(object :
InsertScreenAdStatusListener {
interstitialYlhManager?.setWifiAdStatusListener(object :
WifiAdStatusListener {
override fun adSuccess() {
insertScreenAdStatusListener2?.adSuccess()
wifiAdStatusListener?.adSuccess()
}
override fun adFail() {
insertScreenAdStatusListener2?.adFail()
wifiAdStatusListener?.adFail()
}
override fun adClose() {
}
})
}
......@@ -89,13 +97,15 @@ class InsertScreenAdManager {
fun onDestroy() {
interstitialGroManager?.onDestroy()
interstitialGroManager?.setWifiAdStatusListener(null)
interstitialGroManager = null
interstitialYlhManager?.onDestroy()
interstitialYlhManager?.setWifiAdStatusListener(null)
interstitialYlhManager = null
}
fun setInsertScreenAdStatusListener(insertScreenAdStatusListener: InsertScreenAdStatusListener?) {
this.insertScreenAdStatusListener2 = insertScreenAdStatusListener
fun setInsertScreenAdStatusListener(insertScreenAdStatusListener: WifiAdStatusListener?) {
this.wifiAdStatusListener = insertScreenAdStatusListener
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import com.bytedance.msdk.api.interstitial.TTInterstitialAd;
import com.bytedance.msdk.api.interstitial.TTInterstitialAdListener;
import com.bytedance.msdk.api.interstitial.TTInterstitialAdLoadCallback;
import com.mints.flowbox.BuildConfig;
import com.mints.flowbox.ad.wifi.WifiAdStatusListener;
import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.common.Constant;
import com.mints.flowbox.manager.CsjGroMoreManager;
......@@ -27,7 +28,7 @@ public class InterstitialGroManager {
private static final String TAG = InterstitialGroManager.class.getSimpleName();
private InsertScreenAdStatusListener insertScreenAdStatusListener;
private WifiAdStatusListener wifiAdStatusListener;
private TTInterstitialAd mInterstitialAd;
private Activity activity;
......@@ -87,8 +88,8 @@ public class InterstitialGroManager {
mInterstitialAd.loadAd(adSlot, new TTInterstitialAdLoadCallback() {
@Override
public void onInterstitialLoadFail(AdError adError) {
if (insertScreenAdStatusListener != null) {
insertScreenAdStatusListener.adFail();
if (wifiAdStatusListener != null) {
wifiAdStatusListener.adFail();
}
LogUtil.d(TAG, "code=" + adError.code + "message=" + adError.message);
......@@ -148,8 +149,8 @@ public class InterstitialGroManager {
*/
@Override
public void onInterstitialClosed() {
if (insertScreenAdStatusListener != null) {
insertScreenAdStatusListener.adSuccess();
if (wifiAdStatusListener != null) {
wifiAdStatusListener.adSuccess();
}
AppConfig.isShowInsertScreen = false;
}
......@@ -173,7 +174,7 @@ public class InterstitialGroManager {
}
};
public void setInsertScreenAdStatusListener(InsertScreenAdStatusListener insertScreenAdStatusListener) {
this.insertScreenAdStatusListener = insertScreenAdStatusListener;
public void setWifiAdStatusListener(WifiAdStatusListener wifiAdStatusListener) {
this.wifiAdStatusListener = wifiAdStatusListener;
}
}
......@@ -2,13 +2,9 @@ package com.mints.flowbox.ad.inscreen;
import android.app.Activity;
import com.mints.flowbox.BuildConfig;
import com.mints.flowbox.ad.wifi.WifiAdStatusListener;
import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.common.Constant;
import com.mints.flowbox.manager.TrackManager;
import com.mints.flowbox.manager.TtCsjAdManager;
import com.mints.flowbox.manager.ad.YlhAdManager;
import com.mints.flowbox.mvp.model.WeightBean;
import com.mints.flowbox.utils.LogUtil;
import com.qq.e.ads.interstitial3.ExpressInterstitialAD;
import com.qq.e.ads.interstitial3.ExpressInterstitialAdListener;
......@@ -23,7 +19,7 @@ public class InterstitialYlhManager {
private static final String TAG = InterstitialYlhManager.class.getSimpleName();
private InsertScreenAdStatusListener insertScreenAdStatusListener;
private WifiAdStatusListener wifiAdStatusListener;
private Activity activity;
private ExpressInterstitialAD mExpressInterstitialAD;
......@@ -79,8 +75,8 @@ public class InterstitialYlhManager {
@Override
public void onClose() {
if (insertScreenAdStatusListener != null) {
insertScreenAdStatusListener.adSuccess();
if (wifiAdStatusListener != null) {
wifiAdStatusListener.adSuccess();
}
AppConfig.isShowInsertScreen = false;
}
......@@ -134,7 +130,7 @@ public class InterstitialYlhManager {
}
}
public void setInsertScreenAdStatusListener(InsertScreenAdStatusListener insertScreenAdStatusListener) {
this.insertScreenAdStatusListener = insertScreenAdStatusListener;
public void setWifiAdStatusListener(WifiAdStatusListener wifiAdStatusListener) {
this.wifiAdStatusListener = wifiAdStatusListener;
}
}
......@@ -14,6 +14,8 @@ import java.util.*
*/
class WifiAdManager {
private var wifiAdStatusListener: WifiAdStatusListener? = null
// groMore插屏
private var interstitialGroManager: InterstitialGroManager? = null
......@@ -83,6 +85,19 @@ class WifiAdManager {
fun showInterstitial() {
when (currentAdType) {
Constant.GROMORE_INSERTSCREEN_AD -> {
interstitialGroManager?.setWifiAdStatusListener(object :WifiAdStatusListener{
override fun adSuccess() {
}
override fun adFail() {
}
override fun adClose() {
wifiAdStatusListener?.adClose()
}
})
interstitialGroManager?.showInteractionAd()
}
Constant.GROMORE_FULL_AD -> {
......@@ -93,10 +108,14 @@ class WifiAdManager {
fun onDestroy() {
interstitialGroManager?.onDestroy()
interstitialGroManager?.setWifiAdStatusListener(null)
interstitialGroManager = null
fullGroManager?.onDestroy()
fullGroManager = null
}
fun setWifiAdStatusListener(listener: WifiAdStatusListener?) {
this.wifiAdStatusListener = listener
}
}
\ No newline at end of file
package com.mints.flowbox.ad.inscreen
package com.mints.flowbox.ad.wifi
/**
* 广告状态触发事件
*/
interface InsertScreenAdStatusListener {
interface WifiAdStatusListener {
/**
* 广告加载成功
......@@ -11,4 +11,6 @@ interface InsertScreenAdStatusListener {
fun adSuccess()
fun adFail()
fun adClose()
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ import com.daimajia.androidanimations.library.YoYo
import com.github.iielse.switchbutton.SwitchView
import com.mints.flowbox.R
import com.mints.flowbox.ad.inscreen.InsertScreenAdManager
import com.mints.flowbox.ad.inscreen.InsertScreenAdStatusListener
import com.mints.flowbox.ad.wifi.WifiAdStatusListener
import com.mints.flowbox.ad.video.VideoAdingManager
import com.mints.flowbox.common.AppConfig
import com.mints.flowbox.common.Constant
......@@ -49,7 +49,6 @@ import com.mints.library.utils.nodoubleclick.AntiShake
import com.umeng.analytics.MobclickAgent
import kotlinx.android.synthetic.main.fragment_main_turntable.*
import kotlinx.android.synthetic.main.layout_turn_btn.*
import java.util.*
import kotlin.collections.ArrayList
/**
......@@ -120,7 +119,7 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
insertScreenAdManager = InsertScreenAdManager()
insertScreenAdManager?.setInsertScreenAdStatusListener(object :
InsertScreenAdStatusListener {
WifiAdStatusListener {
override fun adSuccess() {
try {
if (turnTableData?.surplus!! <= 0) {
......
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