调整弹窗逻辑
This commit is contained in:
parent
8d5990c25b
commit
c92e8dd8bc
@ -30,6 +30,7 @@ import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
|||||||
import com.tencent.imsdk.v2.V2TIMManager;
|
import com.tencent.imsdk.v2.V2TIMManager;
|
||||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||||
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
||||||
|
import com.yunbao.common.manager.OpenAdManager;
|
||||||
import com.yunbao.common.utils.MobclickAgent;
|
import com.yunbao.common.utils.MobclickAgent;
|
||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
import com.yunbao.common.CommonAppConfig;
|
import com.yunbao.common.CommonAppConfig;
|
||||||
@ -37,7 +38,6 @@ import com.yunbao.common.CommonAppContext;
|
|||||||
import com.yunbao.common.Constants;
|
import com.yunbao.common.Constants;
|
||||||
import com.yunbao.common.bean.AnchorStartLiveBean;
|
import com.yunbao.common.bean.AnchorStartLiveBean;
|
||||||
import com.yunbao.common.bean.CrashSaveBean;
|
import com.yunbao.common.bean.CrashSaveBean;
|
||||||
import com.yunbao.common.dialog.DebugDialog;
|
|
||||||
import com.yunbao.common.event.SudGameSocketImEvent;
|
import com.yunbao.common.event.SudGameSocketImEvent;
|
||||||
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
|
import com.yunbao.common.manager.imrongcloud.InstructorSendReward;
|
||||||
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
|
import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
|
||||||
@ -54,6 +54,7 @@ import com.yunbao.live.socket.SocketRyClient;
|
|||||||
import com.yunbao.live.utils.LiveImDeletUtil;
|
import com.yunbao.live.utils.LiveImDeletUtil;
|
||||||
import com.yunbao.live.views.PortraitLiveManager;
|
import com.yunbao.live.views.PortraitLiveManager;
|
||||||
import com.yunbao.live.views.RecommendLiveRoomProvider;
|
import com.yunbao.live.views.RecommendLiveRoomProvider;
|
||||||
|
import com.yunbao.main.activity.LoginActivity;
|
||||||
import com.yunbao.main.activity.MsgSettActivity;
|
import com.yunbao.main.activity.MsgSettActivity;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -108,20 +109,25 @@ public class AppContext extends CommonAppContext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityDestroyed(@NonNull Activity activity) {
|
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||||
|
AppManager.getInstance().removeActivity(activity);
|
||||||
for (WeakReference<Activity> reference : activities) {
|
for (WeakReference<Activity> reference : activities) {
|
||||||
if (reference.get() == activity) {
|
if (reference.get() == activity) {
|
||||||
activities.remove(reference);
|
activities.remove(reference);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppManager.getInstance().removeActivity(activity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||||
activities.add(new WeakReference<>(activity));
|
activities.add(new WeakReference<>(activity));
|
||||||
|
if(activity instanceof LoginActivity){
|
||||||
|
AppManager.getInstance().clear();
|
||||||
|
}
|
||||||
CrashSaveBean.getInstance().setActivitySize(activities);
|
CrashSaveBean.getInstance().setActivitySize(activities);
|
||||||
AppManager.getInstance().addActivity(activity);
|
AppManager.getInstance().addActivity(activity);
|
||||||
|
OpenAdManager.getInstance().dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,7 +112,7 @@ 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://")) {
|
||||||
url = CommonAppConfig.HOST + url;
|
url = CommonAppConfig.HOST + (url.startsWith("/") ? url : "/" + url);
|
||||||
}
|
}
|
||||||
return url + "?t=" + System.currentTimeMillis() / 1000;
|
return url + "?t=" + System.currentTimeMillis() / 1000;
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,11 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
|
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
@ -28,8 +26,6 @@ import com.yunbao.common.utils.ScreenDimenUtil;
|
|||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
||||||
private ImageView mImageView;
|
private ImageView mImageView;
|
||||||
private LinearLayout contentLayout;
|
private LinearLayout contentLayout;
|
||||||
@ -79,11 +75,29 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
Log.e("-----弹窗-----", "onCreate: 创建弹窗");
|
Log.e("-----弹窗-----", "onCreate: 创建弹窗");
|
||||||
contentLayout = findViewById(R.id.content_layout);
|
contentLayout = findViewById(R.id.content_layout);
|
||||||
mClose = findViewById(R.id.close);
|
mClose = findViewById(R.id.close);
|
||||||
|
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(10);
|
||||||
|
int height = (int) (width * 1.5);
|
||||||
|
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||||
|
height = (int) (width * 1.2);
|
||||||
|
}
|
||||||
|
Log.i("-----弹窗-----", "高度:" + height+" 宽度:"+width);
|
||||||
|
DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(DebugDialog dialog) {
|
||||||
|
dialog.show();
|
||||||
|
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(10);
|
||||||
|
int height = (int) (width * 1.5);
|
||||||
|
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||||
|
height = (int) (width * 1.2);
|
||||||
|
}
|
||||||
|
dialog.setParams(model.getName()+"弹框高宽","高度:" + height+" 宽度:"+width);
|
||||||
|
}
|
||||||
|
});
|
||||||
if (model.getSort() == 1) {
|
if (model.getSort() == 1) {
|
||||||
setImage(model);
|
setImage(model,width,height);
|
||||||
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
||||||
} else {
|
} else {
|
||||||
setWeb(model);
|
setWeb(model,width,height);
|
||||||
}
|
}
|
||||||
mClose.setOnClickListener(v -> dismiss());
|
mClose.setOnClickListener(v -> dismiss());
|
||||||
if (model.getShowTime() > 0) {
|
if (model.getShowTime() > 0) {
|
||||||
@ -91,12 +105,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWeb(OpenAdModel model) {
|
private void setWeb(OpenAdModel model, int width, int height) {
|
||||||
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(20);
|
|
||||||
int height = (int) (width * 1.4);
|
|
||||||
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
|
||||||
height = (int) (width * 1.2);
|
|
||||||
}
|
|
||||||
WebView mWebView = new WebView(mContext);
|
WebView mWebView = new WebView(mContext);
|
||||||
mWebView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
mWebView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
||||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject");
|
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject");
|
||||||
@ -121,12 +130,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
contentLayout.addView(mWebView);
|
contentLayout.addView(mWebView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setImage(OpenAdModel model) {
|
private void setImage(OpenAdModel model, int width, int height) {
|
||||||
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(20);
|
|
||||||
int height = (int) (width * 1.4);
|
|
||||||
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
|
||||||
height = (int) (width * 1.2);
|
|
||||||
}
|
|
||||||
mImageView = new ImageView(mContext);
|
mImageView = new ImageView(mContext);
|
||||||
mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
||||||
mImageView.setOnClickListener(v -> {
|
mImageView.setOnClickListener(v -> {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.yunbao.common.manager;
|
package com.yunbao.common.manager;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.yunbao.common.CommonAppContext;
|
import com.yunbao.common.CommonAppContext;
|
||||||
import com.yunbao.common.bean.OpenAdModel;
|
import com.yunbao.common.bean.OpenAdModel;
|
||||||
import com.yunbao.common.dialog.DebugDialog;
|
import com.yunbao.common.dialog.DebugDialog;
|
||||||
@ -42,18 +44,6 @@ public class OpenAdManager {
|
|||||||
|
|
||||||
private OpenAdManager() {
|
private OpenAdManager() {
|
||||||
showMap = new HashMap<>();
|
showMap = new HashMap<>();
|
||||||
DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run(DebugDialog dialog) {
|
|
||||||
dialog.show();
|
|
||||||
onItemClickListener = new OnItemClickListener<String>() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(String bean, int position) {
|
|
||||||
dialog.setParams(bean, "剩余:" + position);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
init(false);
|
init(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +55,7 @@ public class OpenAdManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
Log.i(TAG, "reset: ");
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,13 +71,14 @@ public class OpenAdManager {
|
|||||||
if (list != null && list.isEmpty()) {
|
if (list != null && list.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Context context = CommonAppContext.getTopActivity();
|
Context context = AppManager.getInstance().getMainActivity();
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
context = CommonAppContext.sInstance;
|
context = CommonAppContext.sInstance;
|
||||||
}
|
}
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveNetManager.get(context).activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
LiveNetManager.get(context).activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<OpenAdModel> data) {
|
public void onSuccess(List<OpenAdModel> data) {
|
||||||
@ -126,6 +118,19 @@ public class OpenAdManager {
|
|||||||
if (System.currentTimeMillis() - showTime < 100) {
|
if (System.currentTimeMillis() - showTime < 100) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(DebugDialog dialog) {
|
||||||
|
dialog.setShowPattern(ShowPattern.CURRENT_ACTIVITY);
|
||||||
|
dialog.show();
|
||||||
|
onItemClickListener = new OnItemClickListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(String bean, int position) {
|
||||||
|
dialog.setParams(bean, "剩余:" + position);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
showTime = System.currentTimeMillis();
|
showTime = System.currentTimeMillis();
|
||||||
for (OpenAdModel model : list) {
|
for (OpenAdModel model : list) {
|
||||||
if (model.getType() == type) {
|
if (model.getType() == type) {
|
||||||
@ -247,6 +252,17 @@ public class OpenAdManager {
|
|||||||
Log.i(TAG, "展示过:" + model);
|
Log.i(TAG, "展示过:" + model);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (model.getType() == OpenAdModel.TYPE_HOME && !AppManager.getInstance().isMainActivity()) {
|
||||||
|
Log.i(TAG, "首页类型弹窗,但当前不是首页");
|
||||||
|
dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.getType() == TYPE_LIVE && !AppManager.getInstance().isLiveActivity()) {
|
||||||
|
Log.i(TAG, "直播类型弹窗,但当前不是直播");
|
||||||
|
dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showMap.put(model.getId(), true);
|
showMap.put(model.getId(), true);
|
||||||
if (model.getShowModel() == OpenAdModel.SHOW_DIY) {
|
if (model.getShowModel() == OpenAdModel.SHOW_DIY) {
|
||||||
String nextTime = String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000));
|
String nextTime = String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.yunbao.common.utils;
|
package com.yunbao.common.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ public class AppManager {
|
|||||||
private static Stack<Activity> activityStack;
|
private static Stack<Activity> activityStack;
|
||||||
|
|
||||||
public AppManager() {
|
public AppManager() {
|
||||||
activityStack=new Stack<>();
|
activityStack = new Stack<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,18 +37,38 @@ public class AppManager {
|
|||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return getLastActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity getLiveActivity() {
|
public Activity getLiveActivity() {
|
||||||
for (Activity activity : activityStack) {
|
for (Activity activity : activityStack) {
|
||||||
if (activity.getClass().getSimpleName().contains("LiveAudienceActivity")) {
|
if (activity.getClass().getSimpleName().contains("LiveActivity")) {
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
activityStack.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMainActivity() {
|
||||||
|
Activity lastActivity = getLastActivity();
|
||||||
|
if(lastActivity==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return lastActivity.getClass().getSimpleName().contains("MainActivity");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLiveActivity() {
|
||||||
|
Activity lastActivity = getLastActivity();
|
||||||
|
if(lastActivity==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return lastActivity.getClass().getSimpleName().contains("LiveActivity");
|
||||||
|
}
|
||||||
|
|
||||||
public static class SingleApp {
|
public static class SingleApp {
|
||||||
public static AppManager INSTANCE = new AppManager();
|
public static AppManager INSTANCE = new AppManager();
|
||||||
}
|
}
|
||||||
@ -59,6 +80,10 @@ public class AppManager {
|
|||||||
if (activityStack == null) {
|
if (activityStack == null) {
|
||||||
activityStack = new Stack<Activity>();
|
activityStack = new Stack<Activity>();
|
||||||
}
|
}
|
||||||
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>class com.yunbao.main.activity.MsgAddressBookActivity
|
||||||
|
if (getActivity(activity.getClass()) != null) {
|
||||||
|
activityStack.remove(getActivity(activity.getClass()));
|
||||||
|
}
|
||||||
activityStack.add(activity);
|
activityStack.add(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user