新增【弹框功能优化】

This commit is contained in:
2023-09-15 14:54:45 +08:00
parent d383a08013
commit 54258c3f13
6 changed files with 39 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.StringUtil;
import java.text.ParseException;
@@ -34,6 +35,8 @@ public class OpenAdModel extends BaseModel {
private String startTime;//活动开始时间
@SerializedName("end_show_time")
private String endTime;//活动结束时间
@SerializedName("popup_permission")
private int permission;
public OpenAdModel() {
@@ -48,10 +51,10 @@ public class OpenAdModel extends BaseModel {
}
public String getUrl() {
if (url.startsWith("http://") || url.startsWith("https://")) {
return CommonAppConfig.HOST + "/" + url;
if (!url.startsWith("http://") || !url.startsWith("https://")) {
url = CommonAppConfig.HOST + url;
}
return url;
return url + "?t=" + System.currentTimeMillis() / 1000;
}
public void setUrl(String url) {
@@ -114,6 +117,14 @@ public class OpenAdModel extends BaseModel {
this.id = id;
}
public int getPermission() {
return permission;
}
public void setPermission(int permission) {
this.permission = permission;
}
public boolean isInTime() {
if (StringUtil.isEmpty(startTime, endTime)) {
return true;
@@ -133,6 +144,13 @@ public class OpenAdModel extends BaseModel {
return startTime.getTime() <= time && time <= endTime.getTime();
}
public boolean userIsPermission(boolean isGuard) {
if (permission == 4 && !isGuard) {//守护不可见
return false;
}
return true;
}
@Override
public String toString() {
return "OpenAdModel{" +
@@ -145,6 +163,7 @@ public class OpenAdModel extends BaseModel {
", model=" + model +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
", permission='" + permission + '\'' +
'}';
}
}

View File

@@ -34,9 +34,7 @@ public class OpenAdManager {
}
public void reset() {
for (Integer integer : runnableMap.keySet()) {
handler.removeCallbacks(Objects.requireNonNull(runnableMap.get(integer)));
}
dismiss();
runnableMap.clear();
showMap.clear();
list.clear();
@@ -57,7 +55,7 @@ public class OpenAdManager {
public void onSuccess(List<OpenAdModel> data) {
list = data;
if (isShow) {
show(TYPE_HOME);
show(TYPE_HOME,false);
}
}
@@ -69,7 +67,7 @@ public class OpenAdManager {
}
public synchronized void show(int type) {
public synchronized void show(int type,boolean isGuard) {
if (list.isEmpty()) {
init(true);
return;
@@ -77,6 +75,9 @@ public class OpenAdManager {
showType=type;
for (OpenAdModel model : list) {
if (model.getType() == type) {
if(type==OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)){
continue;
}
if (runnableMap.containsKey(model.getId())) {
AdRunnable runnable = runnableMap.get(model.getId());
if (runnable != null) {
@@ -85,6 +86,7 @@ public class OpenAdManager {
runnableMap.remove(model.getId());
}
}
if (!isShow(model)) {
Log.i(TAG, "show: "+model);
handler.postDelayed(new AdRunnable(model), model.getDelayShowTime());