Commit 1c2147fd authored by mengcuiguang's avatar mengcuiguang

代码优化

parent f6e61c37
......@@ -252,7 +252,7 @@ dependencies {
// implementation(name: 'ks_3.3.5.3', ext: 'aar')
// 聚乐云
implementation(name: 'okgo-4.0', ext: 'aar')
implementation(name: 'scenemodule-4.0-hzq', ext: 'aar')
implementation(name: 'scenemodule-4.1-hzq', ext: 'aar')
implementation(name: 'scenead-4.0', ext: 'aar')
implementation 'com.just.agentweb:agentweb:4.1.2'
// 喜马拉雅 已集成
......
package com.mints.goodmoney.ad.video
import android.app.Activity
import android.content.DialogInterface
import android.text.TextUtils
import android.view.KeyEvent
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.views.BaseView
import com.mints.goodmoney.ui.widgets.dialog.LoadingDialog
import com.mints.goodmoney.utils.ToastUtil
import java.util.HashMap
open class BaseVideoAd(activity: Activity) : BaseView {
open var activity: Activity? = null
var progressDialog: LoadingDialog? = null
init {
this.activity = activity
}
override fun getBaseApplication(): MintsApplication {
return activity?.getApplication() as MintsApplication
}
/**
* 显示加载进度条(自定义message)
*
* @param message
*/
override fun showLoading(message: String?) {
if (activity != null) {
if (activity!!.getWindow() != null && !activity!!.isFinishing()) {
if (progressDialog == null) {
progressDialog = LoadingDialog(activity)
progressDialog!!.setLoadText(message)
}
progressDialog?.show()
setProgressOnTouchOutside(false)
setProgressNoDismiss()
}
}
}
/**
* 设置Progress是否手触消失
*
* @param onTouchOutside
*/
open fun setProgressOnTouchOutside(onTouchOutside: Boolean) {
if (progressDialog != null) progressDialog!!.setCanceledOnTouchOutside(onTouchOutside)
}
/**
* 设置点击返回是否消失加载进度条
*/
fun setProgressNoDismiss() {
if (progressDialog != null && progressDialog!!.isShowing()) {
progressDialog!!.setOnKeyListener(DialogInterface.OnKeyListener { dialog, keyCode, event ->
keyCode == KeyEvent.KEYCODE_BACK
})
}
}
/**
* 消失加载进度条
*/
override fun hideLoading() {
try {
if (activity != null) {
if (activity!!.getWindow() != null && !activity!!.isFinishing()) {
if (progressDialog != null && progressDialog!!.isShowing()) {
progressDialog!!.dismiss()
progressDialog = null
}
}
}
} catch (e: Exception) {
e.printStackTrace()
} finally {
progressDialog = null
}
}
override fun showToast(msg: String?) {
if (!TextUtils.isEmpty(msg)) ToastUtil.show(MintsApplication.getContext(), msg)
}
/**
* 激励视频请求接口封装
*/
fun getAdMapVO(carrierType: String, adsource: String, extraId: String?, curCoin: Int): HashMap<String, Any> {
val vo = HashMap<String, Any>()
vo["carrierType"] = carrierType
vo["adtype"] = Constant.ADTYPE_VEDIO
vo["adsource"] = adsource
var tempExtraId = ""
if (extraId != null) {
tempExtraId = extraId
}
when (carrierType) {
Constant.CARRIER_VERSUS_VIDEO -> vo["coin"] = curCoin
Constant.CARRIER_HOMEWATER -> vo["waterCoin"] = curCoin
Constant.CARRIER_OFFLINE_DOUBLE -> vo["offline_income"] = curCoin
Constant.CARRIER_CHALLENGE_TURN, Constant.CARRIER_CHALLENGE_CARD -> vo["turntableKey"] = tempExtraId
}
return vo
}
open fun loadAd(activity: Activity, curCoin: Int, carrierType: String, extraId: String?) {}
open fun onDestroy() {}
}
\ No newline at end of file
......@@ -7,19 +7,20 @@ import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.mints.goodmoney.ad.video.base.BaseVideoAd;
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.TrackManager;
import com.mints.goodmoney.manager.TtCsjAdManager;
import com.mints.goodmoney.mvp.views.VideoAdManagerView;
/**
* 穿山甲全屏广告
*/
public class CsjFullVideoAdManager extends BaseVideoAd implements VideoAdManagerView {
public class CsjFullVideoAdManager extends BaseVideoAd {
private static CsjFullVideoAdManager _inst;
private CsjFullVedioAdListener csjFullVedioAdListener;
private VedioAdStatusListener vedioAdStatusListener;
Activity activity;
private TTAdNative ttAdNative;
......@@ -37,7 +38,6 @@ public class CsjFullVideoAdManager extends BaseVideoAd implements VideoAdManager
}
private CsjFullVideoAdManager(Activity activity) {
super(activity);
init(activity);
}
......@@ -68,8 +68,8 @@ public class CsjFullVideoAdManager extends BaseVideoAd implements VideoAdManager
public void onError(int code, String message) {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_ONE, String.valueOf(code), message);
if (csjFullVedioAdListener != null) {
csjFullVedioAdListener.csjFullVedioAdFail();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
......@@ -92,16 +92,16 @@ public class CsjFullVideoAdManager extends BaseVideoAd implements VideoAdManager
}
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_TWO, "", "");
if (csjFullVedioAdListener != null) {
csjFullVedioAdListener.csjFullVedioDownload();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adDownload();
}
}
@Override
public void onAdClose() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_THREE, "", "");
if (csjFullVedioAdListener != null) {
csjFullVedioAdListener.csjFullVedioAdSuccess();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adSuccess();
}
if (activity != null) {
TrackManager.getInstance().reportAddCoinMsg(activity, getAdMapVO(carrierType, Constant.AD_SOURCE_CSJFULL, extraId, curCoin));
......@@ -129,8 +129,8 @@ public class CsjFullVideoAdManager extends BaseVideoAd implements VideoAdManager
} else {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_ONE, "999999", "Cached Fail");
if (csjFullVedioAdListener != null) {
csjFullVedioAdListener.csjFullVedioAdFail();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
}
......@@ -146,15 +146,8 @@ public class CsjFullVideoAdManager extends BaseVideoAd implements VideoAdManager
activity = null;
}
public void setCsjFullVedioAdListener(CsjFullVedioAdListener csjFullVedioAdListener) {
this.csjFullVedioAdListener = csjFullVedioAdListener;
public void setVedioAdStatusListener(VedioAdStatusListener vedioAdStatusListener) {
this.vedioAdStatusListener = vedioAdStatusListener;
}
public interface CsjFullVedioAdListener {
void csjFullVedioAdFail();
void csjFullVedioAdSuccess();
void csjFullVedioDownload();
}
}
......@@ -8,6 +8,8 @@ import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTAppDownloadListener;
import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.mints.goodmoney.BuildConfig;
import com.mints.goodmoney.ad.video.base.BaseVideoAd;
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.TTNativeExpressManager;
......@@ -31,7 +33,7 @@ public class CsjVideoAdManager extends BaseVideoAd {
private AppPreferences ps;
private int curCoin;
private String extraId;
private CsjVideoAdListener csjVideoAdListener;
private VedioAdStatusListener vedioAdStatusListener;
Activity activity;
private TTAdNative ttAdNative;
......@@ -48,7 +50,6 @@ public class CsjVideoAdManager extends BaseVideoAd {
}
private CsjVideoAdManager(Activity activity) {
super(activity);
init(activity);
}
......@@ -66,7 +67,7 @@ public class CsjVideoAdManager extends BaseVideoAd {
if (mttRewardVideoAd != null) {
mttRewardVideoAd.setRewardAdInteractionListener(null);
}
ps=null;
activity = null;
}
......@@ -81,7 +82,6 @@ public class CsjVideoAdManager extends BaseVideoAd {
isClickScreen = true;
this.curCoin = curCoin;
this.extraId = extraId;
String codeId = TtCsjAdManager.TT_AD_VEDIO_MAIN_DEV;
if (!BuildConfig.DEBUG) {
switch (carrierType) {
......@@ -150,9 +150,9 @@ public class CsjVideoAdManager extends BaseVideoAd {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, String.valueOf(code), message);
LogUtil.d("csjVideoAdListener", "onError " + code + message);
if (csjVideoAdListener != null) {
csjVideoAdListener.csjVideoAdFail();
LogUtil.d("vedioAdStatusListener", "onError " + code + message);
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
......@@ -165,8 +165,8 @@ public class CsjVideoAdManager extends BaseVideoAd {
} else {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "Cached Fail");
if (csjVideoAdListener != null) {
csjVideoAdListener.csjVideoAdFail();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
}
......@@ -197,8 +197,8 @@ public class CsjVideoAdManager extends BaseVideoAd {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
if (csjVideoAdListener != null) {
csjVideoAdListener.csjVideoDownload();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adDownload();
}
}
......@@ -206,8 +206,8 @@ public class CsjVideoAdManager extends BaseVideoAd {
public void onAdClose() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_THREE, "", "");
if (csjVideoAdListener != null) {
csjVideoAdListener.csjVideoAdSuccess();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adSuccess();
}
}
......@@ -219,8 +219,8 @@ public class CsjVideoAdManager extends BaseVideoAd {
public void onVideoError() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "VideoError");
if (csjVideoAdListener != null) {
csjVideoAdListener.csjVideoAdFail();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
......@@ -299,15 +299,8 @@ public class CsjVideoAdManager extends BaseVideoAd {
return vo;
}
public void setCsjVideoAdListener(CsjVideoAdListener csjVideoAdListener) {
this.csjVideoAdListener = csjVideoAdListener;
public void setVedioAdStatusListener(VedioAdStatusListener vedioAdStatusListener) {
this.vedioAdStatusListener = vedioAdStatusListener;
}
public interface CsjVideoAdListener {
void csjVideoAdFail();
void csjVideoAdSuccess();
void csjVideoDownload();
}
}
......@@ -5,13 +5,13 @@ import com.kwad.sdk.api.KsAdSDK
import com.kwad.sdk.api.KsLoadManager
import com.kwad.sdk.api.KsRewardVideoAd
import com.kwad.sdk.api.KsScene
import com.mints.goodmoney.ad.video.base.BaseVideoAd
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.KsManager
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.mvp.views.VideoAdManagerView
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.ToastUtil
private val TAG = KsVideoAdManager::class.java.simpleName
......@@ -20,13 +20,13 @@ private val TAG = KsVideoAdManager::class.java.simpleName
* 快手广告视频
*/
class KsVideoAdManager private constructor(activity: Activity) :
BaseVideoAd(activity), VideoAdManagerView {
BaseVideoAd() {
private var ksVideoAdListener: KsVideoAdListener? = null
private var vedioAdStatusListener: VedioAdStatusListener? = null
private var mRewardVideoAd: KsRewardVideoAd? = null
private var isClickScreen: Boolean = true
override var activity: Activity? = null
var activity: Activity? = null
companion object {
private var _inst: KsVideoAdManager? = null
......@@ -55,8 +55,8 @@ class KsVideoAdManager private constructor(activity: Activity) :
val scene = KsScene.Builder(KsManager.KS_AD_VEDIO_POSTID).build()
KsAdSDK.getLoadManager().loadRewardVideoAd(scene, object : KsLoadManager.RewardVideoAdListener {
override fun onError(p0: Int, p1: String?) {
if (ksVideoAdListener != null) {
ksVideoAdListener?.ksVideoAdFail()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adFail()
}
}
......@@ -79,8 +79,8 @@ class KsVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_KS, Constant.EVENT_TYPE_FOUR, "", "")
isClickScreen = false
}
if (ksVideoAdListener != null) {
ksVideoAdListener?.ksVideoAdDownload()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adDownload()
}
}
......@@ -91,8 +91,8 @@ class KsVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_KS, Constant.EVENT_TYPE_THREE, "", "")
if (ksVideoAdListener != null) {
ksVideoAdListener?.ksVideoAdSuccess()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adSuccess()
}
}
......@@ -101,8 +101,8 @@ class KsVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_KS, Constant.EVENT_TYPE_ONE, (p0).toString(), "")
if (ksVideoAdListener != null) {
ksVideoAdListener?.ksVideoAdFail()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adFail()
}
}
......@@ -131,15 +131,10 @@ class KsVideoAdManager private constructor(activity: Activity) :
}
fun setKsVideoAdListener(ksVideoAdListener: KsVideoAdListener?) {
this.ksVideoAdListener = ksVideoAdListener
fun setVedioAdStatusListener(vedioAdStatusListener: VedioAdStatusListener?) {
this.vedioAdStatusListener = vedioAdStatusListener
}
interface KsVideoAdListener {
fun ksVideoAdSuccess()
fun ksVideoAdFail()
fun ksVideoAdDownload()
}
override fun onDestroy() {
mRewardVideoAd = null
......
......@@ -2,11 +2,12 @@ package com.mints.goodmoney.ad.video
import android.app.Activity
import com.maplehaze.adsdk.video.RewardVideoAd
import com.mints.goodmoney.ad.video.base.BaseVideoAd
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.MhManager
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.mvp.views.VideoAdManagerView
import com.mints.goodmoney.utils.LogUtil
private val TAG = MhVideoAdManager::class.java.simpleName
......@@ -15,13 +16,13 @@ private val TAG = MhVideoAdManager::class.java.simpleName
* 枫岚广告视频
*/
class MhVideoAdManager private constructor(activity: Activity) :
BaseVideoAd(activity), VideoAdManagerView {
BaseVideoAd() {
private var mhVideoAdListener: MhVideoAdListener? = null
private var vedioAdStatusListener: VedioAdStatusListener? = null
private var mRewardVideoAd: RewardVideoAd? = null
private var isClickScreen: Boolean = true
override var activity: Activity? = null
private var activity: Activity? = null
companion object {
private var _inst: MhVideoAdManager? = null
......@@ -84,8 +85,8 @@ class MhVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_FL, Constant.EVENT_TYPE_FOUR, "", "")
isClickScreen = false
}
if (mhVideoAdListener != null) {
mhVideoAdListener?.mhVideoAdDownload()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adDownload()
}
}
......@@ -100,8 +101,8 @@ class MhVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_FL, Constant.EVENT_TYPE_THREE, "", "")
if (mhVideoAdListener != null) {
mhVideoAdListener?.mhVideoAdSuccess()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adSuccess()
}
}
......@@ -110,8 +111,8 @@ class MhVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_FL, Constant.EVENT_TYPE_ONE, (p0).toString(), "")
if (mhVideoAdListener != null) {
mhVideoAdListener?.mhVideoAdFail()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adFail()
}
}
......@@ -120,15 +121,10 @@ class MhVideoAdManager private constructor(activity: Activity) :
mRewardVideoAd?.loadAd()
}
fun setMhVideoAdListener(mhVideoAdListener: MhVideoAdListener?) {
this.mhVideoAdListener = mhVideoAdListener
fun setVedioAdStatusListener(vedioAdStatusListener: VedioAdStatusListener?) {
this.vedioAdStatusListener = vedioAdStatusListener
}
interface MhVideoAdListener {
fun mhVideoAdSuccess()
fun mhVideoAdFail()
fun mhVideoAdDownload()
}
override fun onDestroy() {
mRewardVideoAd = null
......
......@@ -4,6 +4,8 @@ import android.app.Activity
import android.text.TextUtils
import androidx.annotation.Nullable
import com.mints.goodmoney.BuildConfig
import com.mints.goodmoney.ad.video.base.BaseVideoAd
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.TrackManager
......@@ -25,11 +27,12 @@ private val TAG = ShVideoAdManager::class.java.simpleName
* 天卓珊瑚广告视频
*/
class ShVideoAdManager private constructor(activity: Activity) :
BaseVideoAd(activity) {
BaseVideoAd() {
private var isClickScreen: Boolean = true
private var activity: Activity? = null
private var shVideoAdListener: ShVideoAdListener? = null
private var vedioAdStatusListener: VedioAdStatusListener? = null
private lateinit var ps: AppPreferences
companion object {
......@@ -103,8 +106,8 @@ class ShVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_ONE, (adError.code).toString(), "")
if (shVideoAdListener != null) {
shVideoAdListener?.shVideoAdFail()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adFail()
}
}
......@@ -127,8 +130,8 @@ class ShVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_FOUR, "", "")
isClickScreen = false
}
if (shVideoAdListener != null) {
shVideoAdListener?.shVideoAdDownload()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adDownload()
}
return super.onAdClicked(ad)
......@@ -168,8 +171,8 @@ class ShVideoAdManager private constructor(activity: Activity) :
LogUtil.d(TAG, "onVideoClosed")
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SH, Constant.EVENT_TYPE_THREE, "", "")
if (shVideoAdListener != null) {
shVideoAdListener?.shVideoAdSuccess()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adSuccess()
}
return super.onVideoClosed(coralAD, s)
......@@ -178,14 +181,8 @@ class ShVideoAdManager private constructor(activity: Activity) :
}
fun setShVideoAdListener(shVideoAdListener: ShVideoAdListener?) {
this.shVideoAdListener = shVideoAdListener
}
interface ShVideoAdListener {
fun shVideoAdSuccess()
fun shVideoAdFail()
fun shVideoAdDownload()
fun setVedioAdStatusListener(vedioAdStatusListener: VedioAdStatusListener?) {
this.vedioAdStatusListener = vedioAdStatusListener
}
override fun onDestroy() {
......
......@@ -7,7 +7,9 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.text.TextUtils;
import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.ad.video.base.BaseVideoAd;
import com.mints.goodmoney.ad.video.base.ChannelRuleEnum;
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.TrackManager;
......@@ -16,7 +18,6 @@ import com.mints.goodmoney.mvp.model.WeightBean;
import com.mints.goodmoney.service.AppInstallService;
import com.mints.goodmoney.utils.AppUtil;
import com.mints.goodmoney.utils.LogUtil;
import com.mints.goodmoney.utils.ToastUtil;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
......@@ -362,37 +363,37 @@ public class VideoAdingManager {
*/
public void onDestory() {
if (csjVideoAdManager != null) {
csjVideoAdManager.setCsjVideoAdListener(null);
csjVideoAdManager.setVedioAdStatusListener(null);
csjVideoAdManager.onDestroy();
csjVideoAdManager = null;
}
if (ylhVideoAdManager != null) {
ylhVideoAdManager.setYlhVideoAdListener(null);
ylhVideoAdManager.setVedioAdStatusListener(null);
ylhVideoAdManager.onDestroy();
ylhVideoAdManager = null;
}
if (wnVideoAdManager != null) {
wnVideoAdManager.setWnVideoAdListener(null);
wnVideoAdManager.setVedioAdStatusListener(null);
wnVideoAdManager.onDestroy();
wnVideoAdManager = null;
}
if (mhVideoAdManager != null) {
mhVideoAdManager.setMhVideoAdListener(null);
mhVideoAdManager.setVedioAdStatusListener(null);
mhVideoAdManager.onDestroy();
mhVideoAdManager = null;
}
if (csjFullVideoAdManager != null) {
csjFullVideoAdManager.setCsjFullVedioAdListener(null);
csjFullVideoAdManager.setVedioAdStatusListener(null);
csjFullVideoAdManager.onDestroy();
csjFullVideoAdManager = null;
}
if (shVideoAdManager != null) {
shVideoAdManager.setShVideoAdListener(null);
shVideoAdManager.setVedioAdStatusListener(null);
shVideoAdManager.onDestroy();
shVideoAdManager = null;
}
if (ksVideoAdManager != null) {
ksVideoAdManager.setKsVideoAdListener(null);
ksVideoAdManager.setVedioAdStatusListener(null);
ksVideoAdManager.onDestroy();
ksVideoAdManager = null;
}
......@@ -441,16 +442,16 @@ public class VideoAdingManager {
ylhVideoAdManager = YlhVideoAdManager.getInstance(activity);
}
ylhVideoAdManager.setYlhVideoAdListener(new YlhVideoAdManager.YlhVideoAdListener() {
ylhVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener() {
@Override
public void ylhVideoAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.YLH_VEDIO_AD);
}
}
@Override
public void ylhVideoAdSuccess() {
public void adSuccess() {
AppConfig.ylhAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.YLH_VEDIO_AD);
......@@ -458,7 +459,7 @@ public class VideoAdingManager {
}
@Override
public void ylhVideoAdDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -476,19 +477,20 @@ public class VideoAdingManager {
return;
}
csjVideoAdManager = CsjVideoAdManager.getInstance(activity);
// csjVideoAdManager = CsjVideoAdManager.getInstance();
}
csjVideoAdManager.setCsjVideoAdListener(new CsjVideoAdManager.CsjVideoAdListener() {
csjVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener() {
@Override
public void csjVideoAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.CSJ_VEDIO_AD);
}
}
@Override
public void csjVideoAdSuccess() {
public void adSuccess() {
AppConfig.csjVideoAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.CSJ_VEDIO_AD);
......@@ -496,7 +498,7 @@ public class VideoAdingManager {
}
@Override
public void csjVideoDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -515,9 +517,9 @@ public class VideoAdingManager {
}
wnVideoAdManager = WnVideoAdManager.Companion.getInstance(activity);
}
wnVideoAdManager.setWnVideoAdListener(new WnVideoAdManager.WnVideoAdListener() {
wnVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener() {
@Override
public void wnVideoAdSuccess() {
public void adSuccess() {
AppConfig.wnVideoAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.SDHZ_VEDIO_AD);
......@@ -525,14 +527,14 @@ public class VideoAdingManager {
}
@Override
public void wnVideoAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.SDHZ_VEDIO_AD);
}
}
@Override
public void wnVideoAdDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -551,9 +553,9 @@ public class VideoAdingManager {
}
mhVideoAdManager = MhVideoAdManager.Companion.getInstance(activity);
}
mhVideoAdManager.setMhVideoAdListener(new MhVideoAdManager.MhVideoAdListener() {
mhVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener() {
@Override
public void mhVideoAdSuccess() {
public void adSuccess() {
AppConfig.flVideoAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.FL_VEDIO_AD);
......@@ -561,14 +563,14 @@ public class VideoAdingManager {
}
@Override
public void mhVideoAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.FL_VEDIO_AD);
}
}
@Override
public void mhVideoAdDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -588,9 +590,9 @@ public class VideoAdingManager {
}
csjFullVideoAdManager = CsjFullVideoAdManager.getInstance(activity);
}
csjFullVideoAdManager.setCsjFullVedioAdListener(new CsjFullVideoAdManager.CsjFullVedioAdListener() {
csjFullVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener(){
@Override
public void csjFullVedioAdSuccess() {
public void adSuccess() {
AppConfig.csjFullVideoAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.CSJ_FULL_AD);
......@@ -598,14 +600,14 @@ public class VideoAdingManager {
}
@Override
public void csjFullVedioAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.CSJ_FULL_AD);
}
}
@Override
public void csjFullVedioDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -625,9 +627,9 @@ public class VideoAdingManager {
}
shVideoAdManager = ShVideoAdManager.Companion.getInstance(activity);
}
shVideoAdManager.setShVideoAdListener(new ShVideoAdManager.ShVideoAdListener() {
shVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener() {
@Override
public void shVideoAdSuccess() {
public void adSuccess() {
AppConfig.shVideoAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.SH_VEDIO_AD);
......@@ -635,14 +637,14 @@ public class VideoAdingManager {
}
@Override
public void shVideoAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.SH_VEDIO_AD);
}
}
@Override
public void shVideoAdDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -662,9 +664,9 @@ public class VideoAdingManager {
}
ksVideoAdManager = KsVideoAdManager.Companion.getInstance(activity);
}
ksVideoAdManager.setKsVideoAdListener(new KsVideoAdManager.KsVideoAdListener() {
ksVideoAdManager.setVedioAdStatusListener(new VedioAdStatusListener() {
@Override
public void ksVideoAdSuccess() {
public void adSuccess() {
AppConfig.ksVideoAdCount--;
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerSuccess(Constant.KS_VEDIO_AD);
......@@ -672,14 +674,14 @@ public class VideoAdingManager {
}
@Override
public void ksVideoAdFail() {
public void adFail() {
if (videoAdingListener != null) {
videoAdingListener.videoAdingListenerFail(Constant.KS_VEDIO_AD);
}
}
@Override
public void ksVideoAdDownload() {
public void adDownload() {
isVideoAdDownload = true;
// 注册下载任务监听
......@@ -689,6 +691,12 @@ public class VideoAdingManager {
ksVideoAdManager.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
}
// ChannelRuleEnum channelRule = ChannelRuleEnum.match(videoAdType);
// BaseVideoAd rule = channelRule.channel;
// if (rule != null) {
// rule.loadAd(activity, bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
// }
} catch (Exception e) {
e.printStackTrace();
if (videoAdingListener != null) {
......
package com.mints.goodmoney.ad.video
import android.app.Activity
import com.mints.goodmoney.ad.video.base.BaseVideoAd
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.TrackManager
import com.mints.goodmoney.manager.WnManager
import com.mints.goodmoney.mvp.views.VideoAdManagerView
import com.mints.goodmoney.utils.LogUtil
import com.wannuosili.sdk.*
......@@ -15,13 +16,13 @@ private val TAG = WnVideoAdManager::class.java.simpleName
* 闪电盒子视频
*/
class WnVideoAdManager private constructor(activity: Activity) :
BaseVideoAd(activity), VideoAdManagerView {
BaseVideoAd() {
private var wnVideoAdListener: WnVideoAdListener? = null
private var vedioAdStatusListener: VedioAdStatusListener? = null
private var mRewardVideoAd: WNRewardVideoAd? = null
private var isClickScreen: Boolean = true
override var activity: Activity? = null
private var activity: Activity? = null
companion object {
private var _inst: WnVideoAdManager? = null
......@@ -65,8 +66,8 @@ class WnVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SDHZ, Constant.EVENT_TYPE_ONE, (code).toString(), message)
if (wnVideoAdListener != null) {
wnVideoAdListener?.wnVideoAdFail()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adFail()
}
}
......@@ -88,8 +89,8 @@ class WnVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SDHZ, Constant.EVENT_TYPE_FOUR, "", "")
isClickScreen = false
}
if (wnVideoAdListener != null) {
wnVideoAdListener?.wnVideoAdDownload()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adDownload()
}
}
......@@ -98,8 +99,8 @@ class WnVideoAdManager private constructor(activity: Activity) :
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_SDHZ, Constant.EVENT_TYPE_THREE, "", "")
if (wnVideoAdListener != null) {
wnVideoAdListener?.wnVideoAdSuccess()
if (vedioAdStatusListener != null) {
vedioAdStatusListener?.adSuccess()
}
}
......@@ -112,7 +113,6 @@ class WnVideoAdManager private constructor(activity: Activity) :
if (ad.type == WNAdConstant.AD_TYPE_DOWNLOAD) {
ad.downloadListener = object : WNAdDownloadListener {
override fun onDownloadStarted(totalBytes: Long, fileName: String, appName: String) {
showToast("开始下载")
}
override fun onDownloadFinished(totalBytes: Long, fileName: String, appName: String) {}
......@@ -126,14 +126,8 @@ class WnVideoAdManager private constructor(activity: Activity) :
})
}
fun setWnVideoAdListener(wnVideoAdListener: WnVideoAdListener?) {
this.wnVideoAdListener = wnVideoAdListener
}
interface WnVideoAdListener {
fun wnVideoAdSuccess()
fun wnVideoAdFail()
fun wnVideoAdDownload()
fun setVedioAdStatusListener(vedioAdStatusListener: VedioAdStatusListener?) {
this.vedioAdStatusListener = vedioAdStatusListener
}
override fun onDestroy() {
......
......@@ -3,14 +3,13 @@ package com.mints.goodmoney.ad.video;
import android.app.Activity;
import android.os.SystemClock;
import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.ad.video.base.BaseVideoAd;
import com.mints.goodmoney.ad.video.base.VedioAdStatusListener;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.TrackManager;
import com.mints.goodmoney.manager.YlhAdManager;
import com.mints.goodmoney.mvp.views.VideoAdManagerView;
import com.mints.goodmoney.utils.LogUtil;
import com.mints.goodmoney.utils.ToastUtil;
import com.qq.e.ads.rewardvideo.RewardVideoAD;
import com.qq.e.ads.rewardvideo.RewardVideoADListener;
import com.qq.e.comm.util.AdError;
......@@ -20,16 +19,16 @@ import java.lang.ref.WeakReference;
/**
* 优量汇视频
*/
public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView {
public class YlhVideoAdManager extends BaseVideoAd {
private static YlhVideoAdManager _inst;
// 优量汇激励视频
private RewardVideoAD rewardVideoAD;
private YlhVideoAdListener ylhVideoAdListener;
private VedioAdStatusListener vedioAdStatusListener;
Activity activity;
private Activity activity;
private boolean isClickScreen = true; // 是否点击屏幕跳转广告
......@@ -44,7 +43,6 @@ public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView
}
private YlhVideoAdManager(WeakReference<Activity> activity) {
super(activity.get());
init(activity.get());
}
......@@ -144,17 +142,17 @@ public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView
if (SystemClock.elapsedRealtime() < (rewardVideoAD.getExpireTimestamp() - delta)) {
rewardVideoAD.showAD();
} else {
showToast("广告已过期,请再次请求广告后进行广告展示!");
// showToast("广告已过期,请再次请求广告后进行广告展示!");
}
} else {
showToast("此条广告已经展示过,请再次请求广告后进行广告展示!");
// showToast("此条广告已经展示过,请再次请求广告后进行广告展示!");
}
} catch (Exception e) {
e.printStackTrace();
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ONE, "999999", "Load Fail");
if (ylhVideoAdListener != null) {
ylhVideoAdListener.ylhVideoAdFail();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
}
......@@ -195,8 +193,8 @@ public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
if (ylhVideoAdListener != null) {
ylhVideoAdListener.ylhVideoAdDownload();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adDownload();
}
}
......@@ -211,8 +209,8 @@ public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView
TrackManager.getInstance().reportAddCoinMsg(activity, getAdMapVO(carrierType, Constant.AD_SOURCE_YLH, extraId, curCoin));
if (ylhVideoAdListener != null) {
ylhVideoAdListener.ylhVideoAdSuccess();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adSuccess();
}
}
......@@ -225,8 +223,8 @@ public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView
// 0 成功 1失败 2点击 3-有效展示
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ONE, String.valueOf(adError.getErrorCode()), adError.getErrorMsg());
}
if (ylhVideoAdListener != null) {
ylhVideoAdListener.ylhVideoAdFail();
if (vedioAdStatusListener != null) {
vedioAdStatusListener.adFail();
}
}
});
......@@ -234,15 +232,7 @@ public class YlhVideoAdManager extends BaseVideoAd implements VideoAdManagerView
rewardVideoAD.loadAD();
}
public void setYlhVideoAdListener(YlhVideoAdListener ylhVideoAdListener) {
this.ylhVideoAdListener = ylhVideoAdListener;
}
public interface YlhVideoAdListener {
void ylhVideoAdFail();
void ylhVideoAdSuccess();
void ylhVideoAdDownload();
public void setVedioAdStatusListener(VedioAdStatusListener vedioAdStatusListener) {
this.vedioAdStatusListener = vedioAdStatusListener;
}
}
package com.mints.goodmoney.ad.video.base
import android.app.Activity
import com.mints.goodmoney.common.Constant
import java.util.*
open class BaseVideoAd {
/**
* 激励视频请求接口封装
*/
fun getAdMapVO(carrierType: String, adsource: String, extraId: String?, curCoin: Int): HashMap<String, Any> {
val vo = HashMap<String, Any>()
vo["carrierType"] = carrierType
vo["adtype"] = Constant.ADTYPE_VEDIO
vo["adsource"] = adsource
var tempExtraId = ""
if (extraId != null) {
tempExtraId = extraId
}
when (carrierType) {
Constant.CARRIER_VERSUS_VIDEO -> vo["coin"] = curCoin
Constant.CARRIER_HOMEWATER -> vo["waterCoin"] = curCoin
Constant.CARRIER_OFFLINE_DOUBLE -> vo["offline_income"] = curCoin
Constant.CARRIER_CHALLENGE_TURN, Constant.CARRIER_CHALLENGE_CARD -> vo["turntableKey"] = tempExtraId
}
return vo
}
open fun loadAd(activity: Activity, curCoin: Int, carrierType: String, extraId: String?) {}
open fun onDestroy() {}
}
\ No newline at end of file
package com.mints.goodmoney.ad.video.base;//package com.example.rule;
public enum ChannelRuleEnum {
/**
* 头条
*/
// CSJ_FULL_AD(Constant.CSJ_FULL_AD, CsjFullVideoAdManager.getInstance()),
// CSJ_VEDIO_AD(Constant.CSJ_VEDIO_AD, CsjVideoAdManager.getInstance()),
;
public String name;
public BaseVideoAd channel;
ChannelRuleEnum(String name, BaseVideoAd channel) {
this.name = name;
this.channel = channel;
}
//匹配
public static ChannelRuleEnum match(String name) {
ChannelRuleEnum[] values = ChannelRuleEnum.values();
for (ChannelRuleEnum value : values) {
if (value.name.equals(name)) {
return value;
}
}
return null;
}
public String getName() {
return name;
}
}
package com.mints.goodmoney.ad.video.base
/**
* 广告状态触发事件
*/
interface VedioAdStatusListener {
/**
* 广告加载失败
*/
fun adFail()
/**
* 广告加载成功
*/
fun adSuccess()
/**
* 点击广告
*/
fun adDownload()
}
\ No newline at end of file
......@@ -25,7 +25,9 @@ import com.mints.goodmoney.ui.widgets.dialog.DrawcashVideoDialog
import com.mints.goodmoney.utils.LogUtil
import com.mints.library.utils.CommonUtils
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_drawcash.*
import kotlinx.android.synthetic.main.fragment_main_my.*
import kotlinx.android.synthetic.main.header_layout.*
import kotlinx.android.synthetic.main.view_title.*
import java.math.BigDecimal
......@@ -381,6 +383,8 @@ class DrawcashActivity : BaseActivity(),
}
override fun userFrequently() {
if (AntiShake.check(tvDrawcashExplain?.id)) return
readyGoThenKill(DrawcashRecordActivity::class.java)
}
......
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