调整弹窗
This commit is contained in:
parent
186b9d61ee
commit
0396e2d06d
@ -139,7 +139,7 @@ public class DebugDialog {
|
|||||||
EasyFloat.updateFloat("debug");
|
EasyFloat.updateFloat("debug");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
params.put("发包时间:"+ CommonAppConfig.BUILD_TIME, textView);
|
params.put("发包时间:" + CommonAppConfig.BUILD_TIME, textView);
|
||||||
adapter.setParamMap(params);
|
adapter.setParamMap(params);
|
||||||
|
|
||||||
EasyFloat.with(mContext)
|
EasyFloat.with(mContext)
|
||||||
|
@ -4,6 +4,9 @@ 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.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.WindowInsets;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -11,6 +14,7 @@ import android.widget.LinearLayout;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
|
import com.lzf.easyfloat.enums.ShowPattern;
|
||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
import com.yunbao.common.activity.WebViewActivity;
|
import com.yunbao.common.activity.WebViewActivity;
|
||||||
import com.yunbao.common.bean.OpenAdModel;
|
import com.yunbao.common.bean.OpenAdModel;
|
||||||
@ -75,34 +79,49 @@ 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) {
|
contentLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
height = (int) (width * 1.2);
|
boolean isShow = false;
|
||||||
}
|
|
||||||
Log.i("-----弹窗-----", "高度:" + height+" 宽度:"+width);
|
|
||||||
DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run(DebugDialog dialog) {
|
public void onGlobalLayout() {
|
||||||
dialog.show();
|
if (isShow)
|
||||||
|
return;
|
||||||
|
isShow = true;
|
||||||
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(10);
|
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(10);
|
||||||
int height = (int) (width * 1.5);
|
int height = (int) (width * 1.5);
|
||||||
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||||
height = (int) (width * 1.2);
|
height = (int) (width * 1.2);
|
||||||
}
|
}
|
||||||
dialog.setParams(model.getName()+"弹框高宽","高度:" + height+" 宽度:"+width);
|
Log.i("-----弹窗-----", "高度:" + height + " 宽度:" + width + " 布局宽度: " + contentLayout.getWidth() + " 屏幕宽度: " + ScreenDimenUtil.getInstance().getScreenWdith());
|
||||||
|
/*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(DebugDialog dialog) {
|
||||||
|
dialog.setShowPattern(ShowPattern.ALL_TIME);
|
||||||
|
dialog.show();
|
||||||
|
int width = contentLayout.getWidth() - DpUtil.dp2px(10);
|
||||||
|
int height = (int) (width * 1.5);
|
||||||
|
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||||
|
height = (int) (width * 1.2);
|
||||||
|
}
|
||||||
|
Log.i("-----弹窗-----", "弹框debug高宽 高度:" + height + " 宽度:" + width);
|
||||||
|
dialog.setParams(model.getName() + "弹框高宽", "高度:" + height + " 宽度:" + width);
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
if (model.getPopupSort() == 1) {
|
||||||
|
setImage(model, width, height);
|
||||||
|
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
||||||
|
} else {
|
||||||
|
setWeb(model, width, height);
|
||||||
|
}
|
||||||
|
mClose.setOnClickListener(v -> dismiss());
|
||||||
|
if (model.getShowTime() > 0) {
|
||||||
|
mClose.postDelayed(OpenAdCenterDialogPopup.this::dismiss, model.getShowTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (model.getPopupSort() == 1) {
|
|
||||||
setImage(model,width,height);
|
|
||||||
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
|
||||||
} else {
|
|
||||||
setWeb(model,width,height);
|
|
||||||
}
|
|
||||||
mClose.setOnClickListener(v -> dismiss());
|
|
||||||
if (model.getShowTime() > 0) {
|
|
||||||
mClose.postDelayed(this::dismiss, model.getShowTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWeb(OpenAdModel model, int width, int height) {
|
private void setWeb(OpenAdModel model, int width, int height) {
|
||||||
@ -125,13 +144,14 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
|||||||
} else {
|
} else {
|
||||||
url += "?uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken();
|
url += "?uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken();
|
||||||
}
|
}
|
||||||
Log.i("-----弹窗-----", "setWeb: "+url);
|
Log.i("-----弹窗-----", "setWeb: " + url);
|
||||||
mWebView.loadUrl(url);
|
mWebView.loadUrl(url);
|
||||||
contentLayout.addView(mWebView);
|
contentLayout.addView(mWebView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setImage(OpenAdModel model, int width, int height) {
|
private void setImage(OpenAdModel model, int width, int height) {
|
||||||
mImageView = new ImageView(mContext);
|
mImageView = new ImageView(mContext);
|
||||||
|
mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
|
||||||
mImageView.setOnClickListener(v -> {
|
mImageView.setOnClickListener(v -> {
|
||||||
if ("home_page_banner_battle".equals(model.getOriginalUrl())) {
|
if ("home_page_banner_battle".equals(model.getOriginalUrl())) {
|
||||||
|
@ -50,9 +50,16 @@ public class OpenAdManager {
|
|||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
dismiss();
|
dismiss();
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
runnableMap.clear();
|
runnableMap.clear();
|
||||||
showMap.clear();
|
showMap.clear();
|
||||||
list.clear();
|
list.clear();
|
||||||
|
waitRunnableMap.clear();
|
||||||
|
list = null;
|
||||||
|
runNowRunnable = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
@ -107,7 +114,12 @@ public class OpenAdManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long showTime = 0;
|
private static long showTime = 0;
|
||||||
private OnItemClickListener<String> onItemClickListener;
|
private OnItemClickListener<String> onItemClickListener=new OnItemClickListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(String bean, int position) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public synchronized void show(int type, boolean isGuard) {
|
public synchronized void show(int type, boolean isGuard) {
|
||||||
showType = type;
|
showType = type;
|
||||||
@ -119,10 +131,10 @@ public class OpenAdManager {
|
|||||||
if (System.currentTimeMillis() - showTime < 100) {
|
if (System.currentTimeMillis() - showTime < 100) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
/*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run(DebugDialog dialog) {
|
public void run(DebugDialog dialog) {
|
||||||
dialog.setShowPattern(ShowPattern.CURRENT_ACTIVITY);
|
dialog.setShowPattern(ShowPattern.ALL_TIME);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
onItemClickListener = new OnItemClickListener<String>() {
|
onItemClickListener = new OnItemClickListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
@ -131,7 +143,7 @@ public class OpenAdManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
showTime = System.currentTimeMillis();
|
showTime = System.currentTimeMillis();
|
||||||
waitRunnableMap.clear();
|
waitRunnableMap.clear();
|
||||||
runnableMap.clear();
|
runnableMap.clear();
|
||||||
@ -258,30 +270,51 @@ public class OpenAdManager {
|
|||||||
Log.i(TAG, "run: " + model);
|
Log.i(TAG, "run: " + model);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
ToastUtil.showDebug("model为空");
|
ToastUtil.showDebug("model为空");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!model.isInTime()) {
|
if (!model.isInTime()) {
|
||||||
ToastUtil.showDebug("不在展示时间内:" + model.getStartTime() + "|" + model.getEndTime());
|
ToastUtil.showDebug("不在展示时间内:" + model.getStartTime() + "|" + model.getEndTime());
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isShow(model)) {
|
if (isShow(model)) {
|
||||||
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (model.getType() != showType) {
|
if (model.getType() != showType) {
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isShow(model)) {
|
if (isShow(model)) {
|
||||||
Log.i(TAG, "展示过:" + model);
|
Log.i(TAG, "展示过:" + model);
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (model.getType() == OpenAdModel.TYPE_HOME && !AppManager.getInstance().isMainActivity()) {
|
if (model.getType() == OpenAdModel.TYPE_HOME && !AppManager.getInstance().isMainActivity()) {
|
||||||
Log.i(TAG, "首页类型弹窗,但当前不是首页");
|
Log.i(TAG, "首页类型弹窗,但当前不是首页");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (model.getType() == TYPE_LIVE && !AppManager.getInstance().isLiveActivity()) {
|
if (model.getType() == TYPE_LIVE && !AppManager.getInstance().isLiveActivity()) {
|
||||||
Log.i(TAG, "直播类型弹窗,但当前不是直播");
|
Log.i(TAG, "直播类型弹窗,但当前不是直播");
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick("", -2);
|
||||||
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
|
import com.yunbao.common.manager.OpenAdManager;
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
@ -51,19 +52,21 @@ public class AppManager {
|
|||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
activityStack.clear();
|
activityStack.clear();
|
||||||
|
OpenAdManager.getInstance().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMainActivity() {
|
public boolean isMainActivity() {
|
||||||
Activity lastActivity = getLastActivity();
|
Activity lastActivity = getLastActivity();
|
||||||
if(lastActivity==null){
|
if (lastActivity == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return lastActivity.getClass().getSimpleName().contains("MainActivity");
|
return lastActivity.getClass().getSimpleName().contains("MainActivity");
|
||||||
}
|
}
|
||||||
//TODO 首页类型没展示完进直播间会不展示直播间的。
|
|
||||||
|
//TODO 首页类型没展示完进直播间会不展示直播间的。
|
||||||
public boolean isLiveActivity() {
|
public boolean isLiveActivity() {
|
||||||
Activity lastActivity = getLastActivity();
|
Activity lastActivity = getLastActivity();
|
||||||
if(lastActivity==null){
|
if (lastActivity == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return lastActivity.getClass().getSimpleName().contains("LiveAudienceActivity");
|
return lastActivity.getClass().getSimpleName().contains("LiveAudienceActivity");
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/close"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_marginBottom="12dp">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -25,10 +26,10 @@
|
|||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_marginBottom="202dp"
|
android:layout_marginTop="24dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/content_layout"
|
app:layout_constraintEnd_toEndOf="@+id/content_layout"
|
||||||
app:layout_constraintStart_toStartOf="@+id/content_layout"
|
app:layout_constraintStart_toStartOf="@+id/content_layout"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/content_layout"
|
||||||
app:srcCompat="@mipmap/ic_open_ad_close" />
|
app:srcCompat="@mipmap/ic_open_ad_close" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user