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); } /**