diff --git a/app/src/main/java/com/gh/common/util/SoftInputHidWidgetUtils.java b/app/src/main/java/com/gh/common/util/SoftInputHidWidgetUtils.java deleted file mode 100644 index 7dee35f559..0000000000 --- a/app/src/main/java/com/gh/common/util/SoftInputHidWidgetUtils.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.gh.common.util; - -import android.app.Activity; -import android.graphics.Rect; -import android.os.Build; -import android.view.View; -import android.view.ViewTreeObserver; -import android.widget.FrameLayout; - -/** - * 用于解决因为沉浸式状态栏(自定义)时键盘不遮挡输入框 - */ -public class SoftInputHidWidgetUtils { - private View mChildOfContent; - private int usableHeightPrevious; - private FrameLayout.LayoutParams frameLayoutParams; - private int contentHeight; - private boolean isfirst = true; - private int statusBarHeight; - - public static void assistActivity(Activity activity) { - if (Build.VERSION.SDK_INT >= 19) { - new SoftInputHidWidgetUtils(activity); - } - } - - private SoftInputHidWidgetUtils(Activity activity) { - statusBarHeight = getStatusBarHeight(activity); - FrameLayout content = (FrameLayout)activity.findViewById(android.R.id.content); - mChildOfContent = content.getChildAt(0); - - //界面出现变动都会调用这个监听事件 - mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - public void onGlobalLayout() { - if (isfirst) { - contentHeight = mChildOfContent.getHeight();//兼容华为等机型 - isfirst = false; - } - possiblyResizeChildOfContent(); - } - }); - - frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams(); - } - - //重新调整跟布局的高度 - private void possiblyResizeChildOfContent() { - - int usableHeightNow = computeUsableHeight(); - //当前可见高度和上一次可见高度不一致 布局变动 - if (usableHeightNow != usableHeightPrevious) { - int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight(); - int heightDifference = usableHeightSansKeyboard - usableHeightNow; - if (heightDifference > (usableHeightSansKeyboard / 4)) { - // keyboard probably just became visible - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ - frameLayoutParams.height = usableHeightSansKeyboard - heightDifference + statusBarHeight; - } else { - frameLayoutParams.height = usableHeightSansKeyboard - heightDifference; - } - } else { - frameLayoutParams.height = contentHeight; - } - mChildOfContent.requestLayout(); - usableHeightPrevious = usableHeightNow; - } - } - - /** - * 获取改变之后界面的可用高度(可以为开发者显示内容的高度) - * @return - */ - private int computeUsableHeight() { - Rect r = new Rect(); - mChildOfContent.getWindowVisibleDisplayFrame(r);//获取到的rect就是界面除去标题栏、除去软键盘挡住部分,所剩下的域 - return (r.bottom - r.top); - } - - public static int getStatusBarHeight(Activity activity) { - //获取状态栏的高度 - int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android"); - return activity.getResources().getDimensionPixelSize(resourceId); - } -} diff --git a/app/src/main/java/com/gh/common/view/DownloadDialog.java b/app/src/main/java/com/gh/common/view/DownloadDialog.java index c85d7464c7..e334640966 100644 --- a/app/src/main/java/com/gh/common/view/DownloadDialog.java +++ b/app/src/main/java/com/gh/common/view/DownloadDialog.java @@ -20,6 +20,7 @@ import android.widget.TextView; import com.gh.common.constant.Config; import com.gh.common.exposure.ExposureEvent; +import com.gh.common.util.ClickUtils; import com.gh.common.util.DirectUtils; import com.gh.common.util.DisplayUtils; import com.gh.common.util.PackageUtils; @@ -63,12 +64,8 @@ import java.util.concurrent.ConcurrentHashMap; * @des 弹出游戏版本下载按钮,点击并添加到下载任务中 */ public class DownloadDialog implements OnCollectionCallBackListener { - - private static DownloadDialog instance; - private Context mContext; - private boolean isShow; private PopupWindow popupWindow; private List gameApk; private GameEntity gameEntity; @@ -101,17 +98,12 @@ public class DownloadDialog implements OnCollectionCallBackListener { private final int column = 3; private boolean isLoadPlatform; - private DownloadDialog() { - isShow = false; + private DownloadDialog(Context context) { + mContext = context; } - // todo 不能设置未单例 public static DownloadDialog getInstance(Context context) { -// if (instance == null) { - instance = new DownloadDialog(); -// } - instance.mContext = context; // 每次创建context重新赋值, Dialog持有context问题 - return instance; + return new DownloadDialog(context); } // 自动下载并翻到相应页面 @@ -127,13 +119,9 @@ public class DownloadDialog implements OnCollectionCallBackListener { public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location, @Nullable ExposureEvent traceEvent) { - if (isShow && (popupWindow == null || !popupWindow.isShowing())) { - isShow = false; - } - if (isShow) { + if (ClickUtils.isFastDoubleClick()) { return; } - isShow = true; this.gameEntity = gameEntity; this.entrance = entrance; @@ -204,7 +192,6 @@ public class DownloadDialog implements OnCollectionCallBackListener { }); popupWindow.setOnDismissListener(() -> { - isShow = false; EventBus.getDefault().unregister(DownloadDialog.this); DownloadManager.getInstance(mContext).removeObserver(dataWatcher); });