新增【弹框功能优化】
This commit is contained in:
parent
d383a08013
commit
54258c3f13
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user