调整弹窗展示逻辑
This commit is contained in:
parent
022806d9da
commit
ab24348f72
@ -2,9 +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 com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -48,7 +46,9 @@ public class OpenAdModel extends BaseModel {
|
||||
@SerializedName("popup_frequency_time")
|
||||
private String section = "0";// SHOW_DEF = 2 1
|
||||
@SerializedName("popup_sort")
|
||||
private int sort = 1;//弹框类型 1.图片 2.H5
|
||||
private int popupSort = 1;//弹框类型 1.图片 2.H5
|
||||
@SerializedName("sort")
|
||||
private int sort = 0;
|
||||
|
||||
public OpenAdModel() {
|
||||
}
|
||||
@ -70,6 +70,10 @@ public class OpenAdModel extends BaseModel {
|
||||
return model;
|
||||
}
|
||||
|
||||
public int getPopupSort() {
|
||||
return popupSort;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
@ -78,6 +82,10 @@ public class OpenAdModel extends BaseModel {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public void setPopupSort(int popupSort) {
|
||||
this.popupSort = popupSort;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -231,7 +239,7 @@ public class OpenAdModel extends BaseModel {
|
||||
", permission=" + permission +
|
||||
", showModel=" + showModel +
|
||||
", section='" + section + '\'' +
|
||||
", sort=" + sort +
|
||||
", sort=" + popupSort +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,9 @@ import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@ -37,7 +39,7 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
builder.animationDuration(0);
|
||||
builder.hasShadowBg(true);
|
||||
if(model.getSort()==2){
|
||||
if(model.getPopupSort()==2){
|
||||
builder.dismissOnTouchOutside(false);
|
||||
builder.dismissOnBackPressed(false);
|
||||
}
|
||||
@ -67,7 +69,7 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
||||
super.onCreate();
|
||||
contentLayout = findViewById(R.id.content_layout);
|
||||
mClose = findViewById(R.id.close);
|
||||
if (model.getSort() == 1) {
|
||||
if (model.getPopupSort() == 1) {
|
||||
setImage();
|
||||
} else {
|
||||
setWeb();
|
||||
@ -104,8 +106,11 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
||||
}
|
||||
|
||||
private void setImage() {
|
||||
int width = ScreenDimenUtil.getInstance().getScreenWdith();
|
||||
int height = (int) (width * 1.4);
|
||||
|
||||
ImageView mImageView = new ImageView(mContext);
|
||||
mImageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
||||
mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
||||
mImageView.setOnClickListener(v -> {
|
||||
WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME);
|
||||
if (mListener != null) {
|
||||
|
@ -93,7 +93,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
||||
dialog.setParams(model.getName()+"弹框高宽","高度:" + height+" 宽度:"+width);
|
||||
}
|
||||
});
|
||||
if (model.getSort() == 1) {
|
||||
if (model.getPopupSort() == 1) {
|
||||
setImage(model,width,height);
|
||||
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
||||
} else {
|
||||
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -82,6 +83,7 @@ public class OpenAdManager {
|
||||
LiveNetManager.get(context).activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<OpenAdModel> data) {
|
||||
data.clear();
|
||||
if (data == null || data.isEmpty()) {
|
||||
Log.i(TAG, "onSuccess: 没有数据");
|
||||
list = new ArrayList<>();
|
||||
@ -132,11 +134,14 @@ public class OpenAdManager {
|
||||
}
|
||||
});
|
||||
showTime = System.currentTimeMillis();
|
||||
waitRunnableMap.clear();
|
||||
runnableMap.clear();
|
||||
runNowRunnable = null;
|
||||
for (OpenAdModel model : list) {
|
||||
if (model.getType() == type) {
|
||||
if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
|
||||
/* if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
if (model.getShowModel() == OpenAdModel.SHOW_ONE) {
|
||||
if (SpUtil.getInstance().getBooleanValue("open_ad_popup_" + model.getId())) {
|
||||
continue;
|
||||
@ -203,16 +208,35 @@ public class OpenAdManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
void next() {
|
||||
Log.i(TAG, "next: " + waitRunnableMap.size());
|
||||
if (waitRunnableMap.isEmpty()) return;
|
||||
AdRunnable next = waitRunnableMap.keySet().iterator().next();
|
||||
Integer i = waitRunnableMap.get(next);
|
||||
if (i == null) {
|
||||
i = 0;
|
||||
int getNowType() {
|
||||
Activity lastActivity = AppManager.getInstance().getLastActivity();
|
||||
if (lastActivity == null) {
|
||||
return -1;
|
||||
}
|
||||
onItemClickListener.onItemClick("当前加载id:" + next.model.getId() + " " + next.model.getName() + " 延迟展示时间:" + i, (waitRunnableMap.size() - 1));
|
||||
handler.postDelayed(next, i);
|
||||
if (AppManager.getInstance().isLiveActivity()) {
|
||||
return TYPE_LIVE;
|
||||
} else if (AppManager.getInstance().isMainActivity()) {
|
||||
return TYPE_HOME;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
void next() {
|
||||
Log.i(TAG, "next: 剩余数" + waitRunnableMap.size());
|
||||
if (waitRunnableMap.isEmpty()) return;
|
||||
for (AdRunnable next : waitRunnableMap.keySet()) {
|
||||
Log.i(TAG, "next: " + next.model);
|
||||
if (next.model.getType() == getNowType()) {
|
||||
Integer i = waitRunnableMap.get(next);
|
||||
if (i == null) {
|
||||
i = 0;
|
||||
}
|
||||
onItemClickListener.onItemClick("当前加载id:" + next.model.getId() + " " + next.model.getName() + " 延迟展示时间:" + i, (waitRunnableMap.size() - 1));
|
||||
handler.postDelayed(next, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class AdRunnable implements Runnable {
|
||||
@ -271,9 +295,9 @@ public class OpenAdManager {
|
||||
}
|
||||
if (model.getModel() == OpenAdModel.MODEL_BOTTOM) {
|
||||
new OpenAdBottomDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> {
|
||||
Log.i(TAG, "run: 弹框回调:" + position);
|
||||
Log.i(TAG, "run: 弹框回调:" + position + " id = " + model.getId());
|
||||
if (IS_QUEUE_SHOW) {
|
||||
waitRunnableMap.remove(runnable);
|
||||
removeList(bean);
|
||||
if (position == 0) {
|
||||
next();
|
||||
}
|
||||
@ -281,9 +305,9 @@ public class OpenAdManager {
|
||||
}).showDialog();
|
||||
} else {
|
||||
new OpenAdCenterDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> {
|
||||
Log.i(TAG, "run: 弹框回调:" + position);
|
||||
Log.i(TAG, "run: 弹框回调:" + position + " id = " + model.getId());
|
||||
if (IS_QUEUE_SHOW) {
|
||||
waitRunnableMap.remove(runnable);
|
||||
removeList(bean);
|
||||
if (position == 0) {
|
||||
next();
|
||||
}
|
||||
@ -291,6 +315,16 @@ public class OpenAdManager {
|
||||
}).showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void removeList(OpenAdModel model) {
|
||||
Log.i(TAG, "removeList: " + model);
|
||||
for (AdRunnable next : waitRunnableMap.keySet()) {
|
||||
if (next.model.getId() == model.getId()) {
|
||||
waitRunnableMap.remove(next);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AdListComparator implements Comparator<OpenAdModel> {
|
||||
|
@ -60,13 +60,13 @@ public class AppManager {
|
||||
}
|
||||
return lastActivity.getClass().getSimpleName().contains("MainActivity");
|
||||
}
|
||||
|
||||
//TODO 首页类型没展示完进直播间会不展示直播间的。
|
||||
public boolean isLiveActivity() {
|
||||
Activity lastActivity = getLastActivity();
|
||||
if(lastActivity==null){
|
||||
return false;
|
||||
}
|
||||
return lastActivity.getClass().getSimpleName().contains("LiveActivity");
|
||||
return lastActivity.getClass().getSimpleName().contains("LiveAudienceActivity");
|
||||
}
|
||||
|
||||
public static class SingleApp {
|
||||
|
@ -15,6 +15,7 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
@ -27,8 +28,10 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.lzf.easyfloat.EasyFloat;
|
||||
import com.lzf.easyfloat.enums.ShowPattern;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.lzf.easyfloat.utils.LifecycleUtils;
|
||||
import com.yunbao.common.dialog.DebugDialog;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
@ -109,6 +112,7 @@ import com.yunbao.live.socket.SocketRyChatUtil;
|
||||
import com.yunbao.live.socket.SocketRyClient;
|
||||
import com.yunbao.live.socket.SocketSendBean;
|
||||
import com.yunbao.live.utils.LiveImDeletUtil;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@ -316,6 +320,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
loading.setVisibility(View.GONE);
|
||||
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
|
||||
|
||||
}
|
||||
};
|
||||
final Runnable loadTimeoutRunnableGone = new Runnable() {
|
||||
@ -324,6 +329,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
loading.setVisibility(View.GONE);
|
||||
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
||||
//ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播,等待加载时间过了后弹出
|
||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -945,7 +945,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
NoviceInstructorManager.get(mContext).getNoviceInstructor();
|
||||
NoviceInstructorManager.get(mContext).checktHomeZdyPop();
|
||||
initAnchorRecommendBanner();
|
||||
OpenAdManager.getInstance().reset();
|
||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user