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