From 54258c3f13a5e2701af4621c01235ef09824b9af Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 15 Sep 2023 14:54:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=90=E5=BC=B9=E6=A1=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/OpenAdModel.java | 25 ++++++++++++++++--- .../yunbao/common/manager/OpenAdManager.java | 12 +++++---- .../live/activity/LiveAudienceActivity.java | 4 ++- .../com/yunbao/live/bean/LiveGuardInfo.java | 5 ++++ .../live/views/PortraitLiveManager.java | 2 +- .../yunbao/main/activity/MainActivity.java | 2 +- 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java index d284d5c8b..0189513be 100644 --- a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java +++ b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java @@ -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 + '\'' + '}'; } } diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java index 29d416018..060c72714 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -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 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()); diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 6584ac982..432ff0e9b 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -96,6 +96,7 @@ import com.yunbao.live.R; import com.yunbao.live.adapter.VerticalPagerAdapter; import com.yunbao.live.bean.ImUserBean; import com.yunbao.live.bean.LiveChatBean; +import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.dialog.LiveFansFragment; import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveGiftPopup; @@ -778,7 +779,8 @@ public class LiveAudienceActivity extends LiveActivity { } } 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 diff --git a/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java b/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java index 0e07e4734..1015a6de7 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java @@ -3,6 +3,8 @@ package com.yunbao.live.bean; import android.os.Parcel; import android.os.Parcelable; +import com.yunbao.common.Constants; + /** * 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; + } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 2d6b485f2..919693d9f 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -263,7 +263,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe public void run() { loading.setVisibility(View.GONE); enterRoomLeaveHandler.post(enterRoomLeaveRunnable); - OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE); + OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE,LiveGuardInfo.isGuard(mLiveGuardInfo)); } }; final Runnable loadTimeoutRunnableGone = new Runnable() { diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 7e31a51b7..1693facbf 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -876,7 +876,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene NoviceInstructorManager.get(mContext).getNoviceInstructor(); NoviceInstructorManager.get(mContext).checktHomeZdyPop(); initAnchorRecommendBanner(); - OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME); + OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false); } /**