Commit c00e92b1 authored by jyx's avatar jyx

代码优化

parent dbf7ee9e
...@@ -17,18 +17,18 @@ import com.tz.sdk.core.ad.ADSource ...@@ -17,18 +17,18 @@ import com.tz.sdk.core.ad.ADSource
import com.tz.sdk.core.ad.ADType import com.tz.sdk.core.ad.ADType
import com.tz.sdk.core.loader.ADLoader import com.tz.sdk.core.loader.ADLoader
private val TAG = TzVideoAdManager::class.java.simpleName private val TAG = ShVideoAdManager::class.java.simpleName
/** /**
* 天卓珊瑚广告视频 * 天卓珊瑚广告视频
*/ */
class TzVideoAdManager private constructor(activity: Activity) : class ShVideoAdManager private constructor(activity: Activity) :
BaseVideoAd(activity), VideoAdManagerView { BaseVideoAd(activity), VideoAdManagerView {
private var isClickScreen: Boolean = true private var isClickScreen: Boolean = true
private var tzVideoAdPresenter: TzVideoAdPresenter? = null private var tzVideoAdPresenter: TzVideoAdPresenter? = null
private var tzVideoAdListener: TzVideoAdListener? = null private var shVideoAdListener: ShVideoAdListener? = null
companion object { companion object {
...@@ -40,12 +40,12 @@ class TzVideoAdManager private constructor(activity: Activity) : ...@@ -40,12 +40,12 @@ class TzVideoAdManager private constructor(activity: Activity) :
const val TZ_REWRAD_TYPE_DEBUG = 131 const val TZ_REWRAD_TYPE_DEBUG = 131
const val TZ_REWRAD_TYPE_RELEASE = 104 const val TZ_REWRAD_TYPE_RELEASE = 104
private var _inst: TzVideoAdManager? = null private var _inst: ShVideoAdManager? = null
fun getInstance(activity: Activity): TzVideoAdManager? { fun getInstance(activity: Activity): ShVideoAdManager? {
return if (_inst != null) { return if (_inst != null) {
_inst _inst
} else { } else {
_inst = TzVideoAdManager(activity) _inst = ShVideoAdManager(activity)
_inst _inst
} }
} }
...@@ -87,7 +87,6 @@ class TzVideoAdManager private constructor(activity: Activity) : ...@@ -87,7 +87,6 @@ class TzVideoAdManager private constructor(activity: Activity) :
.load(object : CoralVideoListener() { .load(object : CoralVideoListener() {
override fun onAdLoaded(adList: List<CoralAD>?) { override fun onAdLoaded(adList: List<CoralAD>?) {
LogUtil.d(TAG, "onAdLoaded") LogUtil.d(TAG, "onAdLoaded")
// if (adList != null && adList.isNotEmpty()) { // if (adList != null && adList.isNotEmpty()) {
// val ad = adList[0] // val ad = adList[0]
// ad.playVideo(activity) // ad.playVideo(activity)
...@@ -101,8 +100,8 @@ class TzVideoAdManager private constructor(activity: Activity) : ...@@ -101,8 +100,8 @@ class TzVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_ONE, (adError.code).toString(), "") TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_ONE, (adError.code).toString(), "")
if (tzVideoAdListener != null) { if (shVideoAdListener != null) {
tzVideoAdListener?.tzVideoAdFail() shVideoAdListener?.shVideoAdFail()
} }
} }
...@@ -125,8 +124,8 @@ class TzVideoAdManager private constructor(activity: Activity) : ...@@ -125,8 +124,8 @@ class TzVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_FOUR, "", "") TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_FOUR, "", "")
isClickScreen = false isClickScreen = false
} }
if (tzVideoAdListener != null) { if (shVideoAdListener != null) {
tzVideoAdListener?.tzVideoAdDownload() shVideoAdListener?.shVideoAdDownload()
} }
return super.onAdClicked(ad) return super.onAdClicked(ad)
...@@ -169,8 +168,8 @@ class TzVideoAdManager private constructor(activity: Activity) : ...@@ -169,8 +168,8 @@ class TzVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_THREE, "", "") TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_THREE, "", "")
if (tzVideoAdListener != null) { if (shVideoAdListener != null) {
tzVideoAdListener?.tzVideoAdSuccess() shVideoAdListener?.shVideoAdSuccess()
} }
return super.onVideoClosed(coralAD, s) return super.onVideoClosed(coralAD, s)
...@@ -179,14 +178,14 @@ class TzVideoAdManager private constructor(activity: Activity) : ...@@ -179,14 +178,14 @@ class TzVideoAdManager private constructor(activity: Activity) :
} }
fun setTzVideoAdListener(tzVideoAdListener: TzVideoAdListener?) { fun setShVideoAdListener(shVideoAdListener: ShVideoAdListener?) {
this.tzVideoAdListener = tzVideoAdListener this.shVideoAdListener = shVideoAdListener
} }
interface TzVideoAdListener { interface ShVideoAdListener {
fun tzVideoAdSuccess() fun shVideoAdSuccess()
fun tzVideoAdFail() fun shVideoAdFail()
fun tzVideoAdDownload() fun shVideoAdDownload()
} }
override fun onDestroy() { override fun onDestroy() {
......
...@@ -28,8 +28,8 @@ public class VideoAdingManager { ...@@ -28,8 +28,8 @@ public class VideoAdingManager {
private CsjVideoAdManager csjVideoAdManager; private CsjVideoAdManager csjVideoAdManager;
private YlhVideoAdManager ylhVideoAdManager; private YlhVideoAdManager ylhVideoAdManager;
private MhVideoAdManager mhVideoAdManager; private MhVideoAdManager mhVideoAdManager;
private TzVideoAdManager tzVideoAdManager; private ShVideoAdManager shVideoAdManager;
private CsjFullVideoAdManager csjFullVedioAdManager; private CsjFullVideoAdManager csjFullVideoAdManager;
private int wnWeight; private int wnWeight;
private int ylhWeight; private int ylhWeight;
...@@ -70,8 +70,8 @@ public class VideoAdingManager { ...@@ -70,8 +70,8 @@ public class VideoAdingManager {
ylhVideoAdManager = YlhVideoAdManager.getInstance(activity); ylhVideoAdManager = YlhVideoAdManager.getInstance(activity);
wnVideoAdManager = WnVideoAdManager.Companion.getInstance(activity); wnVideoAdManager = WnVideoAdManager.Companion.getInstance(activity);
mhVideoAdManager = MhVideoAdManager.Companion.getInstance(activity); mhVideoAdManager = MhVideoAdManager.Companion.getInstance(activity);
tzVideoAdManager = TzVideoAdManager.Companion.getInstance(activity); shVideoAdManager = ShVideoAdManager.Companion.getInstance(activity);
csjFullVedioAdManager = CsjFullVideoAdManager.getInstance(activity); csjFullVideoAdManager = CsjFullVideoAdManager.getInstance(activity);
weightList = new ArrayList<>(); weightList = new ArrayList<>();
} }
...@@ -237,7 +237,7 @@ public class VideoAdingManager { ...@@ -237,7 +237,7 @@ public class VideoAdingManager {
if (AppConfig.shVideoAdCount > 0) { if (AppConfig.shVideoAdCount > 0) {
weightList.add(new WeightBean(wnWeight, Constant.SH_VEDIO_AD)); weightList.add(new WeightBean(wnWeight, Constant.SH_VEDIO_AD));
weight = weight + shVideoWeight; weight = weight + shVideoWeight;
LogUtil.d(TAG, "权重值:sdhzWeight:" + shVideoWeight); LogUtil.d(TAG, "权重值:shWeight:" + shVideoWeight);
} }
// 权重随机 // 权重随机
...@@ -310,15 +310,15 @@ public class VideoAdingManager { ...@@ -310,15 +310,15 @@ public class VideoAdingManager {
mhVideoAdManager.onDestroy(); mhVideoAdManager.onDestroy();
mhVideoAdManager = null; mhVideoAdManager = null;
} }
if (csjFullVedioAdManager != null) { if (csjFullVideoAdManager != null) {
csjFullVedioAdManager.setCsjFullVedioAdListener(null); csjFullVideoAdManager.setCsjFullVedioAdListener(null);
csjFullVedioAdManager.onDestroy(); csjFullVideoAdManager.onDestroy();
csjFullVedioAdManager = null; csjFullVideoAdManager = null;
} }
if (tzVideoAdManager != null) { if (shVideoAdManager != null) {
tzVideoAdManager.setTzVideoAdListener(null); shVideoAdManager.setShVideoAdListener(null);
tzVideoAdManager.onDestroy(); shVideoAdManager.onDestroy();
tzVideoAdManager = null; shVideoAdManager = null;
} }
activity = null; activity = null;
...@@ -485,28 +485,28 @@ public class VideoAdingManager { ...@@ -485,28 +485,28 @@ public class VideoAdingManager {
mhVideoAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId()); mhVideoAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
} else if (TextUtils.equals(videoAdType, Constant.CSJ_FULL_AD)) { } else if (TextUtils.equals(videoAdType, Constant.CSJ_FULL_AD)) {
// 穿山甲全屏广告激励视频 // 穿山甲全屏广告激励视频
if (csjFullVedioAdManager == null) { if (csjFullVideoAdManager == null) {
if (activity == null) { if (activity == null) {
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerError(Constant.SH_VEDIO_AD); videoAdingListener.videoAdingListenerError(Constant.CSJ_FULL_AD);
} }
return; return;
} }
csjFullVedioAdManager = CsjFullVideoAdManager.getInstance(activity); csjFullVideoAdManager = CsjFullVideoAdManager.getInstance(activity);
} }
csjFullVedioAdManager.setCsjFullVedioAdListener(new CsjFullVideoAdManager.CsjFullVedioAdListener() { csjFullVideoAdManager.setCsjFullVedioAdListener(new CsjFullVideoAdManager.CsjFullVedioAdListener() {
@Override @Override
public void csjFullVedioAdSuccess() { public void csjFullVedioAdSuccess() {
AppConfig.shVideoAdCount--; AppConfig.shVideoAdCount--;
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.SH_VEDIO_AD); videoAdingListener.videoAdingListenerSuccess(Constant.CSJ_FULL_AD);
} }
} }
@Override @Override
public void csjFullVedioAdFail() { public void csjFullVedioAdFail() {
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.SH_VEDIO_AD); videoAdingListener.videoAdingListenerFail(Constant.CSJ_FULL_AD);
} }
} }
...@@ -516,21 +516,21 @@ public class VideoAdingManager { ...@@ -516,21 +516,21 @@ public class VideoAdingManager {
} }
}); });
csjFullVedioAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId()); csjFullVideoAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
} else if (TextUtils.equals(videoAdType, Constant.SH_VEDIO_AD)) { } else if (TextUtils.equals(videoAdType, Constant.SH_VEDIO_AD)) {
// 珊瑚广告激励视频 // 珊瑚广告激励视频
if (tzVideoAdManager == null) { if (shVideoAdManager == null) {
if (activity == null) { if (activity == null) {
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerError(Constant.SH_VEDIO_AD); videoAdingListener.videoAdingListenerError(Constant.SH_VEDIO_AD);
} }
return; return;
} }
tzVideoAdManager = TzVideoAdManager.Companion.getInstance(activity); shVideoAdManager = ShVideoAdManager.Companion.getInstance(activity);
} }
tzVideoAdManager.setTzVideoAdListener(new TzVideoAdManager.TzVideoAdListener() { shVideoAdManager.setShVideoAdListener(new ShVideoAdManager.ShVideoAdListener() {
@Override @Override
public void tzVideoAdSuccess() { public void shVideoAdSuccess() {
AppConfig.shVideoAdCount--; AppConfig.shVideoAdCount--;
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.SH_VEDIO_AD); videoAdingListener.videoAdingListenerSuccess(Constant.SH_VEDIO_AD);
...@@ -538,19 +538,19 @@ public class VideoAdingManager { ...@@ -538,19 +538,19 @@ public class VideoAdingManager {
} }
@Override @Override
public void tzVideoAdFail() { public void shVideoAdFail() {
if (videoAdingListener != null) { if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.SH_VEDIO_AD); videoAdingListener.videoAdingListenerFail(Constant.SH_VEDIO_AD);
} }
} }
@Override @Override
public void tzVideoAdDownload() { public void shVideoAdDownload() {
isVideoAdDownload = true; isVideoAdDownload = true;
} }
}); });
tzVideoAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId()); shVideoAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
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