Commit 1e4c5250 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent fc91e796
......@@ -17,7 +17,6 @@ import com.mintegral.msdk.out.MIntegralSDKFactory;
import com.mints.highgold.common.AppConfig;
import com.mints.highgold.common.Constant;
import com.mints.highgold.manager.LiebaoManager;
import com.mints.highgold.manager.LyAdManager;
import com.mints.highgold.manager.MiitHelper;
import com.mints.highgold.manager.TTAdManagerHolder;
import com.mints.highgold.net.LoanService;
......@@ -142,9 +141,6 @@ public class MintsApplication extends MultiDexApplication {
// 猎豹游戏初始化
LiebaoManager.getInstance().initCmGameSdk();
// 立言积分初始化
// initGold(this);
// 初始化ShareSDK
MobSDK.init(this);
......@@ -200,7 +196,7 @@ public class MintsApplication extends MultiDexApplication {
initTuia();
// Mintegral广告
// initMintegral();
initMintegral();
}
/**
......
......@@ -148,7 +148,7 @@ public class CsjFullVedioAdManager implements LyVedioAdManagerView {
// System.out.println("mcg __ csjfull onAdVideoBarClick");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_HYTECH, Constant.EVENT_TYPE_FOUR, "", "");
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_TWO, "", "");
......
......@@ -215,7 +215,7 @@ public class CsjVedioAdManager implements LyVedioAdManagerView {
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_HYTECH, Constant.EVENT_TYPE_FOUR, "", "");
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
......
......@@ -32,7 +32,7 @@ public class MintegralVedioAdManager implements MintegralVedioAdManagerView {
private static MintegralVedioAdManager _inst;
// private MintegralVedioAdPresenter mintegralVedioAdPresenter;
// private MintegralVedioAdPresenter mintegralVedioAdPresenter;
private MintegralVedioAdListener mintegralVedioAdListener;
Activity activity;
......@@ -83,9 +83,9 @@ public class MintegralVedioAdManager implements MintegralVedioAdManagerView {
// }
try {
if (mDialog != null) {
mDialog = null;
}
// if (mDialog != null) {
// mDialog = null;
// }
if (mNetStateOnReceive != null && activity != null) {
activity.unregisterReceiver(mNetStateOnReceive);
}
......@@ -140,12 +140,10 @@ public class MintegralVedioAdManager implements MintegralVedioAdManagerView {
@Override
public void onLoadSuccess(String unitId) {
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_MINTEGRAL, Constant.EVENT_TYPE_ZERO, "", "");
System.out.println("mcg __ onLoadSuccess");
}
@Override
public void onVideoLoadSuccess(String unitId) {
System.out.println("mcg __ onVideoLoadSuccess");
if (mMTGRewardVideoHandler.isReady()) {
mMTGRewardVideoHandler.show(mRewardId, mUserId);
} else {
......@@ -177,15 +175,22 @@ public class MintegralVedioAdManager implements MintegralVedioAdManagerView {
@Override
public void onAdShow() {
System.out.println("mcg __ onAdShow");
}
@Override
public void onAdClose(boolean isCompleteView, String RewardName, float RewardAmout) {
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_MINTEGRAL, Constant.EVENT_TYPE_THREE, "", "");
if (isCompleteView) {
showDialog(RewardName, RewardAmout);
if (mintegralVedioAdListener != null) {
mintegralVedioAdListener.mintegralVedioAdAdSuccess();
}
// if (activity != null) {
// mintegralVedioAdPresenter.reportAddCoinMsg(activity, getAdMapVO(carrierType));
// }
}
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_MINTEGRAL, Constant.EVENT_TYPE_THREE, "", "");
System.out.println("mcg __ onAdClose isCompleteView:" + isCompleteView);
......@@ -193,7 +198,6 @@ public class MintegralVedioAdManager implements MintegralVedioAdManagerView {
@Override
public void onVideoAdClicked(String unitId) {
System.out.println("mcg __ onVideoAdClicked");
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_MINTEGRAL, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
......@@ -209,21 +213,10 @@ public class MintegralVedioAdManager implements MintegralVedioAdManagerView {
@Override
public void onVideoComplete(String unitId) {
System.out.println("mcg __ onVideoComplete");
}
@Override
public void onEndcardShow(String unitId) {
if (mintegralVedioAdListener != null) {
mintegralVedioAdListener.mintegralVedioAdAdSuccess();
}
// if (activity != null) {
// mintegralVedioAdPresenter.reportAddCoinMsg(activity, getAdMapVO(carrierType));
// }
// System.out.println("mcg __ onEndcardShow");
}
});
......
......@@ -26,17 +26,17 @@ public class VedioAdingManager {
private YlhVedioAdManager ylhVedioAdManager;
private CsjVedioAdManager csjVedioAdManager;
private CsjFullVedioAdManager csjFullVedioAdManager;
// private MintegralVedioAdManager mintegralVedioAdManager;
private MintegralVedioAdManager mintegralVedioAdManager;
private HytechVedioAdManager hytechVedioAdManager;
private int ylhWeight;
private int csjFullWeight;
private int csjVedioWeight;
private int hytechVedioWeight;
private int mintegralWeight;
private ArrayList<Integer> weightList;
private boolean isVedioAdDownload = false;// 是否点击广告下载 true-点击
private int randomWeightTest;
private Activity activity;
public static VedioAdingManager getInstance(Activity activity) {
......@@ -64,30 +64,40 @@ public class VedioAdingManager {
csjVedioAdManager = CsjVedioAdManager.getInstance(activity);
csjFullVedioAdManager = CsjFullVedioAdManager.getInstance(activity);
hytechVedioAdManager = HytechVedioAdManager.getInstance(activity);
// mintegralVedioAdManager = MintegralVedioAdManager.getInstance(activity);
mintegralVedioAdManager = MintegralVedioAdManager.getInstance(activity);
weightList = new ArrayList<>();
}
/**
* 初始化广告权重
*/
public void initAdWeight(int csjVedioWeight, int ylhWeight, int csjFullWeight, int hytechVedioWeight) {
public void initAdWeight(int csjVedioWeight, int ylhWeight, int csjFullWeight, int hytechVedioWeight, int mintegralWeight) {
this.csjVedioWeight = csjVedioWeight;
this.ylhWeight = ylhWeight;
this.csjFullWeight = csjFullWeight;
this.hytechVedioWeight = hytechVedioWeight;
this.mintegralWeight = mintegralWeight;
}
/**
* 获取广告类型配置
* 根据类型加载对应视频(第一次加载)
*
* @param bean
*/
private String getVedioAdType() {
// 根据权重获取广告类型
String adType = getRandomWeightAdtype();
System.out.println("mcg __ 权重结果返回的广告类型:" + adType);
return adType;
public void loadAding(VedioAdingBean bean) {
isVedioAdDownload = false;
loadAdVedio(getVedioAdType(), bean);
}
/**
* 加载失败优先级对应视频
*
* @param bean
*/
public void loadFailAding(VedioAdingBean bean) {
isVedioAdDownload = false;
loadAdVedio(getNextAdType(), bean);
}
/**
* 根据广告优先级获取下一个
......@@ -100,12 +110,108 @@ public class VedioAdingManager {
nextAdType = Constant.CSJ_FULL_AD;
} else if (AppConfig.hytechVedioAdCount > 0) {
nextAdType = Constant.HYTECH_VEDIO_AD;
} else if (AppConfig.mintegralAdCount > 0) {
nextAdType = Constant.MINTEGRAL_VEDIO_AD;
} else if (AppConfig.ylhAdCount > 0) {
nextAdType = Constant.YLH_VEDIO_AD;
}
return nextAdType;
}
/**
* 获取广告类型配置
*/
private String getVedioAdType() {
// 根据权重获取广告类型
String adType = getRandomWeightAdtype();
System.out.println("mcg __ 权重结果返回的广告类型:" + adType);
return adType;
}
/**
* 根据权重 获取广告类型
*/
private String getRandomWeightAdtype() {
String adType = "";
// int randomWeight = getRandomWeight(weightList);
int randomWeight = getRandomWeight();
if (randomWeight == ylhWeight) {
adType = Constant.YLH_VEDIO_AD;
} else if (randomWeight == csjFullWeight) {
adType = Constant.CSJ_FULL_AD;
} else if (randomWeight == csjVedioWeight) {
adType = Constant.CSJ_VEDIO_AD;
} else if (randomWeight == hytechVedioWeight) {
adType = Constant.HYTECH_VEDIO_AD;
} else if (randomWeight == mintegralWeight) {
adType = Constant.MINTEGRAL_VEDIO_AD;
}
return adType;
}
/**
* 获取当前权重比
*
* @return
*/
private int getRandomWeight() {
int weight = 0;
if (weightList != null) {
weightList.clear();
}
// 若没有视频完成数,不加入权重计算范围内
if (AppConfig.csjVedioAdCount > 0) {
weightList.add(csjVedioWeight);
weight = weight + csjVedioWeight;
System.out.print("mcg __ 权重值:csjVedioWeight:" + csjVedioWeight);
}
if (AppConfig.csjFullAdCount > 0) {
weightList.add(csjFullWeight);
weight = weight + csjFullWeight;
System.out.print(" mcg __ 权重值:csjFullWeight:" + csjFullWeight);
}
if (AppConfig.hytechVedioAdCount > 0) {
weightList.add(hytechVedioWeight);
weight = weight + hytechVedioWeight;
System.out.print(" mcg __ 权重值:hytechVedioWeight:" + hytechVedioWeight);
}
if (AppConfig.ylhAdCount > 0) {
weightList.add(ylhWeight);
weight = weight + ylhWeight;
System.out.println(" mcg __ 权重值:ylhWeight:" + ylhWeight);
}
if (AppConfig.mintegralAdCount > 0) {
weightList.add(mintegralWeight);
weight = weight + mintegralWeight;
System.out.println(" mcg __ 权重值:mintegralWeight:" + mintegralWeight);
}
// 权重随机
System.out.print("mcg __ 1、权重总值:" + weight);
if (weightList != null && weightList.size() > 0) {
Random r = new Random();
int randomWeight = r.nextInt(weight) + 1;
System.out.print(" 2、权重随机值:" + randomWeight);
for (Integer w : weightList) {
randomWeight -= w;
if (randomWeight <= 0) {
System.out.println(" 3、权重结果:" + w);
return w;
}
}
return weightList.get(0);
}
return -1;
}
/**
* 是否点击下载
*
......@@ -116,17 +222,77 @@ public class VedioAdingManager {
}
/**
* 根据类型加载对应视频
* 获取所有视频完成数状态 true-无可看视频
*
* @param bean
* @return
*/
public void loadAding(VedioAdingBean bean) {
isVedioAdDownload = false;
public boolean getVedioFinishFlag() {
int csjVedioAdCount = AppConfig.csjVedioAdCount;
int ylhAdCount = AppConfig.ylhAdCount;
int csjFullAdCount = AppConfig.csjFullAdCount;
int hytechVedioAdCount = AppConfig.hytechVedioAdCount;
int mintegralAdCount = AppConfig.mintegralAdCount;
if (csjFullAdCount <= 0 && ylhAdCount <= 0 &&
csjVedioAdCount <= 0 && hytechVedioAdCount <= 0 &&
mintegralAdCount <= 0) {
// showToast("今日视频已看完,请明天再来吧");
return true;
}
return false;
}
/**
* 释放资源
*/
public void destory() {
if (ylhVedioAdManager != null) {
ylhVedioAdManager.destory();
ylhVedioAdManager = null;
}
if (csjVedioAdManager != null) {
csjVedioAdManager.destory();
csjVedioAdManager = null;
}
if (csjFullVedioAdManager != null) {
csjFullVedioAdManager.destory();
csjFullVedioAdManager = null;
}
if (hytechVedioAdManager != null) {
hytechVedioAdManager.destory();
hytechVedioAdManager = null;
}
if (mintegralVedioAdManager != null) {
mintegralVedioAdManager.destory();
mintegralVedioAdManager = null;
}
}
public void setVedioAdingListener(VedioAdingListener vedioAdingListener) {
this.vedioAdingListener = vedioAdingListener;
}
/**
* 加载成功失败回调
*/
public interface VedioAdingListener {
void vedioAdingListenerError(String adType);
void vedioAdingListenerFail(String adType);
void vedioAdingListenerSuccess(String adType);
}
/**
* 展示视频
*
* @param vedioAdType
* @param bean
*/
private void loadAdVedio(String vedioAdType, VedioAdingBean bean) {
try {
// 获取最终广告类型
String vedioAdType = getVedioAdType();
if (TextUtils.isEmpty(vedioAdType)) {
ToastUtil.show(activity, "今日视频已看完,请明天再来吧");
return;
}
......@@ -270,250 +436,43 @@ public class VedioAdingManager {
}
}
});
}
// else if (TextUtils.equals(vedioAdType, Constant.MINTEGRAL_VEDIO_AD)) {
// // MINTEGRAL激励视频
// if (mintegralVedioAdManager == null) {
// if (activity == null) {
// if (vedioAdingListener != null) {
// vedioAdingListener.vedioAdingListenerError(Constant.MINTEGRAL_VEDIO_AD);
// }
// return;
// }
// mintegralVedioAdManager = MintegralVedioAdManager.getInstance(activity);
// }
//
// mintegralVedioAdManager.loadMintegralAd(bean.getDownloadCoin(), bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
// mintegralVedioAdManager.setMintegralVedioAdListener(new MintegralVedioAdManager.MintegralVedioAdListener() {
// @Override
// public void mintegralVedioAdFail() {
// if (vedioAdingListener != null) {
// vedioAdingListener.vedioAdingListenerFail(Constant.MINTEGRAL_VEDIO_AD);
// }
// }
//
// @Override
// public void mintegralVedioAdAdSuccess() {
// AppConfig.mintegralAdCount--;
// AppConfig.preAdType = Constant.MINTEGRAL_VEDIO_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
// if (vedioAdingListener != null) {
// vedioAdingListener.vedioAdingListenerSuccess(Constant.MINTEGRAL_VEDIO_AD);
// }
// }
//
// @Override
// public void mintegralVedioAdDownload() {
// isVedioAdDownload = true;
// }
// });
// }
} catch (Exception e) {
e.printStackTrace();
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerError(bean.getCarrierType());
}
}
}
/**
* 加载失败优先级对应视频
*
* @param bean
*/
public void loadFailAding(VedioAdingBean bean) {
isVedioAdDownload = false;
try {
// 获取最终广告类型
String vedioAdType = getNextAdType();
if (TextUtils.isEmpty(vedioAdType)) {
return;
}
if (TextUtils.equals(vedioAdType, Constant.YLH_VEDIO_AD)) {
// 优量汇
if (ylhVedioAdManager == null) {
} else if (TextUtils.equals(vedioAdType, Constant.MINTEGRAL_VEDIO_AD)) {
// MINTEGRAL激励视频
if (mintegralVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerError(Constant.YLH_VEDIO_AD);
vedioAdingListener.vedioAdingListenerError(Constant.MINTEGRAL_VEDIO_AD);
}
return;
}
ylhVedioAdManager = YlhVedioAdManager.getInstance(activity);
mintegralVedioAdManager = MintegralVedioAdManager.getInstance(activity);
}
ylhVedioAdManager.loanYlhAd(bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
ylhVedioAdManager.setYlhVedioAdListener(new YlhVedioAdManager.YlhVedioAdListener() {
mintegralVedioAdManager.loadMintegralAd(bean.getDownloadCoin(), bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
mintegralVedioAdManager.setMintegralVedioAdListener(new MintegralVedioAdManager.MintegralVedioAdListener() {
@Override
public void ylhVedioAdFail() {
public void mintegralVedioAdFail() {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerFail(Constant.YLH_VEDIO_AD);
vedioAdingListener.vedioAdingListenerFail(Constant.MINTEGRAL_VEDIO_AD);
}
}
@Override
public void ylhVedioAdSuccess() {
AppConfig.ylhAdCount--;
AppConfig.preAdType = Constant.YLH_VEDIO_AD;
public void mintegralVedioAdAdSuccess() {
AppConfig.mintegralAdCount--;
AppConfig.preAdType = Constant.MINTEGRAL_VEDIO_AD;
AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.YLH_VEDIO_AD);
vedioAdingListener.vedioAdingListenerSuccess(Constant.MINTEGRAL_VEDIO_AD);
}
}
@Override
public void ylhVedioAdDownload() {
public void mintegralVedioAdDownload() {
isVedioAdDownload = true;
}
});
} else if (TextUtils.equals(vedioAdType, Constant.CSJ_FULL_AD)) {
// 穿山甲全屏
if (csjFullVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerError(Constant.CSJ_FULL_AD);
}
return;
}
csjFullVedioAdManager = CsjFullVedioAdManager.getInstance(activity);
}
csjFullVedioAdManager.loadCsjFullAd(bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
csjFullVedioAdManager.setCsjFullVedioAdListener(new CsjFullVedioAdManager.CsjFullVedioAdListener() {
@Override
public void csjFullVedioAdFail() {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerFail(Constant.CSJ_FULL_AD);
}
}
@Override
public void csjFullVedioAdSuccess() {
AppConfig.csjFullAdCount--;
AppConfig.preAdType = Constant.CSJ_FULL_AD;
AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.CSJ_FULL_AD);
}
}
@Override
public void csjFullVedioDownload() {
isVedioAdDownload = true;
}
});
} else if (TextUtils.equals(vedioAdType, Constant.CSJ_VEDIO_AD)) {
// 穿山甲激励视频
if (csjVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerError(Constant.CSJ_VEDIO_AD);
}
return;
}
csjVedioAdManager = CsjVedioAdManager.getInstance(activity);
}
csjVedioAdManager.loadCsjAd(bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
csjVedioAdManager.setCsjVedioAdListener(new CsjVedioAdManager.CsjVedioAdListener() {
@Override
public void csjVedioAdFail() {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerFail(Constant.CSJ_VEDIO_AD);
}
}
@Override
public void csjVedioAdSuccess() {
AppConfig.csjVedioAdCount--;
AppConfig.preAdType = Constant.CSJ_VEDIO_AD;
AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.CSJ_VEDIO_AD);
}
}
@Override
public void csjVedioDownload() {
isVedioAdDownload = true;
}
});
} else if (TextUtils.equals(vedioAdType, Constant.HYTECH_VEDIO_AD)) {
// HYTECH
if (hytechVedioAdManager == null) {
if (activity == null) {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerError(bean.getCarrierType());
}
return;
}
hytechVedioAdManager = HytechVedioAdManager.getInstance(activity);
}
hytechVedioAdManager.loanHytechAd(bean.getDownloadCoin(), bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
hytechVedioAdManager.setHytechVedioAdListener(new HytechVedioAdManager.HytechVedioAdListener() {
@Override
public void hytechVedioAdFail() {
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerFail(Constant.HYTECH_VEDIO_AD);
}
}
@Override
public void hytechVedioAdSuccess() {
AppConfig.hytechVedioAdCount--;
AppConfig.preAdType = Constant.HYTECH_VEDIO_AD;
AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
if (vedioAdingListener != null) {
vedioAdingListener.vedioAdingListenerSuccess(Constant.HYTECH_VEDIO_AD);
}
}
});
}
// else if (TextUtils.equals(vedioAdType, Constant.MINTEGRAL_VEDIO_AD)) {
// // MINTEGRAL激励视频
// if (mintegralVedioAdManager == null) {
// if (activity == null) {
// if (vedioAdingListener != null) {
// vedioAdingListener.vedioAdingListenerError(Constant.MINTEGRAL_VEDIO_AD);
// }
// return;
// }
// mintegralVedioAdManager = MintegralVedioAdManager.getInstance(activity);
// }
//
// mintegralVedioAdManager.loadMintegralAd(bean.getDownloadCoin(), bean.getCurCoin(), bean.getCarrierType(), bean.getExtraId());
// mintegralVedioAdManager.setMintegralVedioAdListener(new MintegralVedioAdManager.MintegralVedioAdListener() {
// @Override
// public void mintegralVedioAdFail() {
// if (vedioAdingListener != null) {
// vedioAdingListener.vedioAdingListenerFail(Constant.MINTEGRAL_VEDIO_AD);
// }
// }
//
// @Override
// public void mintegralVedioAdAdSuccess() {
// AppConfig.mintegralAdCount--;
// AppConfig.preAdType = Constant.MINTEGRAL_VEDIO_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
// if (vedioAdingListener != null) {
// vedioAdingListener.vedioAdingListenerSuccess(Constant.MINTEGRAL_VEDIO_AD);
// }
// }
//
// @Override
// public void mintegralVedioAdDownload() {
// isVedioAdDownload = true;
// }
// });
// }
} catch (Exception e) {
e.printStackTrace();
if (vedioAdingListener != null) {
......@@ -522,139 +481,5 @@ public class VedioAdingManager {
}
}
/**
* 获取所有视频完成数状态 true-无可看视频
*
* @return
*/
public boolean getVedioFinishFlag() {
int csjVedioAdCount = AppConfig.csjVedioAdCount;
int ylhAdCount = AppConfig.ylhAdCount;
int csjFullAdCount = AppConfig.csjFullAdCount;
int hytechVedioAdCount = AppConfig.hytechVedioAdCount;
if (csjFullAdCount <= 0 && ylhAdCount <= 0 && csjVedioAdCount <= 0 && hytechVedioAdCount <= 0) {
// showToast("今日视频已看完,请明天再来吧");
return true;
}
return false;
}
/**
* 释放资源
*/
public void destory() {
if (ylhVedioAdManager != null) {
ylhVedioAdManager.destory();
ylhVedioAdManager = null;
}
if (csjVedioAdManager != null) {
csjVedioAdManager.destory();
csjVedioAdManager = null;
}
if (csjFullVedioAdManager != null) {
csjFullVedioAdManager.destory();
csjFullVedioAdManager = null;
}
if (hytechVedioAdManager != null) {
hytechVedioAdManager.destory();
hytechVedioAdManager = null;
}
// if (mintegralVedioAdManager != null) {
// mintegralVedioAdManager.destory();
// mintegralVedioAdManager = null;
// }
}
public void setVedioAdingListener(VedioAdingListener vedioAdingListener) {
this.vedioAdingListener = vedioAdingListener;
}
/**
* 加载成功失败回调
*/
public interface VedioAdingListener {
void vedioAdingListenerError(String adType);
void vedioAdingListenerFail(String adType);
void vedioAdingListenerSuccess(String adType);
}
/**
* 根据权重 获取广告类型
*/
private String getRandomWeightAdtype() {
String adType = "";
// int randomWeight = getRandomWeight(weightList);
int randomWeight = getRandomWeight();
if (randomWeight == ylhWeight) {
adType = Constant.YLH_VEDIO_AD;
} else if (randomWeight == csjFullWeight) {
adType = Constant.CSJ_FULL_AD;
} else if (randomWeight == csjVedioWeight) {
adType = Constant.CSJ_VEDIO_AD;
} else if (randomWeight == hytechVedioWeight) {
adType = Constant.HYTECH_VEDIO_AD;
}
return adType;
}
/**
* 获取当前权重比
*
* @return
*/
private int getRandomWeight() {
int weight = 0;
if (weightList != null) {
weightList.clear();
}
// 若没有视频完成数,不加入权重计算范围内
if (AppConfig.csjVedioAdCount > 0) {
weightList.add(csjVedioWeight);
weight = weight + csjVedioWeight;
System.out.print("mcg __ 权重值:csjVedioWeight:" + csjVedioWeight);
}
if (AppConfig.csjFullAdCount > 0) {
weightList.add(csjFullWeight);
weight = weight + csjFullWeight;
System.out.print(" mcg __ 权重值:csjFullWeight:" + csjFullWeight);
}
if (AppConfig.hytechVedioAdCount > 0) {
weightList.add(hytechVedioWeight);
weight = weight + hytechVedioWeight;
System.out.print(" mcg __ 权重值:hytechVedioWeight:" + hytechVedioWeight);
}
if (AppConfig.ylhAdCount > 0) {
weightList.add(ylhWeight);
weight = weight + ylhWeight;
System.out.println(" mcg __ 权重值:ylhWeight:" + ylhWeight);
}
// 权重随机
System.out.print("mcg __ 1、权重总值:" + weight);
if (weightList != null && weightList.size() > 0) {
Random r = new Random();
int randomWeight = r.nextInt(weight) + 1;
System.out.print(" mcg __ 2、权重随机值:" + randomWeight);
for (Integer w : weightList) {
randomWeight -= w;
if (randomWeight <= 0) {
// ToastUtil.show(MintsApplication.getContext(), "权重广告随机值为:" + randomWeightTest + " 广告类型为:" + w);
System.out.println(" mcg __3、权重结果:" + w);
return w;
}
}
return weightList.get(0);
}
return -1;
}
}
......@@ -166,7 +166,7 @@ public class YlhVedioAdManager implements LyVedioAdManagerView {
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_HYTECH, Constant.EVENT_TYPE_FOUR, "", "");
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
System.out.println("mcg ylh 点击");
......
package com.mints.highgold.ad.banner
import android.app.Activity
import android.view.View
import com.lechuan.midunovel.view.FoxStreamerView
import com.mints.highgold.common.AppConfig
import com.mints.highgold.manager.TaAdManager
import com.mints.highgold.manager.UserManager
class BannerAdmanager {
var activity: Activity? = null
var fsvAward: FoxStreamerView? = null
constructor(activity: Activity?) {
this.activity = activity
}
/**
* 展示banner
*
* @param carrierType
* @param view 要展示的banner
*/
fun showBannerAd(carrierType: String, view: View?) {
if (UserManager.getInstance().adShowFlag) initBannerAd(carrierType, view)
}
/**
* banner广告显示类型 0-推啊
*
* @param carrierType
* @param view
*/
private fun initBannerAd(carrierType: String, view: View?) {
if (AppConfig.bannerAdType == 0) loadTaBannerAd(carrierType, view)
}
private fun loadTaBannerAd(carrierType: String, view: View?) {
if (view != null) {
if (view is FoxStreamerView) {
fsvAward = view
fsvAward?.loadAd(TaAdManager.TA_AD_AWARD_BANNER, UserManager.getInstance().userID)
}
}
}
fun ondestory() {
fsvAward?.destroy()
}
}
\ No newline at end of file
......@@ -58,11 +58,11 @@ public class AppConfig {
/**
* mintegralVedio 剩余广告播放数
*/
public static int mintegralAdCount = 5;
public static int mintegralAdCount = 0;
/**
* hytechVedio 剩余广告播放数
*/
public static int hytechVedioAdCount = 5;
public static int hytechVedioAdCount = 0;
/**
* 一览视频 时间间隔 单位-秒
......@@ -73,4 +73,9 @@ public class AppConfig {
* 插屏广告显示类型 0-穿山甲 1-优量汇 2-推啊
*/
public static int interactionAdType = 0;
/**
* banner显示类型 0-推啊
*/
public static int bannerAdType = 0;
}
......@@ -5,7 +5,6 @@ import android.animation.ValueAnimator;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.LinearInterpolator;
......@@ -19,19 +18,16 @@ import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.lechuan.midunovel.base.util.FoxBaseCommonUtils;
import com.lechuan.midunovel.view.FoxListener;
import com.lechuan.midunovel.view.FoxStreamerView;
import com.mints.highgold.BuildConfig;
import com.mints.highgold.R;
import com.mints.highgold.ad.HytechVedioAdManager;
import com.mints.highgold.ad.VedioAdingManager;
import com.mints.highgold.ad.banner.BannerAdmanager;
import com.mints.highgold.common.AppConfig;
import com.mints.highgold.common.Constant;
import com.mints.highgold.manager.TTAdManagerHolder;
import com.mints.highgold.manager.TTNativeExpressManager;
import com.mints.highgold.manager.TTPreLoadExpressManager;
import com.mints.highgold.manager.TaAdManager;
import com.mints.highgold.manager.TrackManager;
import com.mints.highgold.manager.UserManager;
import com.mints.highgold.manager.YlhAdManager;
......@@ -60,7 +56,6 @@ import java.util.Calendar;
import java.util.HashMap;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
......@@ -121,11 +116,12 @@ public class AwardActivity extends BaseActivity implements AwardView {
private int isBackFlag;//点击 金币翻倍按钮 0-默认点击翻倍 1-点击返回 2-点击返回且提示遗憾
private boolean isClickScreen = true; // 是否点击屏幕跳转广告
private int netCoin = -1;
private int netCsjVedioComplatecount = -1;
private int netCsjVedioNeedcount = -1;
private ObjectAnimator animator;
private UserTaskMsgBean userConfig;
private BannerAdmanager bannerAdManager;
@Override
protected int getContentViewLayoutID() {
......@@ -150,7 +146,9 @@ public class AwardActivity extends BaseActivity implements AwardView {
tvAwardHint.setVisibility(View.GONE);
fsvAward.setVisibility(View.VISIBLE);
fsvAward.loadAd(TaAdManager.TA_AD_AWARD_BANNER, UserManager.getInstance().getUserID());
bannerAdManager = new BannerAdmanager(AwardActivity.this);
bannerAdManager.showBannerAd("", fsvAward);
}
initDataView();
......@@ -215,13 +213,12 @@ public class AwardActivity extends BaseActivity implements AwardView {
@Override
public void onDestroy() {
if (fsvAward != null) {
fsvAward.destroy();
if (bannerAdManager != null) {
bannerAdManager.ondestory();
}
super.onDestroy();
try {
TTPreLoadExpressManager.getInstance().loadTtFrameLayout(getContext());
} catch (Exception e) {
e.printStackTrace();
......@@ -340,38 +337,65 @@ public class AwardActivity extends BaseActivity implements AwardView {
System.out.println("mcg __ VedioAdingManager: vedioAdingListenerFail");
// hideLoading();
vedioAdingManager.loadFailAding(bean);
vedioAdingManager.setVedioAdingListener(new VedioAdingManager.VedioAdingListener() {
@Override
public void vedioAdingListenerError(String adType) {
showToast("加载超时,请休息一下");
hideLoading();
if (csjVedioAdCount > 0) {
// 穿山甲当前进度 < 总数
fullAdException = false;
loadCsjAd(CARRIER_TYPE);
} else if (csjFullAdCount > 0) {
loadCsjFullAd(CARRIER_TYPE);
} else if (hytechVedioAdCount > 0) {
HytechVedioAdManager hytechVedioAdManager = HytechVedioAdManager.getInstance(AwardActivity.this);
hytechVedioAdManager.setHytechVedioAdListener(new HytechVedioAdManager.HytechVedioAdListener() {
@Override
public void hytechVedioAdFail() {
hideLoading();
showToast("视频加载异常,请重试!");
}
@Override
public void hytechVedioAdSuccess() {
hideLoading();
AppConfig.hytechVedioAdCount--;
AppConfig.preAdType = Constant.HYTECH_VEDIO_AD;
AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
}
});
hytechVedioAdManager.loanHytechAd(bean.getDownloadCoin(), curCoin, CARRIER_TYPE, extraId);
} else if (ylhAdCount > 0) {
loanYlhAd(CARRIER_TYPE);
} else {
hideLoading();
showToast("今日视频已看完,请明天再来吧");
}
System.out.println("mcg __ 内部 vedioAdingListenerError adType:" + adType);
}
@Override
public void vedioAdingListenerFail(String adType) {
hideLoading();
showToast("视频加载异常,请重试!");
System.out.println("mcg __ 内部 vedioAdingListenerFail adType:" + adType);
}
@Override
public void vedioAdingListenerSuccess(String adType) {
System.out.println("mcg __ 内部 vedioAdingListenerSuccess adType:" + adType);
hideLoading();
vedioAdingSuccess(adType);
}
});
// if (csjVedioAdCount > 0) {
// // 穿山甲当前进度 < 总数
// fullAdException = false;
// loadCsjAd(CARRIER_TYPE);
// } else if (csjFullAdCount > 0) {
// loadCsjFullAd(CARRIER_TYPE);
// } else if (hytechVedioAdCount > 0) {
// HytechVedioAdManager hytechVedioAdManager = HytechVedioAdManager.getInstance(AwardActivity.this);
// hytechVedioAdManager.setHytechVedioAdListener(new HytechVedioAdManager.HytechVedioAdListener() {
// @Override
// public void hytechVedioAdFail() {
// hideLoading();
// showToast("视频加载异常,请重试!");
// }
//
// @Override
// public void hytechVedioAdSuccess() {
// hideLoading();
//
// AppConfig.hytechVedioAdCount--;
// AppConfig.preAdType = Constant.HYTECH_VEDIO_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
// }
// });
// hytechVedioAdManager.loanHytechAd(bean.getDownloadCoin(), curCoin, CARRIER_TYPE, extraId);
// } else if (ylhAdCount > 0) {
// loanYlhAd(CARRIER_TYPE);
// } else {
// hideLoading();
// showToast("今日视频已看完,请明天再来吧");
// }
}
......@@ -380,13 +404,7 @@ public class AwardActivity extends BaseActivity implements AwardView {
hideLoading();
// showToast("成功了");
System.out.println("mcg __ VedioAdingManager: vedioAdingListenerSuccess --- 是否点击下载isVedioAdDownload=" + vedioAdingManager.isVedioAdDownload());
if (TextUtils.equals(adType, Constant.LY_VEDIO_AD) || TextUtils.equals(adType, Constant.HYTECH_VEDIO_AD)) {
if (!isFinishing()) {
finish();
}
} else {
setAdFinshLayout();
}
vedioAdingSuccess(adType);
}
});
......@@ -462,19 +480,31 @@ public class AwardActivity extends BaseActivity implements AwardView {
}
}
/**
* 广告返回结果
*
* @param adType
*/
private void vedioAdingSuccess(String adType) {
if (TextUtils.equals(adType, Constant.LY_VEDIO_AD) || TextUtils.equals(adType, Constant.HYTECH_VEDIO_AD)) {
if (!isFinishing()) {
finish();
}
} else {
setAdFinshLayout();
}
}
@Override
public void getUserTaskMsgSuc(UserTaskMsgBean data) {
if (data == null) {
netCoin = -1;
netCsjVedioComplatecount = -1;
netCsjVedioNeedcount = -1;
return;
}
userConfig = data;
netCoin = data.getCoin();
netCsjVedioComplatecount = data.getCsj_vedio_complatecount();
netCsjVedioNeedcount = data.getCsj_vedio_needcount();
int sunCoin;
if (netCoin > 0) {
......@@ -510,8 +540,6 @@ public class AwardActivity extends BaseActivity implements AwardView {
@Override
public void getUserTaskMsgFail() {
netCoin = -1;
netCsjVedioComplatecount = -1;
netCsjVedioNeedcount = -1;
}
@Override
......@@ -753,6 +781,7 @@ public class AwardActivity extends BaseActivity implements AwardView {
private void loanYlhAd(String carrierType) {
showLoading("加载中...");
isClickScreen = true;
String ylhPostId;
switch (carrierType) {
case Constant.CARRIER_ONLINE_INCOME_DOUBLE:// 在线收益翻倍
......@@ -832,7 +861,11 @@ public class AwardActivity extends BaseActivity implements AwardView {
@Override
public void onADClick() {//激励视频广告被点击
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
}
@Override
......@@ -870,6 +903,7 @@ public class AwardActivity extends BaseActivity implements AwardView {
showLoading("加载中...");
isloadTTVedio = false;
isClickScreen = true;
String codeId = TTAdManagerHolder.TT_AD_VEDIO_MAIN_DEV;
if (!BuildConfig.DEBUG) {
switch (carrierType) {
......@@ -985,6 +1019,11 @@ public class AwardActivity extends BaseActivity implements AwardView {
public void onAdVideoBarClick() {//广告的下载bar点击回调
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
}
@Override
......@@ -1039,17 +1078,12 @@ public class AwardActivity extends BaseActivity implements AwardView {
showLoading("加载中...");
String codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_EXCEPTION;
isClickScreen = true;
switch (carrierType) {
case Constant.CARRIER_OFFLINE_DOUBLE:// 离线收益翻倍
codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_OFFLINE_DOUBLE;
break;
// case Constant.CARRIER_DRINK_PATCH:// 喝水补卡
// codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_DRINK_PATCH;
// break;
// case Constant.CARRIER_VERSUS_DRINKTEA://喝饮料
// codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_VERSUS_DRINKTEA;
// break;
case Constant.CARRIER_CHALLENGE_TURN:// 挑战大转盘
codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_CHALLENGE_TURN;
break;
......@@ -1108,6 +1142,11 @@ public class AwardActivity extends BaseActivity implements AwardView {
public void onAdVideoBarClick() {
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_TWO, "", "");
if (isClickScreen) {
// 防止重复
TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_FOUR, "", "");
isClickScreen = false;
}
}
@Override
......
......@@ -12,7 +12,6 @@ import android.widget.AdapterView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
......@@ -59,7 +58,6 @@ import com.mints.highgold.ui.widgets.countdowntimer.OnCountDownTimerListener;
import com.mints.highgold.ui.widgets.refresh.CustomRefreshLayout;
import com.mints.highgold.utils.SPUtil;
import com.mints.highgold.utils.SpanUtils;
import com.mints.highgold.utils.TimeRender;
import com.mints.highgold.utils.rxutil.CommonRxTask;
import com.mints.highgold.utils.rxutil.RxjavaUtil;
import com.mints.library.base.BaseWebActivity;
......@@ -117,17 +115,12 @@ public class MainFragment extends BaseFragment
TextView tvFragmentMainRedbox;
@Bind(R.id.lv_main_gamelist)
ScollViewListView lvMainGamelist;
@Bind(R.id.ll_fragment_main_vedio)
LinearLayout llFragmentMainVedio;
@Bind(R.id.ll_fragment_main_try)
LinearLayout llFragmentMainTry;
@Bind(R.id.tv_fragment_main_gametitle)
TextView tvFragmentMainGametitle;
@Bind(R.id.iv_fragment_main_gameicon)
NiceImageView ivFragmentMainGameicon;
private AlertDialog dialog;
private AlertDialog drinkDialog;
CountDownTimerSupport redBoxTimer = null;//红包
CountDownTimerSupport drinkBtnTimer = null;//喝水
long countDownInterval = 1000;//间隔时长
......@@ -289,7 +282,6 @@ public class MainFragment extends BaseFragment
public void onPause() {
super.onPause();
onTimerDestory();
if (drinkBtnTimer != null) {
drinkBtnTimer.stop();
drinkBtnTimer = null;
......@@ -319,8 +311,6 @@ public class MainFragment extends BaseFragment
drinkBtnTimer = null;
}
onTimerDestory();
if (mLocationHandler != null) {
mLocationHandler.removeCallbacksAndMessages(null);
mLocationHandler = null;
......@@ -402,7 +392,6 @@ public class MainFragment extends BaseFragment
activity.clickTab2Layout();
}
}
break;
case R.id.ll_fragment_main_friend:// 邀请好友
readyGo(FriendsNewActivity.class);
......@@ -478,8 +467,8 @@ public class MainFragment extends BaseFragment
// 设置随机广告权重
if (vedioAdingManager != null) {
vedioAdingManager.initAdWeight(data.getVedioplan_csj_vedio_rate(), data.getVedioplan_lyh_vedio_rate(), data.getVedioplan_csj_full_screen_video_rate(), data.getVedioplan_hytech_vedio_rate());
// vedioAdingManager.initAdWeight(0, 0, 0, 1);
vedioAdingManager.initAdWeight(data.getVedioplan_csj_vedio_rate(), data.getVedioplan_lyh_vedio_rate(), data.getVedioplan_csj_full_screen_video_rate(), data.getVedioplan_hytech_vedio_rate(),0);
// vedioAdingManager.initAdWeight(0, 0, 0,0, 1);
}
System.out.println("mcg __ 首页权重值:csjVedioWeight:" + data.getVedioplan_csj_vedio_rate() + " ylhWeight:" + data.getVedioplan_lyh_vedio_rate() + " csjFullWeight:" + data.getVedioplan_csj_full_screen_video_rate() + " hytechVedioAdWeight:" + data.getVedioplan_hytech_vedio_rate());
......@@ -489,11 +478,13 @@ public class MainFragment extends BaseFragment
AppConfig.ylhAdCount = data.getVedioplan_lyh_vedio_surplus();
AppConfig.csjFullAdCount = data.getVedioplan_csj_full_screen_video_surplus();
AppConfig.hytechVedioAdCount = data.getVedioplan_hytech_vedio_surplus();
AppConfig.mintegralAdCount = 0;
// AppConfig.csjVedioAdCount = 0;
// AppConfig.ylhAdCount = 0;
// AppConfig.csjFullAdCount = 0;
// AppConfig.hytechVedioAdCount = 20;
// AppConfig.hytechVedioAdCount = 0;
// AppConfig.mintegralAdCount = 20;
AppConfig.yilanVedioTime = data.getRedPacketSecond();
......@@ -594,21 +585,8 @@ public class MainFragment extends BaseFragment
if (userConfig.isRedEnvelopeShow()) {
rlFragmentMainRedbox.setVisibility(View.VISIBLE);
ivFragmentMainGift.setVisibility(View.GONE);
// 拆红包倒计时
int redBoxTime = data.getRedEnvelopeSecond();
// int redBoxTime = 30;
if (redBoxTime > 0) {
tvFragmentMainRedbox.setEnabled(false);
if (redBoxTimer != null) {//防止计时器重复
redBoxTimer.stop();
redBoxTimer = null;
}
redBoxTimer = new CountDownTimerSupport((int) (redBoxTime * countDownInterval), countDownInterval);
startTime(redBoxTimer, tvFragmentMainRedbox, 0, "可拆开");
} else {
tvFragmentMainRedbox.setEnabled(true);
tvFragmentMainRedbox.setText("可拆开");
}
tvFragmentMainRedbox.setEnabled(true);
} else {
rlFragmentMainRedbox.setVisibility(View.GONE);
// 首页泡泡点击的url
......@@ -632,63 +610,6 @@ public class MainFragment extends BaseFragment
}
}
/**
* 设置红包倒计时
* <p>
* type 0-红包 1-试玩 2-看视频
*/
private void startTime(CountDownTimerSupport timer, TextView tvText, int type, String content) {
timer.setOnCountDownTimerListener(new OnCountDownTimerListener() {
@Override
public void onTick(long millisUntilFinished) {
if (getActivity() != null && !getActivity().isFinishing()) {
System.out.println("mcg __ " + TimeRender.ms2HMS((int) (millisUntilFinished)));
if (tvText != null) {
if (type == 0) {
// 红包
tvText.setText(TimeRender.ms2HMS((int) (millisUntilFinished)));
} else if (type == 1) {
tvText.setText(TimeRender.ms2HMS((int) (millisUntilFinished)));
tvText.setBackground(getResources().getDrawable(R.drawable.shape_tv_gold_gury));
} else if (type == 2) {
tvText.setText(TimeRender.ms2HMS((int) (millisUntilFinished)));
tvText.setBackground(getResources().getDrawable(R.drawable.shape_tv_gold_gury));
}
}
}
}
@Override
public void onFinish() {
if (getActivity() != null && !getActivity().isFinishing()) {
if (tvText != null) {
if (type == 0) {
// 红包
tvText.setText(content);
} else if (type == 1) {
if (llFragmentMainTry != null) {
llFragmentMainTry.setEnabled(true);
}
tvText.setText(content);
tvText.setBackground(getResources().getDrawable(R.drawable.shape_main_water));
} else if (type == 2) {
if (llFragmentMainVedio != null) {
llFragmentMainVedio.setEnabled(true);
}
tvText.setText(content);
tvText.setBackground(getResources().getDrawable(R.drawable.shape_main_water));
}
}
}
}
});
timer.start();
}
@Override
public void getUserTaskMsgFail() {
if (mainMainCrlRefresh != null)
......@@ -699,39 +620,29 @@ public class MainFragment extends BaseFragment
@Override
public void reportTaskMsgV1Suc(String carrierType) {
if (userConfig != null) {
Bundle bundle = new Bundle();
if (TextUtils.equals(carrierType, Constant.CARRIER_DAILY_VIDEO)) {
// 首页视频 下载
int cash = userConfig.getVideoCoin() + userConfig.getConfigH5DownloadCoin();
Bundle bundle = new Bundle();
bundle.putInt(Constant.MAIN_CUR_COIN, cash);
// bundle.putInt(Constant.MAIN_ALL_COIN, userConfig.getCoin());
bundle.putInt(Constant.MAIN_CUR_FLAG, Constant.MAIN_CUR_ONE);
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_DAILY_VIDEO_DOWNLOAD);
readyGo(AwardActivity.class, bundle);
} else if (TextUtils.equals(carrierType, Constant.CARRIER_POP_INTERACTIVE_AD)) {
// 首页礼物
Bundle bundle = new Bundle();
bundle.putInt(Constant.MAIN_CUR_COIN, userConfig.getOnlineIncome());
// bundle.putInt(Constant.MAIN_ALL_COIN, userConfig.getCoin());
bundle.putInt(Constant.MAIN_CUR_FLAG, Constant.MAIN_CUR_ONE);
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_POP_INTERACTIVE_AD);
readyGo(AwardActivity.class, bundle);
} else if (TextUtils.equals(carrierType, Constant.CARRIER_ONLINE_INCOME)) {
// 在线收益
Bundle bundle = new Bundle();
bundle.putInt(Constant.MAIN_CUR_COIN, onlineIncome);
// bundle.putInt(Constant.MAIN_ALL_COIN, userConfig.getCoin());
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_ONLINE_INCOME_DOUBLE);
readyGo(AwardActivity.class, bundle);
} else {
Bundle bundle = new Bundle();
bundle.putInt(Constant.MAIN_CUR_COIN, (userConfig.getConfigDownloadTaskVedioCoin() + userConfig.getConfigDownloadTaskDownloadCoin()));
// bundle.putInt(Constant.MAIN_ALL_COIN, userConfig.getCoin());
bundle.putInt(Constant.MAIN_CUR_FLAG, Constant.MAIN_CUR_ONE);
bundle.putString(Constant.MAIN_CARRIET_TURN, Constant.CARRIER_DAILY_DOWNLOAD_DOWNLOAD);
readyGo(AwardActivity.class, bundle);
}
readyGo(AwardActivity.class, bundle);
}
}
......@@ -1238,9 +1149,6 @@ public class MainFragment extends BaseFragment
if (granted) {
getBaseApplication().initUm(getContext());
AmapLocationManager.getInstance().startLocation(mLocationHandler);
// if (!AppConfig.lyAdSdkInitState) {
// getBaseApplication().initGold(getBaseApplication().getApplicationContext());
// }
} else {
showMissingPermissionDialog("设备、储存");
}
......@@ -1376,429 +1284,6 @@ public class MainFragment extends BaseFragment
});
}
// /**
// * 穿山甲激励视频
// *
// * @param codeId
// * @param carrierType
// */
// private void loadCsjAd(String codeId, String carrierType) {
//// showLoading("加载中...");
//
// isClickTTDownload = false;
// isloadTTVedio = false;
// isClickRunDownload = false;
//
// CARRIER_TYPE = carrierType;
// AD_SOURCE = Constant.AD_SOURCE_CSJ;
//
// if (BuildConfig.DEBUG) {
// codeId = TTAdManagerHolder.TT_AD_VEDIO_MAIN_DEV;
// }
//
// String tid = MD5.GetMD5Code(String.valueOf(System.currentTimeMillis()) + userID);
//
// HashMap<String, Object> vo = new HashMap<>();
// vo.put("adsource", Constant.AD_SOURCE_CSJ);
// vo.put("carrierType", carrierType);
// vo.put("page", Constant.PAGE_ONE);
// if (TextUtils.equals(carrierType, Constant.CARRIER_DAILY_DOWNLOAD)) {
// // 点一点
// vo.put("block", Constant.BLOCK_THREE);
// vo.put("order", Constant.ORDER_ONE);
// } else if (TextUtils.equals(carrierType, Constant.CARRIER_DAILY_VIDEO)) {
// // 观看视频
// vo.put("block", Constant.BLOCK_THREE);
// vo.put("order", Constant.ORDER_TWO);
// } else if (TextUtils.equals(carrierType, Constant.CARRIER_ONLINE_INCOME_DOUBLE)) {
// // 在线
// vo.put("online_income", onlineIncome);
// } else if (TextUtils.equals(carrierType, Constant.CARRIER_HOMEWATER_BUBBLE)) {
// // 首页喝水汽泡
// vo.put("waterCoin", waterIncome);
// } else {
// // 离线收益
// if (userConfig != null) {
// vo.put("offline_income", userConfig.getOfflineIncome());
// }
// }
// vo.put("adtype", Constant.ADTYPE_VEDIO);
// vo.put("tid", tid);
// if (spUtil != null) {
// vo.put("ip", spUtil.getString(Constant.CSJ_VEDIO_APPIP));
// }
//
//
// //step4:创建广告请求参数AdSlot,具体参数含义参考文档
// AdSlot adSlot = new AdSlot.Builder()
// .setCodeId(codeId)
// .setSupportDeepLink(true)
// .setImageAcceptedSize(1080, 1920)
// .setUserID(userID)//用户id,必传参数
// .setMediaExtra(JsonUtil.toJson(vo)) //附加参数,可选
// .setOrientation(TTAdConstant.VERTICAL) //必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL
// .build();
// //step5:请求广告
// ttAdNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
// @Override
// public void onError(int code, String message) {
// hideLoading();
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, String.valueOf(code), message);
//
// showToast("视频加载异常,请重试");
// }
//
// //视频广告加载后,视频资源缓存到本地的回调,在此回调后,播放本地视频,流畅不阻塞。
// @Override
// public void onRewardVideoCached() {
//
// if (mttRewardVideoAd != null) {
// mttRewardVideoAd.showRewardVideoAd(getActivity());
// mttRewardVideoAd = null;
// } else {
// hideLoading();
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "Cached Fail");
//
// showToast("视频加载异常,请重试");
// }
// }
//
// //视频广告的素材加载完毕,比如视频url等,在此回调后,可以播放在线视频,网络不好可能出现加载缓冲,影响体验。
// @Override
// public void onRewardVideoAdLoad(TTRewardVideoAd ad) {
// mttRewardVideoAd = ad;
// mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() {
//
// @Override
// public void onAdShow() {//视频广告展示回调
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ZERO, "", "");
//
// AppConfig.csjVedioAdCount--;
// AppConfig.preAdType = Constant.CSJ_VEDIO_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
//
// isloadTTVedio = true;
//
// hideLoading();
// }
//
// @Override
// public void onAdVideoBarClick() {//广告的下载bar点击回调
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_TWO, "", "");
//
// isClickRunDownload = true;
//
// // 内容是H5连接 点击后也给金币
//// if (interactionType == 3) {
//// isClickTTDownload = true;
//// }
// // 内容是H5连接 点击后也给金币
// try {
// if (mttRewardVideoAd.getInteractionType() == 3) {
// isClickTTDownload = true;
// }
// } catch (Exception e) {
// e.printStackTrace();
// isClickTTDownload = true;
// }
// }
//
// @Override
// public void onAdClose() {//视频广告关闭回调
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_THREE, "", "");
//
// }
//
// //视频播放完成回调
// @Override
// public void onVideoComplete() {//视频广告播放完毕回调
// }
//
// @Override
// public void onVideoError() {//视频广告播完验证奖励有效性回调,参数分别为是否有效,奖励数量,奖励名称
// hideLoading();
// showToast("视频加载失败,请重试");
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJ, Constant.EVENT_TYPE_ONE, "999999", "VideoError");
//
// }
//
// //视频播放完成后,奖励验证回调,rewardVerify:是否有效,rewardAmount:奖励梳理,rewardName:奖励名称
// @Override
// public void onRewardVerify(boolean rewardVerify, int rewardAmount, String rewardName) {
// if (rewardVerify) {
// isloadTTVedio = true;
// } else {
// loanPresenter.checkCoinRecordByTid(tid, carrierType);
// }
// }
//
// @Override
// public void onSkippedVideo() {
// }
// });
// mttRewardVideoAd.setDownloadListener(new TTAppDownloadListener() {
// @Override
// public void onIdle() {
// }
//
// @Override
// public void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName) {
// }
//
// @Override
// public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) {
// }
//
// @Override
// public void onDownloadFailed(long totalBytes, long currBytes, String fileName, String appName) {
// }
//
// @Override
// public void onDownloadFinished(long totalBytes, String fileName, String appName) {
// }
//
// @Override
// public void onInstalled(String fileName, String appName) {
// if (isClickRunDownload) {
// isClickTTDownload = true;
// }
// }
// });
// }
// });
// }
// /**
// * 加载优量汇激励视频
// */
// private void loanYlhAd(String carrierType) {
//// showLoading("加载中...");
//
// isClickTTDownload = false;
// isloadTTVedio = false;
// isClickRunDownload = false;
//
// CARRIER_TYPE = carrierType;
// AD_SOURCE = Constant.AD_SOURCE_YLH;
//
// String ylhPostId;
// switch (carrierType) {
// case Constant.CARRIER_ONLINE_INCOME_DOUBLE:// 在线收益翻倍
// case Constant.CARRIER_OFFLINE_DOUBLE:// 离线收益翻倍
// case Constant.CARRIER_SIGNIN_HOMEPAGE_CARD:// 签到翻倍
// case Constant.CARRIER_DRINK:// 喝水正常
// case Constant.CARRIER_DRINK_PATCH:// 喝水补卡
// case Constant.CARRIER_VERSUS_DRINKTEA://喝饮料
// case Constant.CARRIER_DAILY_TURN:// 首页大转盘
// ylhPostId = YlhAdManager.YLH_AD_VEDIO_MAIN_PAN_POSTID;
// break;
// case Constant.CARRIER_CHALLENGE_TURN:// 挑战大转盘
// ylhPostId = YlhAdManager.YLH_AD_VEDIO_VERSUS_PAN_POSTID;
// break;
// case Constant.CARRIER_CHALLENGE_CARD:// 挑战刮刮乐
// ylhPostId = YlhAdManager.YLH_AD_VEDIO_VERSUS_ERASE_POSTID;
// break;
// default:// 在线收益翻倍
// ylhPostId = YlhAdManager.YLH_AD_VEDIO_MAIN_PAN_POSTID;
// break;
// }
//
// rewardVideoAD = new RewardVideoAD(getActivity(), YlhAdManager.YLH_AD_VEDIO_APPID, ylhPostId, new RewardVideoADListener() {
// @Override
// public void onADLoad() {//广告加载成功,可在此回调后进行广告展示,此时广告过期时间确定,可通过RewardVideoAD.getExpireTimestamp()获取
// hideLoading();
//
// try {
// if (!rewardVideoAD.hasShown()) {//广告展示检查2:当前广告数据还没有展示过
// long delta = 1000;//建议给广告过期时间加个buffer,单位ms,这里demo采用1000ms的buffer
// //广告展示检查3:展示广告前判断广告数据未过期
// if (SystemClock.elapsedRealtime() < (rewardVideoAD.getExpireTimestamp() - delta)) {
// AppConfig.ylhAdCount--;
// AppConfig.preAdType = Constant.YLH_VEDIO_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
//
//
// rewardVideoAD.showAD();
// } else {
// showToast("广告已过期,请再次请求广告后进行广告展示!");
// }
// } else {
// showToast("此条广告已经展示过,请再次请求广告后进行广告展示!");
// }
// } catch (Exception e) {
// e.printStackTrace();
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ONE, "999999", "Load Fail");
//
// System.out.println("mcg __ ylh error");
// }
// }
//
// @Override
// public void onVideoCached() {//视频素材缓存成功,可在此回调后进行广告展示
//
// }
//
// @Override
// public void onADShow() {//激励视频广告页面展示,此后RewardVideoAD.hasShown()返回true
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ZERO, "", "");
//
// }
//
// @Override
// public void onADExpose() {//激励视频广告曝光
//
// }
//
// @Override
// public void onReward() {//激励视频广告激励发放
// isloadTTVedio = true;
//
// HashMap<String, Object> vo = new HashMap<>();
// vo.put("carrierType", carrierType);
// vo.put("adtype", Constant.ADTYPE_VEDIO);
// vo.put("adsource", Constant.AD_SOURCE_YLH);
// if (TextUtils.equals(carrierType, Constant.CARRIER_HOMEWATER_BUBBLE)) {
// vo.put("page", Constant.PAGE_ONE);
// vo.put("waterCoin", waterIncome);
// }
//
// loanPresenter.reportAddCoinMsg(vo, "");
// }
//
// @Override
// public void onADClick() {//激励视频广告被点击
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_TWO, "", "");
//
// isClickTTDownload = true;
// }
//
// @Override
// public void onVideoComplete() {//广告视频素材播放完毕
//
// }
//
// @Override
// public void onADClose() {//激励视频广告被关闭
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_THREE, "", "");
//
// }
//
// @Override
// public void onError(AdError adError) {//广告流程出错,AdError中包含错误码和错误描述
// hideLoading();
//
// if (adError != null) {
// // 0 成功 1失败 2点击 3-有效展示
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_YLH, Constant.EVENT_TYPE_ONE, String.valueOf(adError.getErrorCode()), adError.getErrorMsg());
// }
// showToast("视频加载异常,请重试.");
//
//// System.out.println("mcg __ ylh error" + JsonUtil.toJson(adError));
// }
// });
//
// rewardVideoAD.loadAD();
// }
// /**
// * 全屏广告
// *
// * @param carrierType
// */
// @SuppressWarnings("SameParameterValue")
// private void loadCsjFullAd(String carrierType) {
//// showLoading("加载中...");
//
// CARRIER_TYPE = carrierType;
// AD_SOURCE = Constant.AD_SOURCE_CSJ;
//
// String codeId = TTAdManagerHolder.TT_AD_ALLVEDIO_ID_EXCEPTION;
//
// AdSlot adSlot = new AdSlot.Builder()
// .setCodeId(codeId)
// .setSupportDeepLink(true)
// .setImageAcceptedSize(1080, 1920)
// .setOrientation(TTAdConstant.VERTICAL)
// .build();
// ttAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
// @Override
// public void onError(int code, String message) {
// hideLoading();
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_ONE, String.valueOf(code), message);
//
// showToast("视频加载异常,请重试!");
// }
//
// @Override
// public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ad) {
// mttFullVideoAd = ad;
// mttFullVideoAd.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
//
// @Override
// public void onAdShow() {
// hideLoading();
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_ZERO, "", "");
//
// AppConfig.csjFullAdCount--;
// AppConfig.preAdType = Constant.CSJ_FULL_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
// }
//
// @Override
// public void onAdVideoBarClick() {
// isClickTTDownload = true;
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_TWO, "", "");
//
// }
//
// @Override
// public void onAdClose() {
// isloadTTVedio = true;
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_THREE, "", "");
//
// HashMap<String, Object> vo = new HashMap<>();
// vo.put("carrierType", carrierType);
// vo.put("adtype", Constant.ADTYPE_VEDIO);
// vo.put("adsource", Constant.AD_SOURCE_CSJ);
// // 全屏广告传入
// vo.put("detailAdtype", Constant.ADTYPE_FULLSCREEN_VIDEO);
// if (TextUtils.equals(carrierType, Constant.CARRIER_HOMEWATER_BUBBLE)) {
// vo.put("page", Constant.PAGE_ONE);
// vo.put("waterCoin", waterIncome);
// }
//
// loanPresenter.reportAddCoinMsg(vo, "");
// }
//
// @Override
// public void onVideoComplete() {
// }
//
// @Override
// public void onSkippedVideo() {
//
// }
//
// });
// }
//
// @Override
// public void onFullScreenVideoCached() {
// if (mttFullVideoAd != null) {
// //step6:在获取到广告后展示
// mttFullVideoAd.showFullScreenVideoAd(getActivity());
// mttFullVideoAd = null;
// } else {
// hideLoading();
// TrackManager.getInstance().addCallImp(Constant.AD_SOURCE_CSJFULL, Constant.EVENT_TYPE_ONE, "999999", "Cached Fail");
//
// showToast("视频加载异常,请重试!");
// }
// }
// });
// }
/**
* 获取随机广告
*
......@@ -1862,53 +1347,6 @@ public class MainFragment extends BaseFragment
}
});
// int csjVedioAdCount = AppConfig.csjVedioAdCount;
// int ylhAdCount = AppConfig.ylhAdCount;
// int csjFullAdCount = AppConfig.csjFullAdCount;
// int hytechVedioAdCount = AppConfig.hytechVedioAdCount;
//
// if (csjVedioAdCount > 0) {
// switch (carrierType) {
// case Constant.CARRIER_HOMEWATER_BUBBLE:// 喝水汽泡
// loadCsjAd(TTAdManagerHolder.TT_AD_VEDIO_DRINK, Constant.CARRIER_HOMEWATER_BUBBLE);
// break;
// case Constant.CARRIER_DAILY_DOWNLOAD:// 每日任务-视频
// loadCsjAd(TTAdManagerHolder.TT_AD_VEDIO_MAIN_DOWNLOAD, Constant.CARRIER_DAILY_DOWNLOAD);
// break;
// case Constant.CARRIER_DAILY_VIDEO:// 观看视频-视频
// loadCsjAd(TTAdManagerHolder.TT_AD_VEDIO_MAIN_LOOK, Constant.CARRIER_DAILY_VIDEO);
// break;
//
// }
// } else if (csjFullAdCount > 0) {
// loadCsjFullAd(carrierType);
// } else if (hytechVedioAdCount > 0) {
// HytechVedioAdManager hytechVedioAdManager = HytechVedioAdManager.getInstance(getActivity());
// hytechVedioAdManager.setHytechVedioAdListener(new HytechVedioAdManager.HytechVedioAdListener() {
// @Override
// public void hytechVedioAdFail() {
// hideLoading();
// showToast("视频加载异常,请重试!");
// }
//
// @Override
// public void hytechVedioAdSuccess() {
// hideLoading();
//
// AppConfig.hytechVedioAdCount--;
// AppConfig.preAdType = Constant.HYTECH_VEDIO_AD;
// AppConfig.preAdTime = Calendar.getInstance().getTimeInMillis();
// }
// });
// hytechVedioAdManager.loanHytechAd(downloadCoin, coin, carrierType, extraId);
// } else if (ylhAdCount > 0) {
// loanYlhAd(carrierType);
// } else {
//
// hideLoading();
// showToast("今日视频已看完,请明天再来吧");
// }
}
@Override
......@@ -1931,7 +1369,6 @@ public class MainFragment extends BaseFragment
*/
private void vedioAdingSuccess(String adType, String carrierType) {
if (TextUtils.equals(adType, Constant.YLH_VEDIO_AD) || TextUtils.equals(adType, Constant.CSJ_VEDIO_AD) || TextUtils.equals(adType, Constant.CSJ_FULL_AD)) {
if (TextUtils.equals(adType, Constant.YLH_VEDIO_AD)) {
AD_SOURCE = Constant.AD_SOURCE_YLH;
} else {
......@@ -1952,15 +1389,4 @@ public class MainFragment extends BaseFragment
}
}
}
/**
* 停止计时器
*/
private void onTimerDestory() {
if (redBoxTimer != null) {
redBoxTimer.stop();
redBoxTimer = null;
}
}
}
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