From b4c550f71bd3b85f3828b711d1f021fb7b43b62c Mon Sep 17 00:00:00 2001 From: chenjuntao Date: Thu, 8 Jun 2023 14:43:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=8E=E4=B8=BApad=E7=AE=80=E6=98=93?= =?UTF-8?q?=E9=80=82=E9=85=8D=E2=80=940606=E6=B5=8B=E8=AF=95=20https://jir?= =?UTF-8?q?a.shanqu.cc/browse/GHZS-2639?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamecenter/qa/comment/NewCommentFragment.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentFragment.kt index 96162eb350..f78a5606a2 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentFragment.kt @@ -5,6 +5,7 @@ import android.app.Activity import android.app.Dialog import android.content.Context import android.content.Intent +import android.os.Build import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater @@ -13,6 +14,8 @@ import android.view.inputmethod.InputMethodManager import android.widget.* import androidx.core.content.ContextCompat import androidx.core.os.bundleOf +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.recyclerview.widget.RecyclerView @@ -305,8 +308,17 @@ open class NewCommentFragment : ListFragment commentContainer?.layoutParams = layoutParams } - mKeyboardHeightProvider = KeyboardHeightProvider(activity) - view.post { mKeyboardHeightProvider?.start() } + // 平板上的导航方式改成按键时,使用 KeyboardHeightProvider 的 PopupWindow 会拦截掉所有的触摸事件 + // 换成在 Android 5.1 以后监听 WindowInsets 的实现 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + ViewCompat.setOnApplyWindowInsetsListener(requireActivity().window.decorView) { _: View?, insets: WindowInsetsCompat -> + onKeyboardHeightChanged(insets.getInsets(WindowInsetsCompat.Type.ime()).bottom, 0) + insets + } + } else { + mKeyboardHeightProvider = KeyboardHeightProvider(activity) + view.post { mKeyboardHeightProvider?.start() } + } val emptyHint = mCachedView?.findViewById(R.id.reuseNoneDataTv) emptyHint?.text = "这里还没有人评论噢~" emptyHint?.setTextColor(R.color.background_white.toColor(requireContext()))