Commit c00e92b1 authored by jyx's avatar jyx

代码优化

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