新增首页弹窗更多条件控制

This commit is contained in:
zlzw 2023-12-07 13:04:41 +08:00
parent 2857bb09a2
commit 8c5ae3b61a
2 changed files with 60 additions and 2 deletions

View File

@ -17,14 +17,17 @@ public class OpenAdModel extends BaseModel {
public static final int MODEL_SQUARE = 1;//正方形 public static final int MODEL_SQUARE = 1;//正方形
public static final int MODEL_RECTANGLE = 2;//长方形 public static final int MODEL_RECTANGLE = 2;//长方形
public static final int MODEL_BOTTOM = 3;//底部 public static final int MODEL_BOTTOM = 3;//底部
public static final int SHOW_DEF = 1;//1. 杀死程序后弹出
public static final int SHOW_DIY = 2;//2. 自定义时间自上次弹出弹窗后00:00小时范围00:01小时-48:00小时后再弹出到时间后也需满足触发条件再弹出
public static final int SHOW_ONE = 3;//3. 仅弹出一次
@SerializedName("id") @SerializedName("id")
private int id; private int id;
@SerializedName("popup_location") @SerializedName("popup_location")
private int type = TYPE_HOME; private int type = TYPE_HOME;
@SerializedName("activity_url") @SerializedName("activity_url")
private String url; private String url;//点击跳转url
@SerializedName("image_url") @SerializedName("image_url")
private String imageUrl; private String imageUrl;//图片url
@SerializedName("display_time") @SerializedName("display_time")
private int showTime; //持续展示时间 private int showTime; //持续展示时间
@SerializedName("delay_show_time") @SerializedName("delay_show_time")
@ -37,11 +40,48 @@ public class OpenAdModel extends BaseModel {
private String endTime;//活动结束时间 private String endTime;//活动结束时间
@SerializedName("popup_permission") @SerializedName("popup_permission")
private int permission; private int permission;
@SerializedName("popup_frequency")
private int showModel = SHOW_DEF;//显示模式1杀死程序后弹出 2指定时间内本机时间 31. 仅弹出一次
@SerializedName("popup_frequency_time")
private String section = "0";// SHOW_DEF = 2
public OpenAdModel() { public OpenAdModel() {
} }
public static OpenAdModel createTestData() {
OpenAdModel model = new OpenAdModel();
model.id=3;
model.type=1;
model.url = "/h5/GuildTournament/20230821/rank.html";
model.imageUrl = "https://ceshi.yaoulive.com/data/upload/20230913/1694589490.png";
model.showTime = 10;
model.delayShowTime = 0;
model.model = MODEL_SQUARE;
model.startTime = "2019-01-01 00:00:00";
model.endTime = "2029-01-01 00:00:00";
model.permission = 4;
model.showModel = SHOW_DIY;
model.section = "5";
return model;
}
public int getShowModel() {
return showModel;
}
public void setShowModel(int showModel) {
this.showModel = showModel;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public int getType() { public int getType() {
return type; return type;
} }

View File

@ -11,6 +11,8 @@ import com.yunbao.common.dialog.OpenAdBottomDialogPopup;
import com.yunbao.common.dialog.OpenAdCenterDialogPopup; import com.yunbao.common.dialog.OpenAdCenterDialogPopup;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import java.util.ArrayList; import java.util.ArrayList;
@ -93,6 +95,18 @@ public class OpenAdManager {
if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) { if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
continue; continue;
} }
if (model.getShowModel() == OpenAdModel.SHOW_ONE) {
if (SpUtil.getInstance().getBooleanValue("open_ad_popup_" + model.getId())) {
continue;
}
SpUtil.getInstance().setBooleanValue("open_ad_popup_" + model.getId(), true);
}
if (model.getShowModel() == OpenAdModel.SHOW_DIY) {
String value = SpUtil.getStringValue("open_ad_popup_time_" + model.getId());
if (!StringUtil.isEmpty(value) && System.currentTimeMillis() < Long.parseLong(value)) {
continue;
}
}
if (runnableMap.containsKey(model.getId())) { if (runnableMap.containsKey(model.getId())) {
AdRunnable runnable = runnableMap.get(model.getId()); AdRunnable runnable = runnableMap.get(model.getId());
if (runnable != null) { if (runnable != null) {
@ -166,6 +180,10 @@ public class OpenAdManager {
return; return;
} }
showMap.put(model.getId(), true); showMap.put(model.getId(), true);
if (model.getShowModel() == OpenAdModel.SHOW_DIY) {
String nextTime= String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000));
SpUtil.setStringValue("open_ad_popup_time_" + model.getId(), nextTime);
}
if (model.getModel() == OpenAdModel.MODEL_BOTTOM) { if (model.getModel() == OpenAdModel.MODEL_BOTTOM) {
new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> { new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> {
}).showDialog(); }).showDialog();