From ae0ef717d5cc80a2d3e696bfcb8e1d38c0fb9754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E5=AD=90=E7=BB=B4?= Date: Tue, 4 Mar 2025 17:19:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=BD=91=E9=A1=B5=E4=B8=8D=E8=83=BD=E5=B7=A6?= =?UTF-8?q?=E5=8F=B3=E6=BB=91=E5=8A=A8=E5=88=87=E6=8D=A2Tab=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamedetail/GameDetailWrapperFragment.kt | 8 ++++++++ .../java/com/halo/assistant/fragment/WebFragment.kt | 6 ++++++ .../gamecenter/common/view/NestedScrollWebView2.java | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailWrapperFragment.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailWrapperFragment.kt index 981f85e8fb..55a2246382 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailWrapperFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailWrapperFragment.kt @@ -727,6 +727,8 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable { fragment = fragment ?: WebFragment() bundle.putString(EntranceConsts.KEY_ENTRANCE, "游戏专区") bundle.putString(EntranceConsts.KEY_URL, zone.link) + bundle.putBoolean(WebFragment.KEY_ENABLE_HORIZONTAL_SCROLL_DISPATCH, true) + bundle.putBoolean(WebFragment.KEY_FORCE_ENABLE_NESTED_SCROLL, true) } else { fragment = fragment ?: FuLiFragment() } @@ -735,6 +737,12 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable { GameDetailTabEntity.TYPE_WEB -> { fragment = fragment ?: WebFragment() bundle.putString(EntranceConsts.KEY_URL, tabEntity.link?.link) + bundle.putBoolean(WebFragment.KEY_ENABLE_HORIZONTAL_SCROLL_DISPATCH, true) + bundle.putBoolean(WebFragment.KEY_FORCE_ENABLE_NESTED_SCROLL, true) + bundle.putBoolean( + WebFragment.KEY_LEAVE_WEB_PAGE_TO_HANDLE_BACK_PRESSED, + tabEntity.link?.link?.contains("leave_web_page_handle_back_pressed=true") == true + ) } GameDetailTabEntity.TYPE_GIFT -> { diff --git a/app/src/main/java/com/halo/assistant/fragment/WebFragment.kt b/app/src/main/java/com/halo/assistant/fragment/WebFragment.kt index cb0a047b92..2335a0581b 100644 --- a/app/src/main/java/com/halo/assistant/fragment/WebFragment.kt +++ b/app/src/main/java/com/halo/assistant/fragment/WebFragment.kt @@ -117,6 +117,7 @@ class WebFragment : LazyFragment(), IScrollable { private var mLeaveWebpageToHandleTitle = false //是否由网页处理标题 private var mClearHistoryOnLoaded = false // 是否加载完成以后清理掉旧的加载历史 private var mIsWebViewInstalled = true // 当前设备是否存在可用的 WebView + private var mForceEnableNestedScroll = false // 强制启用嵌套滚动 private var mTimeElapsedHelper: TimeElapsedHelper? = null private lateinit var mJsApi: DefaultJsApi @@ -347,6 +348,7 @@ class WebFragment : LazyFragment(), IScrollable { mIsSecurityCertification = args.getBoolean(KEY_IS_SECURITY_CERTIFICATION, false) mLeaveWebpageToHandleTitle = args.getBoolean(KEY_LEAVE_WEB_PAGE_TO_HANDLE_TITLE, false) mWebUrl = dealWithUrl(args.getString(EntranceConsts.KEY_URL, "")) + mForceEnableNestedScroll = args.getBoolean(KEY_ENABLE_HORIZONTAL_SCROLL_DISPATCH) } mJsApi = DefaultJsApi( requireContext(), @@ -698,6 +700,9 @@ class WebFragment : LazyFragment(), IScrollable { if (mIsHorizontalDispatcherEnabled) { webview.enableHorizontalScrollDispatch() } + if (mForceEnableNestedScroll) { + webview.enableForceNestedScroll() + } webview.addJavascriptObject(mJsApi, null) webview.addJavascriptObject(ShareNativeCallback(), "share") webview.addJavascriptObject(InternalJsApi(), "internal") @@ -1047,6 +1052,7 @@ class WebFragment : LazyFragment(), IScrollable { const val KEY_GAME_NAME = "game_name" const val KEY_CLOSE_BUTTON = "close_button" const val KEY_ENABLE_HORIZONTAL_SCROLL_DISPATCH = "enable_horizontal_scroll_dispatch" + const val KEY_FORCE_ENABLE_NESTED_SCROLL = "force_enable_nested_scroll" private const val REQUEST_PICK_IMAGE = 101 } } \ No newline at end of file diff --git a/module_common/src/main/java/com/gh/gamecenter/common/view/NestedScrollWebView2.java b/module_common/src/main/java/com/gh/gamecenter/common/view/NestedScrollWebView2.java index 93e0543227..e8803bfab7 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/view/NestedScrollWebView2.java +++ b/module_common/src/main/java/com/gh/gamecenter/common/view/NestedScrollWebView2.java @@ -64,6 +64,8 @@ public class NestedScrollWebView2 extends DWebView implements NestedScrollingChi private boolean isScrollX = false; + private boolean mForceEnableNestedScroll = false; + public NestedScrollWebView2(Context context, AttributeSet attrs) { super(context, attrs); init(); @@ -117,7 +119,7 @@ public class NestedScrollWebView2 extends DWebView implements NestedScrollingChi @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - if (!mIsParentViewImplNestedScrolling) { + if (!mIsParentViewImplNestedScrolling && !mForceEnableNestedScroll) { return super.onInterceptTouchEvent(ev); } @@ -193,7 +195,7 @@ public class NestedScrollWebView2 extends DWebView implements NestedScrollingChi @Override public boolean onTouchEvent(MotionEvent ev) { - if (!mIsParentViewImplNestedScrolling) { + if (!mIsParentViewImplNestedScrolling && !mForceEnableNestedScroll) { return super.onTouchEvent(ev); } @@ -527,7 +529,7 @@ public class NestedScrollWebView2 extends DWebView implements NestedScrollingChi @Override public void computeScroll() { - if (!mIsParentViewImplNestedScrolling) { + if (!mIsParentViewImplNestedScrolling && !mForceEnableNestedScroll) { super.computeScroll(); return; } @@ -839,4 +841,8 @@ public class NestedScrollWebView2 extends DWebView implements NestedScrollingChi public void enableHorizontalScrollDispatch() { mInterceptHorizontalScrollDispatch = false; } + + public void enableForceNestedScroll() { + mForceEnableNestedScroll = true; + } }