From abef2248306dc1c596d284eefe0ac57cf489759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=A8?= Date: Mon, 25 Nov 2024 09:26:26 +0800 Subject: [PATCH] fix:https://sentry.shanqu.cc/organizations/lightgame/issues/408589/events/edfa... --- .../home/custom/CustomPageFragment.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageFragment.kt b/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageFragment.kt index d28fb381c1..c9226cdd7b 100644 --- a/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageFragment.kt @@ -3,7 +3,9 @@ package com.gh.gamecenter.home.custom import android.graphics.Color import android.os.Build import android.os.Bundle +import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup import androidx.fragment.app.viewModels import androidx.lifecycle.Observer import androidx.recyclerview.widget.RecyclerView @@ -54,6 +56,7 @@ import com.gh.gamecenter.feature.entity.PageLocation import com.gh.gamecenter.feature.exposure.ExposureEvent import com.gh.gamecenter.feature.exposure.ExposureType import com.gh.gamecenter.feature.minigame.MiniGameItemHelper +import com.gh.gamecenter.feature.utils.SentryHelper import com.gh.gamecenter.game.commoncollection.detail.CustomCommonCollectionDetailActivity import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity import com.gh.gamecenter.home.PageConfigure @@ -182,6 +185,22 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable { viewModel.init(pageConfigure, searchToolbarTabWrapperViewModel, pageLocation) } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + binding = try { + FragmentCustomBinding.inflate(layoutInflater) + } catch (e: Exception) { + SentryHelper.onEvent( + "VIEW_BINDING_BIND_ERROR", + "digest", e.localizedMessage, + "gid", HaloApp.getInstance().gid + ) + // 玄学,重试一次,该闪退闪退 + FragmentCustomBinding.inflate(layoutInflater) + } + mCachedView = binding.root + return mCachedView + } + override fun getRealLayoutId() = R.layout.fragment_custom override fun onFragmentFirstVisible() { @@ -493,8 +512,6 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable { override fun initRealView() { super.initRealView() - binding = FragmentCustomBinding.bind(mCachedView) - scrollCalculatorHelper = ScrollCalculatorHelper(binding.gameList, R.id.autoVideoView, 0, false) buildPriorityChain()