Commit 8a167b03 authored by mengcuiguang's avatar mengcuiguang

1.0.5版本发布,优化权重配置

parent f2fcf593
......@@ -6,6 +6,7 @@ import android.text.TextUtils;
import com.mints.highgold.common.AppConfig;
import com.mints.highgold.common.Constant;
import com.mints.highgold.mvp.model.VedioAdingBean;
import com.mints.highgold.mvp.model.WeightBean;
import com.mints.highgold.utils.ToastUtil;
import java.util.ArrayList;
......@@ -34,7 +35,7 @@ public class VedioAdingManager {
private int csjVedioWeight;
private int hytechVedioWeight;
private int mintegralWeight;
private ArrayList<Integer> weightList;
private ArrayList<WeightBean> weightList;
private Activity activity;
private boolean isVedioAdDownload = false;// 是否点击广告下载 true-点击
......@@ -47,6 +48,7 @@ public class VedioAdingManager {
return _inst;
}
}
private VedioAdingManager(Activity activity) {
init(activity);
return;
......@@ -122,92 +124,64 @@ public class VedioAdingManager {
*/
private String getVedioAdType() {
// 根据权重获取广告类型
String adType = getRandomWeightAdtype();
String adType = getRandomWeight();
System.out.println("mcg __ 权重结果返回的广告类型:" + adType);
return adType;
}
/**
* 根据权重 获取广告类型
*/
private String getRandomWeightAdtype() {
String adType = "";
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;
private String getRandomWeight() {
if (weightList != null) {
weightList.clear();
}
// 若没有视频完成数,不加入权重计算范围内
if (AppConfig.csjVedioAdCount > 0) {
weightList.add(csjVedioWeight);
weight = weight + csjVedioWeight;
weightList.add(new WeightBean(csjVedioWeight, Constant.CSJ_VEDIO_AD));
System.out.print("mcg __ 权重值:csjVedioWeight:" + csjVedioWeight);
}
if (AppConfig.csjFullAdCount > 0) {
weightList.add(csjFullWeight);
weight = weight + csjFullWeight;
weightList.add(new WeightBean(csjFullWeight, Constant.CSJ_FULL_AD));
System.out.print(" mcg __ 权重值:csjFullWeight:" + csjFullWeight);
}
if (AppConfig.hytechVedioAdCount > 0) {
weightList.add(hytechVedioWeight);
weight = weight + hytechVedioWeight;
weightList.add(new WeightBean(hytechVedioWeight, Constant.HYTECH_VEDIO_AD));
System.out.print(" mcg __ 权重值:hytechVedioWeight:" + hytechVedioWeight);
}
if (AppConfig.ylhAdCount > 0) {
weightList.add(ylhWeight);
weight = weight + ylhWeight;
weightList.add(new WeightBean(ylhWeight, Constant.YLH_VEDIO_AD));
System.out.println(" mcg __ 权重值:ylhWeight:" + ylhWeight);
}
if (AppConfig.mintegralAdCount > 0) {
weightList.add(mintegralWeight);
weight = weight + mintegralWeight;
weightList.add(new WeightBean(mintegralWeight, Constant.MINTEGRAL_VEDIO_AD));
System.out.println(" mcg __ 权重值:mintegralWeight:" + mintegralWeight);
}
// 权重随机
System.out.print("mcg __ 1、权重总值:" + weight);
if (weightList != null && weightList.size() > 0) {
int weight = 0;
for (WeightBean weightBean : weightList) {
weight += weightBean.getWeight();
}
System.out.print("mcg __ 1、权重总值:" + weight);
Random r = new Random();
int randomWeight = r.nextInt(weight) + 1;
System.out.print(" 2、权重随机值:" + randomWeight);
for (Integer w : weightList) {
randomWeight -= w;
for (WeightBean weightBean : weightList) {
randomWeight -= weightBean.getWeight();
if (randomWeight <= 0) {
System.out.println(" 3、权重结果:" + w);
return w;
System.out.println(" 3、权重结果:" + weightBean.getType());
return weightBean.getType();
}
}
return weightList.get(0);
}
return -1;
return "";
}
/**
......@@ -239,7 +213,6 @@ public class VedioAdingManager {
return false;
}
/**
* 释放资源
*/
......@@ -275,9 +248,7 @@ public class VedioAdingManager {
*/
public interface VedioAdingListener {
void vedioAdingListenerError(String adType);
void vedioAdingListenerFail(String adType);
void vedioAdingListenerSuccess(String adType);
}
......@@ -492,6 +463,4 @@ public class VedioAdingManager {
}
}
}
}
......@@ -63,8 +63,6 @@ public interface Constant {
/**
* 试玩用户报文
*/
String TRY_COIN = "try_coin";
String TRY_COIN_RATE = "try_coin_rate";
String TRY_CARRIER = "try_carrier";
String TRY_TASK_COIN = "try_task_coin";
String TRY_VEDIO_COIN = "try_vedio_coin";
......@@ -75,14 +73,7 @@ public interface Constant {
// 提交appserver成功,将sdk的任务删除
String TRY_TASK_FLAG = "try_task_flag";
// 提交appserver成功,将sdk的任务删除
String TRY_VEDIOTASK_FLAG = "try_vediotask_flag";
// 提交appserver成功,将sdk的任务删除
String TRY_VEDIO_FLAG = "try_vedio_flag";
// 提现标识 true:可以提现 flase:引导用户做任务
String LOAN_DRAWCASH_FLAG = "loan_drawcash_flag";
String MY_DRAWCASH_FLAG = "my_drawcash_flag";
// 立言个数
String LOAN_LY_COUNT = "loan_ly_count";
// 首次弹出权限声明
String LOAN_PERMISSION_FLAG = "loan_permission_flag";
......@@ -99,11 +90,6 @@ public interface Constant {
/**
* 用户大厅
*/
String USER_LOAN_RATE = "user_loan_rate";
String USER_LOAN_COIN = "user_loan_coin";
String USER_LOAN_CASH = "user_loan_cash";
String ALIPAY_ACCOUNT = "alipay_account";
String NAME_ACCOUNT = "name_account";
String PAN_LOADAD_TYPE = "pan_loadad_type";
String ERASE_LOADAD_TYPE = "erase_loadad_type";
......@@ -126,18 +112,6 @@ public interface Constant {
int MAIN_CUR_TWO = 2;
String LY_APP_DOWNLOAD = "LY_APP_DOWNLOAD";//, "app下载任务增加积分"),
String LY_H5_VIDEO = "VEDIO";// "h5视频广告增加积分"),
String LY_H5_DOWNLOAD = "DOWNLOAD";// "h5视频下载任务增加积分"),
String LY_VIEW = "VIEW";//展示
String LY_CLICK = "CLICK";//点击
String LY_VIDEO_PLAY = "VIDEO_PLAY";//视频广告播放
String LY_APP_DOWNLOAD_START = "APP_DOWNLOAD_START";//app广告下载开始
String LY_APP_DOWNLOAD_SUCC = "APP_DOWNLOAD_SUCC";//app广告下载成功
String LY_APP_DOWNLOAD_INSTAL = "APP_DOWNLOAD_INSTAL";//app广告安装
String LY_APP_DOWNLOAD_ACTIVE = "APP_DOWNLOAD_ACTIVE";//app广告激活
// 喝水打卡
String NORMAL_WATER_COIN = "normal_water_coin";
String PATCH_WATER_COIN = "patch_water_coin";
......@@ -151,10 +125,6 @@ public interface Constant {
String HYTECH_VEDIO_AD = "HYTECH_VEDIO_AD";
String MINTEGRAL_VEDIO_AD = "MINTEGRAL_VEDIO_AD";
// 插屏广告类型
String CSJ_INTERACTION_AD = "CSJ_INTERACTION_AD";
String YLH_INTERACTION_AD = "YLH_INTERACTION_AD";
// 载体
String CARRIER_DRINK = "DRINK";//喝水
String CARRIER_DRINK_PATCH = "DRINK_PATCH";//喝水补卡
......
package com.mints.highgold.mvp.model;
import java.io.Serializable;
public class WeightBean implements Serializable {
private int weight;
private String type;
public WeightBean(int weight, String type) {
this.weight = weight;
this.type = type;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
......@@ -296,7 +296,6 @@ public class AwardActivity extends BaseActivity implements AwardView {
int csjVedioAdCount = AppConfig.csjVedioAdCount;
int ylhAdCount = AppConfig.ylhAdCount;
int csjFullAdCount = AppConfig.csjFullAdCount;
int hytechVedioAdCount = AppConfig.hytechVedioAdCount;
// 随机广告 - 红包,汽泡
if (TextUtils.equals(CARRIER_TYPE, Constant.CARRIER_REDENVELOPE_DOUBLE) ||
TextUtils.equals(CARRIER_TYPE, Constant.CARRIER_REDENVELOPE) ||
......@@ -317,7 +316,6 @@ public class AwardActivity extends BaseActivity implements AwardView {
if (userConfig != null) {
bean.setDownloadCoin(userConfig.getConfigDownloadTaskDownloadCoin());
} else {
bean.setDownloadCoin(0);
}
vedioAdingManager.loadAding(bean);
......@@ -325,15 +323,10 @@ public class AwardActivity extends BaseActivity implements AwardView {
@Override
public void vedioAdingListenerError(String adType) {
hideLoading();
// showToast("视频异常,请重试");
}
@Override
public void vedioAdingListenerFail(String adType) {
// showToast("人工添加,第一次加载失败");
// hideLoading();
vedioAdingManager.loadFailAding(bean);
vedioAdingManager.setVedioAdingListener(new VedioAdingManager.VedioAdingListener() {
@Override
......@@ -358,49 +351,14 @@ public class AwardActivity extends BaseActivity implements AwardView {
}
});
// 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("今日视频已看完,请明天再来吧");
// }
}
@Override
public void vedioAdingListenerSuccess(String adType) {
hideLoading();
// showToast("成功了");
vedioAdingSuccess(adType);
}
});
return;
}
......
......@@ -465,30 +465,30 @@ public class MainFragment extends BaseFragment
//测试数据
// data.setVedioplan_csj_vedio_rate(0);
// data.setVedioplan_lyh_vedio_rate(0);
// data.setVedioplan_csj_full_screen_video_rate(0);
// data.setVedioplan_hytech_vedio_rate(0);
// data.setVedioplan_mintegral_vedio_rate(0);
// data.setVedioplan_csj_vedio_rate(5);
// data.setVedioplan_lyh_vedio_rate(5);
// data.setVedioplan_csj_full_screen_video_rate(5);
// data.setVedioplan_hytech_vedio_rate(5);
// data.setVedioplan_mintegral_vedio_rate(5);
//
// data.setVedioplan_csj_vedio_surplus(0);
// data.setVedioplan_lyh_vedio_surplus(0);
// data.setVedioplan_csj_full_screen_video_surplus(0);
// data.setVedioplan_hytech_vedio_surplus(0);
// data.setVedioplan_mintegral_vedio_surplus(0);
// data.setVedioplan_csj_vedio_surplus(2);
// data.setVedioplan_lyh_vedio_surplus(2);
// data.setVedioplan_csj_full_screen_video_surplus(3);
// data.setVedioplan_hytech_vedio_surplus(2);
// data.setVedioplan_mintegral_vedio_surplus(2);
// 设置随机广告权重
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(), data.getVedioplan_mintegral_vedio_rate());
}
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()+ " mintegralVedioAdWeight:" + data.getVedioplan_mintegral_vedio_rate());
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() + " mintegralVedioAdWeight:" + data.getVedioplan_mintegral_vedio_rate());
// 广告完成数
AppConfig.csjVedioAdCount = data.getVedioplan_csj_vedio_surplus();
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 = data.getVedioplan_mintegral_vedio_surplus();
System.out.println("mcg __ 首页广告完成数:csjVedioAdCount:" + data.getVedioplan_csj_vedio_surplus() + " ylhAdCount:" + data.getVedioplan_lyh_vedio_surplus() + " csjFullAdCount:" + data.getVedioplan_csj_full_screen_video_surplus() + " hytechVedioAdCount:" + data.getVedioplan_hytech_vedio_surplus()+ " mintegralVedioAdCount:" + data.getVedioplan_mintegral_vedio_surplus());
System.out.println("mcg __ 首页广告完成数:csjVedioAdCount:" + data.getVedioplan_csj_vedio_surplus() + " ylhAdCount:" + data.getVedioplan_lyh_vedio_surplus() + " csjFullAdCount:" + data.getVedioplan_csj_full_screen_video_surplus() + " hytechVedioAdCount:" + data.getVedioplan_hytech_vedio_surplus() + " mintegralVedioAdCount:" + data.getVedioplan_mintegral_vedio_surplus());
AppConfig.yilanVedioTime = data.getRedPacketSecond();
......@@ -1370,9 +1370,15 @@ public class MainFragment extends BaseFragment
* @param carrierType
*/
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) ||
TextUtils.equals(adType, Constant.CSJ_VEDIO_AD) ||
TextUtils.equals(adType, Constant.CSJ_FULL_AD) ||
TextUtils.equals(adType, Constant.MINTEGRAL_VEDIO_AD)) {
if (TextUtils.equals(adType, Constant.YLH_VEDIO_AD)) {
AD_SOURCE = Constant.AD_SOURCE_YLH;
} else if (TextUtils.equals(adType, Constant.MINTEGRAL_VEDIO_AD)) {
AD_SOURCE = Constant.AD_SOURCE_MINTEGRAL;
} else {
AD_SOURCE = Constant.AD_SOURCE_CSJ;
}
......
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