新增【弹框功能优化】

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

View File

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

View File

@ -96,6 +96,7 @@ import com.yunbao.live.R;
import com.yunbao.live.adapter.VerticalPagerAdapter; import com.yunbao.live.adapter.VerticalPagerAdapter;
import com.yunbao.live.bean.ImUserBean; import com.yunbao.live.bean.ImUserBean;
import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.dialog.LiveFansFragment; import com.yunbao.live.dialog.LiveFansFragment;
import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveGameDialogFragment;
import com.yunbao.live.dialog.LiveGiftPopup; import com.yunbao.live.dialog.LiveGiftPopup;
@ -778,7 +779,8 @@ public class LiveAudienceActivity extends LiveActivity {
} }
} }
GiftCacheUtil.getInstance().restart(); GiftCacheUtil.getInstance().restart();
new Handler(Looper.getMainLooper()).postDelayed(() -> OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE), 400); new Handler(Looper.getMainLooper()).postDelayed(() -> OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE,
LiveGuardInfo.isGuard(mLiveGuardInfo)), 400);
} }
@Override @Override

View File

@ -3,6 +3,8 @@ package com.yunbao.live.bean;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import com.yunbao.common.Constants;
/** /**
* Created by cxf on 2018/11/14. * Created by cxf on 2018/11/14.
*/ */
@ -72,5 +74,8 @@ public class LiveGuardInfo implements Parcelable {
} }
}; };
public static boolean isGuard(LiveGuardInfo info){
return info != null && info.getMyGuardType() != Constants.GUARD_TYPE_NONE;
}
} }

View File

@ -263,7 +263,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void run() { public void run() {
loading.setVisibility(View.GONE); loading.setVisibility(View.GONE);
enterRoomLeaveHandler.post(enterRoomLeaveRunnable); enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE); OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE,LiveGuardInfo.isGuard(mLiveGuardInfo));
} }
}; };
final Runnable loadTimeoutRunnableGone = new Runnable() { final Runnable loadTimeoutRunnableGone = new Runnable() {

View File

@ -876,7 +876,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
NoviceInstructorManager.get(mContext).getNoviceInstructor(); NoviceInstructorManager.get(mContext).getNoviceInstructor();
NoviceInstructorManager.get(mContext).checktHomeZdyPop(); NoviceInstructorManager.get(mContext).checktHomeZdyPop();
initAnchorRecommendBanner(); initAnchorRecommendBanner();
OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME); OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
} }
/** /**