From cdf3c4e4116db76c7dfc2c1b5d3f28a6698273e0 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 12 Dec 2023 13:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BC=B9=E7=AA=97=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dialog/OpenAdCenterDialogPopup.java | 7 +++++++ .../com/yunbao/common/manager/OpenAdManager.java | 10 +++++++++- .../common/utils/AndroidBug5497Workaround.java | 14 ++++++++++++-- .../src/main/res/layout/dialog_open_center_ad.xml | 2 +- .../com/yunbao/main/activity/MainActivity.java | 1 - .../com/yunbao/main/views/MainHomeViewHolder.java | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java index 5e92f5f10..bc4add265 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java @@ -1,6 +1,7 @@ package com.yunbao.common.dialog; import android.content.Context; +import android.util.Log; import android.widget.ImageView; import androidx.annotation.NonNull; @@ -21,6 +22,10 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { private OpenAdModel model; private OnItemClickListener mListener; + public OpenAdCenterDialogPopup(@NonNull Context context) { + super(context); + } + public OpenAdCenterDialogPopup(@NonNull Context context, OpenAdModel model) { super(context); this.model = model; @@ -33,6 +38,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { @Override public void buildDialog(XPopup.Builder builder) { + builder.hasShadowBg(false); } @Override @@ -53,6 +59,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { @Override protected void onCreate() { super.onCreate(); + Log.e("-----弹窗-----", "onCreate: 创建弹窗" ); mImageView = findViewById(R.id.img); mClose = findViewById(R.id.close); findViewById(R.id.layout).setOnClickListener(v -> dismiss()); diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java index 6856890dd..46242290d 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -83,12 +83,16 @@ public class OpenAdManager { }); } - + private static long showTime=0; public synchronized void show(int type, boolean isGuard) { if (list == null) { init(true); return; } + if(System.currentTimeMillis()-showTime<100){ + return; + } + showTime=System.currentTimeMillis(); showType = type; for (OpenAdModel model : list) { if (model.getType() == type) { @@ -179,6 +183,10 @@ public class OpenAdManager { if (model.getType() != showType) { return; } + if(isShow(model)){ + Log.i(TAG,"展示过:"+model); + return; + } showMap.put(model.getId(), true); if (model.getShowModel() == OpenAdModel.SHOW_DIY) { String nextTime= String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000)); diff --git a/common/src/main/java/com/yunbao/common/utils/AndroidBug5497Workaround.java b/common/src/main/java/com/yunbao/common/utils/AndroidBug5497Workaround.java index a52dc7781..bcc191cad 100644 --- a/common/src/main/java/com/yunbao/common/utils/AndroidBug5497Workaround.java +++ b/common/src/main/java/com/yunbao/common/utils/AndroidBug5497Workaround.java @@ -1,9 +1,12 @@ package com.yunbao.common.utils; import android.app.Activity; +import android.content.Context; import android.graphics.Rect; import android.view.View; +import android.view.ViewGroup; import android.view.ViewTreeObserver; +import android.view.inputmethod.InputMethodManager; import android.widget.FrameLayout; /** @@ -15,12 +18,13 @@ public class AndroidBug5497Workaround { // 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. - public static void assistActivity (Activity activity) { + public static void assistActivity(Activity activity) { new AndroidBug5497Workaround(activity); } private View mChildOfContent; private int usableHeightPrevious; + private int defHeight = ViewGroup.LayoutParams.MATCH_PARENT; private FrameLayout.LayoutParams frameLayoutParams; private AndroidBug5497Workaround(Activity activity) { @@ -29,8 +33,14 @@ public class AndroidBug5497Workaround { mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { possiblyResizeChildOfContent(); + int heightDiff = mChildOfContent.getRootView().getHeight() - mChildOfContent.getHeight(); + if (heightDiff < 100) { + frameLayoutParams.height = defHeight; + mChildOfContent.requestLayout(); + } } }); + frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams(); } @@ -39,7 +49,7 @@ public class AndroidBug5497Workaround { if (usableHeightNow != usableHeightPrevious) { int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight(); int heightDifference = usableHeightSansKeyboard - usableHeightNow; - if (heightDifference > (usableHeightSansKeyboard/4)) { + if (heightDifference > (usableHeightSansKeyboard / 4)) { // keyboard probably just became visible frameLayoutParams.height = usableHeightSansKeyboard - heightDifference; } else { diff --git a/common/src/main/res/layout/dialog_open_center_ad.xml b/common/src/main/res/layout/dialog_open_center_ad.xml index d32b5e485..dd60e83a6 100644 --- a/common/src/main/res/layout/dialog_open_center_ad.xml +++ b/common/src/main/res/layout/dialog_open_center_ad.xml @@ -13,7 +13,7 @@ android:layout_marginStart="20dp" android:layout_marginEnd="20dp" android:layout_marginBottom="12dp" - android:scaleType="fitEnd" + android:scaleType="fitCenter" app:layout_constraintBottom_toTopOf="@+id/close" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index e9c2814d8..5e53a6074 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -511,7 +511,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene findViewById(R.id.banner_click).setVisibility(View.GONE); isfloatBannernet = false; } - mViewHolders[index].onResume(); }); //获取指导员账号 ConversationIMListManager.get(this).getUserInstructor(this); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index 9302f4762..4b3132d4d 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -1,6 +1,7 @@ package com.yunbao.main.views; import android.content.Context; +import android.util.Log; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; @@ -107,7 +108,6 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { @Override public void onResume() { super.onResume(); - mViewHolders[mViewPager.getCurrentItem()].onResume(); } @Override