调整弹窗显示

This commit is contained in:
zlzw 2023-12-12 13:51:02 +08:00
parent d0b7b065b2
commit cdf3c4e411
6 changed files with 30 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.yunbao.common.dialog; package com.yunbao.common.dialog;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -21,6 +22,10 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
private OpenAdModel model; private OpenAdModel model;
private OnItemClickListener<OpenAdModel> mListener; private OnItemClickListener<OpenAdModel> mListener;
public OpenAdCenterDialogPopup(@NonNull Context context) {
super(context);
}
public OpenAdCenterDialogPopup(@NonNull Context context, OpenAdModel model) { public OpenAdCenterDialogPopup(@NonNull Context context, OpenAdModel model) {
super(context); super(context);
this.model = model; this.model = model;
@ -33,6 +38,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
@Override @Override
public void buildDialog(XPopup.Builder builder) { public void buildDialog(XPopup.Builder builder) {
builder.hasShadowBg(false);
} }
@Override @Override
@ -53,6 +59,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
@Override @Override
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
Log.e("-----弹窗-----", "onCreate: 创建弹窗" );
mImageView = findViewById(R.id.img); mImageView = findViewById(R.id.img);
mClose = findViewById(R.id.close); mClose = findViewById(R.id.close);
findViewById(R.id.layout).setOnClickListener(v -> dismiss()); findViewById(R.id.layout).setOnClickListener(v -> dismiss());

View File

@ -83,12 +83,16 @@ public class OpenAdManager {
}); });
} }
private static long showTime=0;
public synchronized void show(int type, boolean isGuard) { public synchronized void show(int type, boolean isGuard) {
if (list == null) { if (list == null) {
init(true); init(true);
return; return;
} }
if(System.currentTimeMillis()-showTime<100){
return;
}
showTime=System.currentTimeMillis();
showType = type; showType = type;
for (OpenAdModel model : list) { for (OpenAdModel model : list) {
if (model.getType() == type) { if (model.getType() == type) {
@ -179,6 +183,10 @@ public class OpenAdManager {
if (model.getType() != showType) { if (model.getType() != showType) {
return; return;
} }
if(isShow(model)){
Log.i(TAG,"展示过:"+model);
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));

View File

@ -1,9 +1,12 @@
package com.yunbao.common.utils; package com.yunbao.common.utils;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout; import android.widget.FrameLayout;
/** /**
@ -15,12 +18,13 @@ public class AndroidBug5497Workaround {
// For more information, see https://issuetracker.google.com/issues/36911528 // For more information, see https://issuetracker.google.com/issues/36911528
// To use this class, simply invoke assistActivity() on an Activity that already has its content view set. // To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
public static void assistActivity (Activity activity) { public static void assistActivity(Activity activity) {
new AndroidBug5497Workaround(activity); new AndroidBug5497Workaround(activity);
} }
private View mChildOfContent; private View mChildOfContent;
private int usableHeightPrevious; private int usableHeightPrevious;
private int defHeight = ViewGroup.LayoutParams.MATCH_PARENT;
private FrameLayout.LayoutParams frameLayoutParams; private FrameLayout.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity) { private AndroidBug5497Workaround(Activity activity) {
@ -29,8 +33,14 @@ public class AndroidBug5497Workaround {
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() { public void onGlobalLayout() {
possiblyResizeChildOfContent(); possiblyResizeChildOfContent();
int heightDiff = mChildOfContent.getRootView().getHeight() - mChildOfContent.getHeight();
if (heightDiff < 100) {
frameLayoutParams.height = defHeight;
mChildOfContent.requestLayout();
}
} }
}); });
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams(); frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
} }
@ -39,7 +49,7 @@ public class AndroidBug5497Workaround {
if (usableHeightNow != usableHeightPrevious) { if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight(); int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow; int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard/4)) { if (heightDifference > (usableHeightSansKeyboard / 4)) {
// keyboard probably just became visible // keyboard probably just became visible
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference; frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else { } else {

View File

@ -13,7 +13,7 @@
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:scaleType="fitEnd" android:scaleType="fitCenter"
app:layout_constraintBottom_toTopOf="@+id/close" app:layout_constraintBottom_toTopOf="@+id/close"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />

View File

@ -511,7 +511,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
findViewById(R.id.banner_click).setVisibility(View.GONE); findViewById(R.id.banner_click).setVisibility(View.GONE);
isfloatBannernet = false; isfloatBannernet = false;
} }
mViewHolders[index].onResume();
}); });
//获取指导员账号 //获取指导员账号
ConversationIMListManager.get(this).getUserInstructor(this); ConversationIMListManager.get(this).getUserInstructor(this);

View File

@ -1,6 +1,7 @@
package com.yunbao.main.views; package com.yunbao.main.views;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
@ -107,7 +108,6 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
mViewHolders[mViewPager.getCurrentItem()].onResume();
} }
@Override @Override