diff --git a/app/src/main/java/com/gh/common/iinterface/ISearchToolbarTab.kt b/app/src/main/java/com/gh/common/iinterface/ISearchToolbarTab.kt index 71e18adfc7..0d558b6857 100644 --- a/app/src/main/java/com/gh/common/iinterface/ISearchToolbarTab.kt +++ b/app/src/main/java/com/gh/common/iinterface/ISearchToolbarTab.kt @@ -5,6 +5,6 @@ import com.gh.gamecenter.entity.BottomTab interface ISearchToolbarTab { fun onScrollChanged(totalHeight: Int, offset: Int, isDarkModeChanged: Boolean) fun changeAppBarColor(color: Int, pageId: String) - fun setSearchStyle(searchStyle: BottomTab.SearchStyle) + fun updateSearchStyle(searchStyle: BottomTab.SearchStyle) fun getCurrentTabIndex(): Int? } \ No newline at end of file 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 13d3e915fb..07ea071720 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 @@ -286,7 +286,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable { if (requireArguments().getString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, "") .isEmpty() && it.topSearch.isNotEmpty() ) { - (parentFragment as? ISearchToolbarTab)?.setSearchStyle(BottomTab.SearchStyle(searchType = it.topSearch)) + (parentFragment as? ISearchToolbarTab)?.updateSearchStyle(BottomTab.SearchStyle(searchType = it.topSearch)) } } diff --git a/app/src/main/java/com/gh/gamecenter/wrapper/BaseTabWrapperFragment.kt b/app/src/main/java/com/gh/gamecenter/wrapper/BaseTabWrapperFragment.kt index 00c0209f8d..eb3847526e 100644 --- a/app/src/main/java/com/gh/gamecenter/wrapper/BaseTabWrapperFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/wrapper/BaseTabWrapperFragment.kt @@ -4,10 +4,9 @@ import android.graphics.Typeface import android.os.Bundle import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup +import android.view.ViewStub import android.widget.LinearLayout import androidx.core.graphics.ColorUtils -import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams import androidx.fragment.app.Fragment import androidx.viewpager.widget.ViewPager @@ -20,8 +19,10 @@ import com.gh.gamecenter.R import com.gh.gamecenter.common.base.adapter.FragmentAdapter import com.gh.gamecenter.common.base.fragment.BaseLazyFragment import com.gh.gamecenter.common.base.fragment.ToolbarFragment -import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.EntranceConsts +import com.gh.gamecenter.common.databinding.ReuseLoadingBinding +import com.gh.gamecenter.common.databinding.ReuseNoConnectionBinding +import com.gh.gamecenter.common.databinding.ReuseNoneDataBinding import com.gh.gamecenter.common.exposure.ExposureSource import com.gh.gamecenter.common.json.json import com.gh.gamecenter.common.utils.* @@ -33,39 +34,40 @@ import com.gh.gamecenter.entity.MultiTabNav import com.gh.gamecenter.fragment.ReloadFragment import com.gh.gamecenter.home.custom.CustomPageFragment import com.google.android.material.tabs.TabLayout -import com.halo.assistant.fragment.WebFragment -import java.util.* import kotlin.math.abs /** * 多Tab导航页 基类 */ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { - protected var mViewPager: ViewPager? = null - protected var mTabLayout: TabLayout? = null - protected var mIndicatorView: TabIndicatorView? = null - protected var mNoneDataContainer: ViewGroup? = null - protected var mNoConnectionContainer: ViewGroup? = null - protected var mLoadingContainer: ViewGroup? = null + protected var viewPager: ViewPager? = null + protected var tabLayout: TabLayout? = null + protected var indicatorView: TabIndicatorView? = null + protected var noDataStub: ViewStub? = null + protected var noConnectionStub: ViewStub? = null + protected var loadingStub: ViewStub? = null + protected var noConnectionBinding: ReuseNoConnectionBinding? = null + protected var noDataBinding: ReuseNoneDataBinding? = null + protected var loadingBinding: ReuseLoadingBinding? = null - protected var mTabBindingList = arrayListOf() - protected var mTabImageStyleList = arrayListOf() + protected var tabBindingList = arrayListOf() + protected var tabImageStyleList = arrayListOf() - protected var mFragmentList = ArrayList() + protected var fragmentList = ArrayList() - protected var mMultiTabNavId = "" - protected var mMultiTabNavName = "" - protected var mBottomTabId = "" - protected var mBottomTabName = "" - protected var mDefaultSelectedTab = -1 - protected var mLastSelectedPosition = 0 + protected var multiTabNavId = "" + protected var multiTabNavName = "" + protected var bottomTabId = "" + protected var bottomTabName = "" + protected var defaultSelectedTab = -1 + protected var lastSelectedPosition = 0 - protected var mBackgroundColor: Int = 0 - protected var mBackgroundWhiteColor: Int = 0 - protected var mAmwayPrimaryColor: Int = 0 - protected var mTabDefaultColor: Int = 0 - protected var mTabSelectedColor: Int = 0 - protected var mTabDefaultLightColor: Int = 0 + protected var backgroundColor: Int = 0 + protected var backgroundWhiteColor: Int = 0 + protected var amwayPrimaryColor: Int = 0 + protected var tabDefaultColor: Int = 0 + protected var tabSelectedColor: Int = 0 + protected var tabDefaultLightColor: Int = 0 abstract fun provideViewModel(): TabWrapperViewModel protected open fun provideTabLayout(): TabLayout? = mCachedView.findViewById(R.id.tabLayout) @@ -76,42 +78,42 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { protected open fun provideTabDefaultColor(): Int = TAB_DEFAULT_COLOR protected open fun provideTabSelectedColor(): Int = TAB_SELECTED_COLOR - override fun provideMultiTabId(): String = mMultiTabNavId - override fun provideMultiTabName(): String = mMultiTabNavName + override fun provideMultiTabId(): String = multiTabNavId + override fun provideMultiTabName(): String = multiTabNavName override fun provideCurrentTabEntity(): MultiTabNav.LinkMultiTabNav? = getCurrentTabEntity() - override fun provideLastSelectedPosition(): Int = mLastSelectedPosition + override fun provideLastSelectedPosition(): Int = lastSelectedPosition override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - savedInstanceState?.let { mDefaultSelectedTab = it.getInt(LAST_SELECTED_POSITION) } - mMultiTabNavId = arguments?.getString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, "") ?: "" - mMultiTabNavName = arguments?.getString(EntranceConsts.KEY_MULTI_TAB_NAV_NAME, "") ?: "" - mBottomTabName = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_NAME, "") ?: "" - mBottomTabId = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_ID, "") ?: "" + savedInstanceState?.let { defaultSelectedTab = it.getInt(LAST_SELECTED_POSITION) } + multiTabNavId = arguments?.getString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, "") ?: "" + multiTabNavName = arguments?.getString(EntranceConsts.KEY_MULTI_TAB_NAV_NAME, "") ?: "" + bottomTabName = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_NAME, "") ?: "" + bottomTabId = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_ID, "") ?: "" } override fun onSaveInstanceState(outState: Bundle) { - mViewPager?.let { outState.putInt(LAST_SELECTED_POSITION, it.currentItem) } + viewPager?.let { outState.putInt(LAST_SELECTED_POSITION, it.currentItem) } super.onSaveInstanceState(outState) } override fun onFragmentFirstVisible() { super.onFragmentFirstVisible() - mNoneDataContainer = mCachedView.findViewById(R.id.reuse_none_data) - mNoConnectionContainer = mCachedView.findViewById(R.id.reuse_no_connection) - mLoadingContainer = mCachedView.findViewById(R.id.reuse_ll_loading) + noDataStub = mCachedView.findViewById(R.id.reuse_no_data_stub) + noConnectionStub = mCachedView.findViewById(R.id.reuse_no_connection_stub) + loadingStub = mCachedView.findViewById(R.id.reuse_loading_stub) - mBackgroundColor = com.gh.gamecenter.common.R.color.ui_background.toColor(requireContext()) - mBackgroundWhiteColor = com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()) - mAmwayPrimaryColor = com.gh.gamecenter.common.R.color.amway_primary_color.toColor(requireContext()) - mTabDefaultColor = provideTabDefaultColor().toColor(requireContext()) - mTabSelectedColor = provideTabSelectedColor().toColor(requireContext()) - mTabDefaultLightColor = TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()) + backgroundColor = com.gh.gamecenter.common.R.color.ui_background.toColor(requireContext()) + backgroundWhiteColor = com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()) + amwayPrimaryColor = com.gh.gamecenter.common.R.color.amway_primary_color.toColor(requireContext()) + tabDefaultColor = provideTabDefaultColor().toColor(requireContext()) + tabSelectedColor = provideTabSelectedColor().toColor(requireContext()) + tabDefaultLightColor = TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()) - if (mMultiTabNavId.isNotEmpty()) { + if (multiTabNavId.isNotEmpty()) { provideViewModel().tabListLiveData.observe(viewLifecycleOwner) { - if (mDefaultSelectedTab == -1) { - mDefaultSelectedTab = provideViewModel().defaultTabPosition + if (defaultSelectedTab == -1) { + defaultSelectedTab = provideViewModel().defaultTabPosition } initViewPager(ArrayList(it)) @@ -121,38 +123,88 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { hideTab() } - mNoneDataContainer?.isVisible = it.isEmpty() - mNoConnectionContainer?.visibility = View.GONE - mLoadingContainer?.visibility = View.GONE + showNoConnection(false) + showLoading(false) + showNoData(it.isEmpty()) } provideViewModel().errorLiveData.observe(viewLifecycleOwner) { - mNoConnectionContainer?.visibility = View.VISIBLE - mLoadingContainer?.visibility = View.GONE - mNoConnectionContainer?.setOnClickListener { - provideViewModel().getMultiTabNav() - mNoConnectionContainer?.visibility = View.GONE - mLoadingContainer?.visibility = View.VISIBLE - } + showLoading(false) + showNoData(false) + showNoConnection(true) } SensorsBridge.trackEvent( "ViewSeveralTabPage", "bottom_tab", - mBottomTabName, + bottomTabName, "several_tab_page_name", - mMultiTabNavName, + multiTabNavName, "several_tab_page_id", - mMultiTabNavId + multiTabNavId ) } } + private fun showNoConnection(show: Boolean) { + if (show) { + if (noConnectionBinding == null) { + noConnectionStub?.setOnInflateListener { _, inflated -> + noConnectionBinding = ReuseNoConnectionBinding.bind(inflated) + noConnectionBinding?.root?.visibility = View.VISIBLE + noConnectionBinding?.connectionReloadTv?.setOnClickListener { + provideViewModel().getMultiTabNav() + showNoData(false) + showNoConnection(false) + showLoading(true) + } + } + noConnectionStub?.inflate() + } else { + noConnectionBinding?.root?.visibility = View.VISIBLE + } + } else { + noConnectionBinding?.root?.visibility = View.GONE + } + } + + private fun showNoData(show: Boolean) { + if (show) { + if (noDataBinding == null) { + noDataStub?.setOnInflateListener { _, inflated -> + noDataBinding = ReuseNoneDataBinding.bind(inflated) + noDataBinding?.root?.visibility = View.VISIBLE + } + noDataStub?.inflate() + } else { + noDataBinding?.root?.visibility = View.VISIBLE + } + } else { + noDataBinding?.root?.visibility = View.GONE + } + } + + private fun showLoading(show: Boolean) { + if (show) { + if (loadingBinding == null) { + loadingStub?.setOnInflateListener { _, inflated -> + loadingBinding = ReuseLoadingBinding.bind(inflated) + loadingBinding?.root?.visibility = View.VISIBLE + } + loadingStub?.inflate() + } else { + loadingBinding?.root?.visibility = View.VISIBLE + } + } else { + loadingBinding?.root?.visibility = View.GONE + } + } + abstract fun hideTab() override fun onBackPressed(): Boolean { - mViewPager?.run { - val currentFragment = mFragmentList.safelyGetInRelease(currentItem) + viewPager?.run { + val currentFragment = fragmentList.safelyGetInRelease(currentItem) if (currentFragment is ToolbarFragment) { return currentFragment.onBackPressed() } @@ -161,16 +213,16 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { } protected open fun initViewPager(tabEntityList: ArrayList) { - mViewPager = provideViewPager() - mTabLayout = provideTabLayout() - mIndicatorView = provideIndicatorView() + viewPager = provideViewPager() + tabLayout = provideTabLayout() + indicatorView = provideIndicatorView() - val fragmentList = generateFragments(tabEntityList).apply { mFragmentList = this } + val fragmentList = generateFragments(tabEntityList).apply { fragmentList = this } val tabTitleList = arrayListOf() tabEntityList.forEach { tabTitleList.add(it.name) } - mViewPager?.run { + viewPager?.run { offscreenPageLimit = fragmentList.size doOnScroll( onPageSelected = { position -> @@ -185,10 +237,10 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { adapter = FragmentAdapter(childFragmentManager, fragmentList, tabTitleList) } - mTabLayout?.setupWithViewPager(mViewPager) - mIndicatorView?.setupWithTabLayout(mTabLayout) - mIndicatorView?.setupWithViewPager(mViewPager) - mIndicatorView?.setIndicatorWidth(provideIndicatorWidth()) + tabLayout?.setupWithViewPager(viewPager) + indicatorView?.setupWithTabLayout(tabLayout) + indicatorView?.setupWithViewPager(viewPager) + indicatorView?.setIndicatorWidth(provideIndicatorWidth()) initTabView(tabEntityList) showTabGuideIfExists(tabEntityList) @@ -199,7 +251,7 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { if (guidePosition != -1) { val tabEntity = tabEntityList[guidePosition] val guide = tabEntity.guide - guide?.bottomTabId = mBottomTabId + guide?.bottomTabId = bottomTabId guide?.multiTabId = tabEntity.id showTabGuide(true, guide, guidePosition) } else { @@ -257,8 +309,8 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { tryCatchInRelease { val field = ViewPager::class.java.getDeclaredField("mRestoredCurItem") field.isAccessible = true - field.set(viewPager, mDefaultSelectedTab) - mLastSelectedPosition = mDefaultSelectedTab + field.set(viewPager, defaultSelectedTab) + lastSelectedPosition = defaultSelectedTab } } @@ -267,7 +319,7 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { */ protected open fun initTabView(tabEntityList: ArrayList) { for (i in 0 until tabEntityList.size) { - val tabView = mTabLayout?.getTabAt(i) ?: continue + val tabView = tabLayout?.getTabAt(i) ?: continue val tabEntity = tabEntityList[i] val tabTitle = if (tabView.text != null) tabView.text.toString() else "" val tabViewBinding = generateTabView(tabTitle) @@ -279,8 +331,8 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { TAB_IMAGE_HIDE_ON_SELECTED } - mTabBindingList.add(tabViewBinding) - mTabImageStyleList.add(tabImageStyle) + tabBindingList.add(tabViewBinding) + tabImageStyleList.add(tabImageStyle) if (tabEntity.img.isNotEmpty()) { tabViewBinding.titleTv.visibility = View.GONE @@ -292,10 +344,10 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { tabViewBinding.titleIv.registerLoadingCallback(object : WrapContentDraweeView.LoadingCallback { override fun loaded() { postRunnable { - mViewPager?.run { + viewPager?.run { // 图片 layout 完成后,更新 tabBar 和 indicatorView 的位置,避免偏移 - mTabLayout?.setScrollPosition(currentItem, 0F, false) - mIndicatorView?.generatePath(currentItem, 0F) + tabLayout?.setScrollPosition(currentItem, 0F, false) + indicatorView?.generatePath(currentItem, 0F) } } } @@ -339,7 +391,7 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { binding.titleTv.run { text = title textSize = provideTabTextSize() - setTextColor(mTabDefaultColor) + setTextColor(tabDefaultColor) } binding.invisibleTitleTv.run { text = title @@ -361,9 +413,9 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { "link_type" to tabEntity.link?.type "link_id" to tabEntity.link?.link "link_text" to tabEntity.link?.text - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId }) } @@ -371,14 +423,14 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { * 安全地从根据 position 获取 fragment */ protected fun getFragment(position: Int): Fragment? { - return if (position < mFragmentList.size) { - mFragmentList.safelyGetInRelease(position) + return if (position < fragmentList.size) { + fragmentList.safelyGetInRelease(position) } else { null } } - protected fun getValidSmartRefreshContent(position: Int? = mViewPager?.currentItem): ISmartRefreshContent? { + protected fun getValidSmartRefreshContent(position: Int? = viewPager?.currentItem): ISmartRefreshContent? { if (position == null) return null val fragment = getFragment(position) return if (fragment?.isAdded == true) fragment as? ISmartRefreshContent else null @@ -395,7 +447,7 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { * @param currentTabSelectedColor tab选中颜色 */ protected open fun updateTabStyle(selectedPosition: Int, positionOffset: Float, currentTabDefaultColor: Int, currentTabSelectedColor: Int) { - if (mTabBindingList.isEmpty()) return + if (tabBindingList.isEmpty()) return val prePosition = selectedPosition - 1 val nextPosition = selectedPosition + 1 @@ -403,8 +455,8 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { // positionOffset 小于零,表示 indicator 当前位置处于选中的 tab 的左边 val indicatorOnLeft = positionOffset < 0F - val selectedTabBinding = mTabBindingList.safelyGetInRelease(selectedPosition) ?: return - val selectedTabImageStyle = mTabImageStyleList.safelyGetInRelease(selectedPosition) ?: return + val selectedTabBinding = tabBindingList.safelyGetInRelease(selectedPosition) ?: return + val selectedTabImageStyle = tabImageStyleList.safelyGetInRelease(selectedPosition) ?: return // 前一个 tab、当前选中的 tab、后一个 tab 的显示比例 val preScaleRatio = 1 + abs(positionOffset) / 4 @@ -413,9 +465,9 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { // 处理前一个 tab if (prePosition != -1) { - mTabBindingList[prePosition].run { + tabBindingList[prePosition].run { if (indicatorOnLeft) { - when (mTabImageStyleList[prePosition]) { + when (tabImageStyleList[prePosition]) { TAB_IMAGE_ALWAYS_ON -> { if (isTabScaleEnabled()) { titleIv.scaleX = preScaleRatio @@ -474,12 +526,12 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { titleTv.visibility = View.VISIBLE invisibleTitleTv.visibility = View.INVISIBLE - mIndicatorView?.visibility = View.VISIBLE + indicatorView?.visibility = View.VISIBLE } } // 选中常驻型的图片时隐藏 indicatorView - mIndicatorView?.goneIf(selectedTabImageStyle == TAB_IMAGE_ALWAYS_ON) + indicatorView?.goneIf(selectedTabImageStyle == TAB_IMAGE_ALWAYS_ON) if (isTabScaleEnabled()) { titleTv.scaleX = selectedScaleRatio @@ -495,10 +547,10 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { } // 处理后一个 tab - if (nextPosition < mTabBindingList.size) { - mTabBindingList[nextPosition].run { + if (nextPosition < tabBindingList.size) { + tabBindingList[nextPosition].run { if (!indicatorOnLeft) { - when (mTabImageStyleList[nextPosition]) { + when (tabImageStyleList[nextPosition]) { TAB_IMAGE_ALWAYS_ON -> { if (isTabScaleEnabled()) { titleIv.scaleX = nextScaleRatio @@ -540,7 +592,7 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { } // 多 tab 切换的时候可能会出现某些 tab 的文字没有回归到原始大小的问题的问题 (positionOffset 不保证连续) - for ((index, binding) in mTabBindingList.withIndex()) { + for ((index, binding) in tabBindingList.withIndex()) { if (index != prePosition && index != selectedPosition && index != nextPosition) { if (binding.titleTv.scaleX != 1F) { binding.titleTv.scaleX = 1F @@ -573,8 +625,8 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { tryWithDefaultCatch { // 补充 Viewpager Fragment 的生命周期, 先调用旧选中 fragment 的 onPause 再当前的 onResume // 避免部分被内嵌的 Fragment 不能正常运作 - if (mFragmentList.size > mLastSelectedPosition) { - val fragment: Fragment = mFragmentList[mLastSelectedPosition] + if (fragmentList.size > lastSelectedPosition) { + val fragment: Fragment = fragmentList[lastSelectedPosition] if (!fragment.isAdded) return fragment.onPause() @@ -584,8 +636,8 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { childFragment.onPause() } } - if (mFragmentList.size > currentSelectedPosition) { - val fragment: Fragment = mFragmentList[currentSelectedPosition] + if (fragmentList.size > currentSelectedPosition) { + val fragment: Fragment = fragmentList[currentSelectedPosition] if (!fragment.isAdded) return fragment.onResume() @@ -595,7 +647,7 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { childFragment.onResume() } } - mLastSelectedPosition = currentSelectedPosition + lastSelectedPosition = currentSelectedPosition } } @@ -610,12 +662,12 @@ abstract class BaseTabWrapperFragment : BaseLazyFragment(), IMultiTab { override fun onDarkModeChanged() { super.onDarkModeChanged() - mBackgroundColor = com.gh.gamecenter.common.R.color.ui_background.toColor(requireContext()) - mBackgroundWhiteColor = com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()) - mAmwayPrimaryColor = com.gh.gamecenter.common.R.color.amway_primary_color.toColor(requireContext()) - mTabDefaultColor = provideTabDefaultColor().toColor(requireContext()) - mTabSelectedColor = provideTabSelectedColor().toColor(requireContext()) - mTabDefaultLightColor = TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()) + backgroundColor = com.gh.gamecenter.common.R.color.ui_background.toColor(requireContext()) + backgroundWhiteColor = com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()) + amwayPrimaryColor = com.gh.gamecenter.common.R.color.amway_primary_color.toColor(requireContext()) + tabDefaultColor = provideTabDefaultColor().toColor(requireContext()) + tabSelectedColor = provideTabSelectedColor().toColor(requireContext()) + tabDefaultLightColor = TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()) } companion object { diff --git a/app/src/main/java/com/gh/gamecenter/wrapper/MainFragmentStateAdapter.kt b/app/src/main/java/com/gh/gamecenter/wrapper/MainFragmentStateAdapter.kt index 8b31c62f2a..1de9c57e6f 100644 --- a/app/src/main/java/com/gh/gamecenter/wrapper/MainFragmentStateAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/wrapper/MainFragmentStateAdapter.kt @@ -38,7 +38,7 @@ class MainFragmentStateAdapter(private val mFragment: Fragment) : BaseDiffFragme return if (data.link == null) { ReloadFragment() } else { - when (data.link!!.type) { + when (data.link.type) { ViewPagerFragmentHelper.TYPE_CUSTOM_PAGE -> { bundle.putParcelable(LinkEntity::class.java.simpleName, data.link) SearchToolbarTabWrapperFragment().setSuperiorChain(superiorChain).apply { arguments = bundle } @@ -46,12 +46,12 @@ class MainFragmentStateAdapter(private val mFragment: Fragment) : BaseDiffFragme ViewPagerFragmentHelper.TYPE_MULTI_TAB_NAV -> { bundle.putParcelable(BottomTab.SearchStyle::class.java.simpleName, data.searchStyle) - bundle.putString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, data.link!!.link) - bundle.putString(EntranceConsts.KEY_MULTI_TAB_NAV_NAME, data.link!!.text) + bundle.putString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, data.link.link) + bundle.putString(EntranceConsts.KEY_MULTI_TAB_NAV_NAME, data.link.text) SearchToolbarTabWrapperFragment().setSuperiorChain(superiorChain).apply { arguments = bundle } } - else -> ViewPagerFragmentHelper.createFragment(mFragment, bundle, data.link!!, false) + else -> ViewPagerFragmentHelper.createFragment(mFragment, bundle, data.link, false) } } } diff --git a/app/src/main/java/com/gh/gamecenter/wrapper/SearchToolbarTabWrapperFragment.kt b/app/src/main/java/com/gh/gamecenter/wrapper/SearchToolbarTabWrapperFragment.kt index da15fb1821..e8f9488da5 100644 --- a/app/src/main/java/com/gh/gamecenter/wrapper/SearchToolbarTabWrapperFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/wrapper/SearchToolbarTabWrapperFragment.kt @@ -45,11 +45,13 @@ import com.gh.gamecenter.common.exposure.ExposureSource import com.gh.gamecenter.common.json.json import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.common.view.TabIndicatorView +import com.gh.gamecenter.core.iinterface.IScrollable import com.gh.gamecenter.core.utils.DisplayUtils import com.gh.gamecenter.core.utils.MD5Utils import com.gh.gamecenter.core.utils.SPUtils import com.gh.gamecenter.core.utils.TimeElapsedHelper import com.gh.gamecenter.databinding.FragmentSearchToolbarTabWrapperBinding +import com.gh.gamecenter.databinding.LayoutAutoVideoViewBinding import com.gh.gamecenter.entity.BottomTab import com.gh.gamecenter.entity.GameUpdateEntity import com.gh.gamecenter.entity.MultiTabNav @@ -61,6 +63,7 @@ import com.gh.gamecenter.feature.exposure.time.TimeUtil import com.gh.gamecenter.feature.game.GameItemViewHolder import com.gh.gamecenter.gamecollection.square.GameCollectionSquareFragment import com.gh.gamecenter.home.custom.CustomPageFragment +import com.gh.gamecenter.home.video.AutomaticVideoView import com.gh.gamecenter.home.video.ScrollCalculatorHelper import com.gh.gamecenter.message.MessageUnreadViewModel import com.gh.gamecenter.packagehelper.PackageViewModel @@ -91,74 +94,76 @@ import kotlin.math.roundToInt */ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbarTab, ISmartRefresh, ISuperiorChain { - private lateinit var mBinding: FragmentSearchToolbarTabWrapperBinding + private lateinit var binding: FragmentSearchToolbarTabWrapperBinding - private val mViewModel: SearchToolbarTabWrapperViewModel by lazy { + private val viewModel: SearchToolbarTabWrapperViewModel by lazy { viewModelProviderFromParent( - SearchToolbarTabWrapperViewModel.Factory(mMultiTabNavId, mNoTabLinkEntity?.link ?: ""), - mMultiTabNavId + SearchToolbarTabWrapperViewModel.Factory(multiTabNavId, noTabLinkEntity?.link ?: ""), + multiTabNavId ) } - private var mDownloadHintTv: TextView? = null - private var mSearchHintTv: TextView? = null - private var mSearchContainerView: View? = null - private var mDownloadView: View? = null - private var mMessageUnread: TextView? = null - private var mSearchRightView: ImageView? = null - private var mTeenagerModelView: View? = null + private var downloadHintTv: TextView? = null + private var searchHintTv: TextView? = null + private var searchContainerView: View? = null + private var downloadView: View? = null + private var messageUnread: TextView? = null + private var searchRightView: ImageView? = null + private var teenagerModelView: View? = null - private var mCurrentAppBarColor: Int = 0 - private var mCurrentTabSelectedColor: Int = 0 - private var mCurrentTabDefaultColor: Int = 0 - private var mCurrentIndicatorDrawable: Int = 0 + private var currentAppBarColor: Int = 0 + private var currentTabSelectedColor: Int = 0 + private var currentTabDefaultColor: Int = 0 + private var currentIndicatorDrawable: Int = 0 - private var mMainWrapperViewModel: MainWrapperViewModel? = null - private val mUnreadViewModel: MessageUnreadViewModel by lazy { + private var mainWrapperViewModel: MainWrapperViewModel? = null + private val unreadViewModel: MessageUnreadViewModel by lazy { viewModelProvider( MessageUnreadViewModel.Factory( HaloApp.getInstance().application ) ) } - private val mPackageViewModel: PackageViewModel by lazy { viewModelProvider(PackageViewModel.Factory()) } - private lateinit var mElapsedHelper: TimeElapsedHelper + private val packageViewModel: PackageViewModel by lazy { viewModelProvider(PackageViewModel.Factory()) } + private lateinit var elapsedHelper: TimeElapsedHelper - private var mStyle = Style.TWO_LINES_TAB + private var style = Style.TWO_LINES_TAB - private val mStatusBarHeight by lazy { DisplayUtils.getStatusBarHeight(requireContext().resources) } - private var mIsDisplayingLightContent = false - private var mOffsetCritical = 0.7F - private var mPullDownPushAction = "" // 触发行为(主动展开/自动展开) - private var mShowTwoLevel = false - private var mIsDragging = false - private var mPullDownPushClick = false - private var mFinishingTwoLevel = false - private var mHeaderOffset = 0 - private var mClipChildren = true - private var mTwoLevelOpenOffset = 0 - private var mTwoLevelOpenCount = 0 - private var mShowTwoLevelStartOffset = 0 - private var mPullDownPush: PullDownPush? = null - private var mPullDownPushExposureEvent: ExposureEvent? = null - private var mGameViewHolder: GameViewHolder? = null + private val statusBarHeight by lazy { DisplayUtils.getStatusBarHeight(requireContext().resources) } + private var isDisplayingLightContent = false + private var offsetCritical = 0.7F + private var pullDownPushAction = "" // 触发行为(主动展开/自动展开) + private var showTwoLevel = false + private var isDragging = false + private var pullDownPushClick = false + private var finishingTwoLevel = false + private var headerOffset = 0 + private var clipChildren = true + private var twoLevelOpenOffset = 0 + private var twoLevelOpenCount = 0 + private var showTwoLevelStartOffset = 0 + private var pullDownPush: PullDownPush? = null + private var pullDownPushExposureEvent: ExposureEvent? = null + private var gameViewHolder: GameViewHolder? = null - private var mNoTabLinkEntity: LinkEntity? = null - private var mLightStatusBar: Boolean? = null - private var mLightSearchToolbarStyle: Boolean? = null - private var mLightRefreshHeaderStyle: Boolean? = null + private var noTabLinkEntity: LinkEntity? = null + private var lightStatusBar: Boolean? = null + private var lightSearchToolbarStyle: Boolean? = null + private var lightRefreshHeaderStyle: Boolean? = null - private var mInferiorChain: PriorityChain? = null - private val mPriorityChain by lazy { PriorityChain { mInferiorChain?.start() } } - private var mSuperiorChain: ISuperiorChain? = null - private var mAutoFinishTwoLevelHandler: Handler? = null - private var mAutoFinishTwoLevelCallback: (() -> Unit)? = null - private val mMultiTabGuideHandler by lazy { MultiTabGuideHandler(24) } + private var inferiorChain: PriorityChain? = null + private val priorityChain by lazy { PriorityChain { inferiorChain?.start() } } + private var superiorChain: ISuperiorChain? = null + private var autoFinishTwoLevelHandler: Handler? = null + private var autoFinishTwoLevelCallback: (() -> Unit)? = null + private val multiTabGuideHandler by lazy { MultiTabGuideHandler(24) } - private val mSingleLineTabToolbarHeight = 56F.dip2px() - private val mTwoLinesTabToolbarHeight = 48F.dip2px() + private val singleLineTabToolbarHeight = 56F.dip2px() + private val twoLinesTabToolbarHeight = 48F.dip2px() - private var mSearchStyle: BottomTab.SearchStyle? = null + private var autoVideoView: AutomaticVideoView? = null + + private var searchStyle: BottomTab.SearchStyle? = null set(value) { field = value setSearchHint() @@ -166,7 +171,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar private val dataWatcher = object : DataWatcher() { override fun onDataChanged(downloadEntity: DownloadEntity) { - if (downloadEntity.gameId == mPullDownPush?.game?.id) { + if (downloadEntity.gameId == pullDownPush?.game?.id) { updatePullDownPushDownloadBtn() } } @@ -177,87 +182,87 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } override fun getLayoutId(): Int = 0 - override fun provideViewModel(): TabWrapperViewModel = mViewModel + override fun provideViewModel(): TabWrapperViewModel = viewModel override fun provideTabLayout(): TabLayout? { - return if (mStyle == Style.SINGLE_LINE_TAB) { - mBinding.tabSearchToolbar.tabLayout + return if (style == Style.SINGLE_LINE_TAB) { + binding.tabSearchToolbar.tabLayout } else { super.provideTabLayout() } } override fun provideIndicatorView(): TabIndicatorView? { - return if (mStyle == Style.SINGLE_LINE_TAB) { - mBinding.tabSearchToolbar.indicatorView + return if (style == Style.SINGLE_LINE_TAB) { + binding.tabSearchToolbar.indicatorView } else { super.provideIndicatorView() } } - private fun getToolbarHeight() = if (mStyle == Style.SINGLE_LINE_TAB) mSingleLineTabToolbarHeight else mTwoLinesTabToolbarHeight + private fun getToolbarHeight() = if (style == Style.SINGLE_LINE_TAB) singleLineTabToolbarHeight else twoLinesTabToolbarHeight override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - mNoTabLinkEntity = arguments?.getParcelable(LinkEntity::class.java.simpleName) - mSearchStyle = arguments?.getParcelable(BottomTab.SearchStyle::class.java.simpleName) ?: BottomTab.SearchStyle() - if (mSearchStyle?.styleType == BottomTab.SearchStyle.STYLE_APPOSITION) { - mStyle = Style.SINGLE_LINE_TAB - } else if (mMultiTabNavId.isEmpty() && mNoTabLinkEntity != null) { - mStyle = Style.NO_TAB + noTabLinkEntity = arguments?.getParcelable(LinkEntity::class.java.simpleName) + searchStyle = arguments?.getParcelable(BottomTab.SearchStyle::class.java.simpleName) ?: BottomTab.SearchStyle() + if (searchStyle?.styleType == BottomTab.SearchStyle.STYLE_APPOSITION) { + style = Style.SINGLE_LINE_TAB + } else if (multiTabNavId.isEmpty() && noTabLinkEntity != null) { + style = Style.NO_TAB } } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - mBinding = FragmentSearchToolbarTabWrapperBinding.inflate(layoutInflater) - mCachedView = mBinding.root + binding = FragmentSearchToolbarTabWrapperBinding.inflate(layoutInflater) + mCachedView = binding.root return mCachedView } private fun initSearchToolbar() { - mBinding.contentBgView.isVisible = mStyle != Style.TWO_LINES_TAB - mBinding.tabContainer.isVisible = mStyle == Style.TWO_LINES_TAB + binding.contentBgView.isVisible = style != Style.TWO_LINES_TAB + binding.tabContainer.isVisible = style == Style.TWO_LINES_TAB val showDownload = Config.isShow() - if (mStyle == Style.SINGLE_LINE_TAB) { - mBinding.tabSearchToolbar.root.visibility = View.VISIBLE - mDownloadHintTv = mBinding.tabSearchToolbar.menuDownloadCountHint - mSearchHintTv = mBinding.tabSearchToolbar.searchTv - mSearchContainerView = mBinding.tabSearchToolbar.searchContainer - mDownloadView = mBinding.tabSearchToolbar.downloadContainer + if (style == Style.SINGLE_LINE_TAB) { + binding.tabSearchToolbar.root.visibility = View.VISIBLE + downloadHintTv = binding.tabSearchToolbar.menuDownloadCountHint + searchHintTv = binding.tabSearchToolbar.searchTv + searchContainerView = binding.tabSearchToolbar.searchContainer + downloadView = binding.tabSearchToolbar.downloadContainer - mBinding.collapsingToolbar.updateLayoutParams { + binding.collapsingToolbar.updateLayoutParams { scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL } - mBinding.tabSearchToolbar.searchContainer.setOnClickListener(this) - mBinding.tabSearchToolbar.downloadContainer.setOnClickListener(this) + binding.tabSearchToolbar.searchContainer.setOnClickListener(this) + binding.tabSearchToolbar.downloadContainer.setOnClickListener(this) } else { - mBinding.searchToolbar.root.visibility = View.VISIBLE - mDownloadHintTv = mBinding.searchToolbar.actionTip - mSearchHintTv = mBinding.searchToolbar.actionbarSearchInput - mSearchContainerView = mBinding.searchToolbar.actionbarSearchRl - mDownloadView = mBinding.searchToolbar.actionbarRlDownload - mMessageUnread = mBinding.searchToolbar.messageUnreadHint - mSearchRightView = mBinding.searchToolbar.actionbarSearchRight - mTeenagerModelView = mBinding.searchToolbar.actionbarTeenagerModel + binding.searchToolbar.root.visibility = View.VISIBLE + downloadHintTv = binding.searchToolbar.actionTip + searchHintTv = binding.searchToolbar.actionbarSearchInput + searchContainerView = binding.searchToolbar.actionbarSearchRl + downloadView = binding.searchToolbar.actionbarRlDownload + messageUnread = binding.searchToolbar.messageUnreadHint + searchRightView = binding.searchToolbar.actionbarSearchRight + teenagerModelView = binding.searchToolbar.actionbarTeenagerModel - mTeenagerModelView?.isVisible = !showDownload - mSearchContainerView?.isVisible = showDownload - mSearchRightView?.isVisible = !showDownload + teenagerModelView?.isVisible = !showDownload + searchContainerView?.isVisible = showDownload + searchRightView?.isVisible = !showDownload - mDownloadView?.setOnClickListener(this) - mBinding.searchToolbar.actionbarNotification.setOnClickListener(this) - mBinding.searchToolbar.actionbarSearchRl.setOnClickListener(this) - mTeenagerModelView?.setOnClickListener(this) - mSearchHintTv?.setOnClickListener(this) - mSearchRightView?.setOnClickListener(this) + downloadView?.setOnClickListener(this) + binding.searchToolbar.actionbarNotification.setOnClickListener(this) + binding.searchToolbar.actionbarSearchRl.setOnClickListener(this) + teenagerModelView?.setOnClickListener(this) + searchHintTv?.setOnClickListener(this) + searchRightView?.setOnClickListener(this) } - mDownloadView?.isVisible = showDownload - mDownloadHintTv?.typeface = Typeface.createFromAsset(requireContext().assets, Constants.DIN_FONT_PATH) - mMessageUnread?.typeface = Typeface.createFromAsset(requireContext().assets, Constants.DIN_FONT_PATH) - mPackageViewModel.filterSameUpdateLiveData.observe(this) { updateList: List -> + downloadView?.isVisible = showDownload + downloadHintTv?.typeface = Typeface.createFromAsset(requireContext().assets, Constants.DIN_FONT_PATH) + messageUnread?.typeface = Typeface.createFromAsset(requireContext().assets, Constants.DIN_FONT_PATH) + packageViewModel.filterSameUpdateLiveData.observe(this) { updateList: List -> setDownloadHint(updateList) } - mUnreadViewModel.messageCenterUnreadCountLiveData.observe(this) { unreadCount: Int -> + unreadViewModel.messageCenterUnreadCountLiveData.observe(this) { unreadCount: Int -> setMessageUnread(unreadCount) } @@ -265,7 +270,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } private fun setDownloadHint(updateList: List) { - mDownloadHintTv?.also { + downloadHintTv?.also { val count = DownloadManager.getInstance().getDownloadOrUpdateCount(updateList) it.goneIf(count == null) { it.text = count!! @@ -275,13 +280,13 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } private fun setMessageUnread(unreadCount: Int) { - mMessageUnread?.isVisible = unreadCount != 0 + messageUnread?.isVisible = unreadCount != 0 if (unreadCount == -1) { - mMessageUnread?.text = "" - mMessageUnread?.also { setHintLayoutParams(it, true) } + messageUnread?.text = "" + messageUnread?.also { setHintLayoutParams(it, true) } } else { - mMessageUnread?.also { BindingAdapters.setMessageUnread(it, unreadCount) } - mMessageUnread?.also { setHintLayoutParams(it, false) } + messageUnread?.also { BindingAdapters.setMessageUnread(it, unreadCount) } + messageUnread?.also { setHintLayoutParams(it, false) } } } @@ -307,15 +312,15 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar private fun setSearchHint() { if (isSupportVisible) { - when (mSearchStyle?.searchType) { + when (searchStyle?.searchType) { BottomTab.SearchStyle.TYPE_HALO_GAME -> { - mSearchHintTv?.let { DefaultSearchHintHelper.setSearchHint(it) } + searchHintTv?.let { DefaultSearchHintHelper.setSearchHint(it) } } BottomTab.SearchStyle.TYPE_MINI_GAME -> { - mSearchHintTv?.hint = if (mSearchStyle?.styleType == BottomTab.SearchStyle.STYLE_APPOSITION) "搜索" else "请输入小游戏关键词" + searchHintTv?.hint = if (searchStyle?.styleType == BottomTab.SearchStyle.STYLE_APPOSITION) "搜索" else "请输入小游戏关键词" } BottomTab.SearchStyle.TYPE_BBS -> { - mSearchHintTv?.hint = if (mSearchStyle?.styleType == BottomTab.SearchStyle.STYLE_APPOSITION) "搜索" else "搜索论坛内容、用户" + searchHintTv?.hint = if (searchStyle?.styleType == BottomTab.SearchStyle.STYLE_APPOSITION) "搜索" else "搜索论坛内容、用户" } } } @@ -329,9 +334,9 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar DirectUtils.directToDownloadManager( requireContext(), "底部tab", - mBottomTabName, - multiTabName = mMultiTabNavName, - multiTabId = mMultiTabNavId + bottomTabName, + multiTabName = multiTabNavName, + multiTabId = multiTabNavId ) } @@ -343,13 +348,13 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar val searchBoxPattern = if (v.id == R.id.searchIv) "靠右" else "置顶且展开" DirectUtils.directToSearch( requireContext(), - mSearchStyle?.searchType ?: "halo_game", - mSearchHintTv?.hint.toString(), + searchStyle?.searchType ?: "halo_game", + searchHintTv?.hint.toString(), "搜索栏", "多tab导航页", - mBottomTabName, - multiTabId = mMultiTabNavId, - multiTabName = mMultiTabNavName, + bottomTabName, + multiTabId = multiTabNavId, + multiTabName = multiTabNavName, searchBoxPattern = searchBoxPattern ) } @@ -358,14 +363,14 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar DataCollectionUtils.uploadClick(activity, "消息图标", "主页") CheckLoginUtils.checkLogin(requireContext(), "(工具栏)") { NewLogUtils.logMessageInformBellClick( - mMessageUnread?.visibility == View.VISIBLE, + messageUnread?.visibility == View.VISIBLE, "首页" ) SensorsBridge.trackMessageCenterClick() // 优先进入有数字提醒的消息tab,其次是有红点提醒的游戏动态,最后是没有提醒的消息tab var defaultTabIndex = 1 - val messageUnreadCount = mUnreadViewModel.messageUnreadCountLiveData.value - val isConcernUnread = mUnreadViewModel.zixunConcernLiveData.value + val messageUnreadCount = unreadViewModel.messageUnreadCountLiveData.value + val isConcernUnread = unreadViewModel.zixunConcernLiveData.value if ((messageUnreadCount == null || messageUnreadCount.message < 1) && isConcernUnread == true) { defaultTabIndex = 0 } @@ -381,42 +386,42 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar override fun onFragmentFirstVisible() { super.onFragmentFirstVisible() - mMainWrapperViewModel = viewModelProviderFromParent(MainWrapperViewModel.Factory(HaloApp.getInstance())) - mElapsedHelper = TimeElapsedHelper() + mainWrapperViewModel = viewModelProviderFromParent(MainWrapperViewModel.Factory(HaloApp.getInstance())) + elapsedHelper = TimeElapsedHelper() initSearchToolbar() buildPriorityChain() // 记录 appBarOffset 供其它子页面使用 - mBinding.appbar.addOnOffsetChangedListener { _, verticalOffset -> - mViewModel.appBarOffset = abs(verticalOffset) + binding.appbar.addOnOffsetChangedListener { _, verticalOffset -> + viewModel.appBarOffset = abs(verticalOffset) } - mBinding.searchIv.setOnClickListener(this) - mBinding.collapsingToolbar.scrimShownAction = { - if (mBinding.searchIv.isVisible != it) { - mBinding.searchIv.isVisible = it - mBinding.indicatorView.post { - mBinding.indicatorView.generatePath(mBinding.viewPager.currentItem, 0F) + binding.searchIv.setOnClickListener(this) + binding.collapsingToolbar.scrimShownAction = { + if (binding.searchIv.isVisible != it) { + binding.searchIv.isVisible = it + binding.indicatorView.post { + binding.indicatorView.generatePath(binding.viewPager.currentItem, 0F) } } } initSmartRefresh() - if (mStyle == Style.NO_TAB) { - (mBinding.collapsingToolbar.layoutParams as? AppBarLayout.LayoutParams)?.let { lp -> + if (style == Style.NO_TAB) { + (binding.collapsingToolbar.layoutParams as? AppBarLayout.LayoutParams)?.let { lp -> lp.scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL } initNoTabViewPager() } - mViewModel.tabSelectLiveData.observe(viewLifecycleOwner) { + viewModel.tabSelectLiveData.observe(viewLifecycleOwner) { val selectTab = it.getContentWithHandled() if (selectTab is MainSelectedEvent.SelectedTab) { if (selectTab.topTabIndex != -1) { - mViewPager?.doOnLayout { - mViewPager?.setCurrentItem(selectTab.topTabIndex, false) + viewPager?.doOnLayout { + viewPager?.setCurrentItem(selectTab.topTabIndex, false) } } } @@ -424,14 +429,14 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } override fun hideTab() { - mBinding.tabContainer.visibility = View.GONE - (mBinding.collapsingToolbar.layoutParams as? AppBarLayout.LayoutParams)?.let { lp -> + binding.tabContainer.visibility = View.GONE + (binding.collapsingToolbar.layoutParams as? AppBarLayout.LayoutParams)?.let { lp -> lp.scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL } } fun setSuperiorChain(superiorChain: ISuperiorChain?): SearchToolbarTabWrapperFragment { - this.mSuperiorChain = superiorChain + this.superiorChain = superiorChain return this } @@ -442,18 +447,18 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar */ private fun buildPriorityChain() { val accelerateNotificationHandler = AccelerateNotificationHandler(21) - mPriorityChain.addHandler(accelerateNotificationHandler) + priorityChain.addHandler(accelerateNotificationHandler) - mMainWrapperViewModel?.accelerateNotificationPopup?.observe(this) { + mainWrapperViewModel?.accelerateNotificationPopup?.observe(this) { - if (mPriorityChain.isHandlerQueueEmpty()) { + if (priorityChain.isHandlerQueueEmpty()) { if (it == null) return@observe val accelerateSet = HashSet(SPUtils.getStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET)) if (it.isNotEmpty() && !accelerateSet.contains(it[0].messageId)) { AccelerateNotificationHandler.showAccelerateNotificationPopupWindow( requireActivity(), - mMainWrapperViewModel, + mainWrapperViewModel, mBaseHandler as BaseHandler, it[0], null @@ -466,66 +471,66 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar requireActivity(), mBaseHandler, it, - mMainWrapperViewModel!! + mainWrapperViewModel!! ) } } - if (mSuperiorChain != null) { - mSuperiorChain?.registerInferiorChain(mPriorityChain) + if (superiorChain != null) { + superiorChain?.registerInferiorChain(priorityChain) } else { - mPriorityChain.start() + priorityChain.start() } } private fun initNoTabViewPager() { - mFragmentList.clear() - mViewPager = provideViewPager() - mLoadingContainer?.visibility = View.GONE - mNoTabLinkEntity?.let { + fragmentList.clear() + viewPager = provideViewPager() + loadingStub?.visibility = View.GONE + noTabLinkEntity?.let { if (it.type == ViewPagerFragmentHelper.TYPE_CUSTOM_PAGE) { val bundle = Bundle() bundle.putAll(arguments) bundle.putString(EntranceConsts.KEY_CUSTOM_PAGE_ID, it.link) bundle.putString(EntranceConsts.KEY_CUSTOM_PAGE_NAME, it.text) - mFragmentList.add(CustomPageFragment().setSuperiorChain(this).with(bundle)) + fragmentList.add(CustomPageFragment().setSuperiorChain(this).with(bundle)) } } - mViewPager?.run { - offscreenPageLimit = mFragmentList.size - mDefaultSelectedTab = 0 + viewPager?.run { + offscreenPageLimit = fragmentList.size + defaultSelectedTab = 0 setRestoredCurItem(this) - adapter = FragmentAdapter(childFragmentManager, mFragmentList) + adapter = FragmentAdapter(childFragmentManager, fragmentList) } } private fun initSmartRefresh() { - mBinding.run { - mGameViewHolder = GameViewHolder(headerContainer).also { + binding.run { + gameViewHolder = GameViewHolder(headerContainer).also { it.gameDownloadBtn = downloadBtn it.multiVersionDownloadTv = multiVersionDownloadTv it.gameDownloadTips = downloadTipsLottie } topMaskView.updateLayoutParams { - height = mStatusBarHeight + getToolbarHeight() + height = statusBarHeight + getToolbarHeight() } - mTwoLevelOpenOffset = DisplayUtils.getScreenWidth() - getToolbarHeight() - mStatusBarHeight - mShowTwoLevelStartOffset = 139F.dip2px() - mStatusBarHeight + twoLevelOpenOffset = DisplayUtils.getScreenWidth() - getToolbarHeight() - statusBarHeight + showTwoLevelStartOffset = 139F.dip2px() - statusBarHeight classicsHeader.setArrowResource(R.drawable.icon_arrow) statusBar.post { twoLevelHeader.updateLayoutParams { - topMargin = -(mStatusBarHeight + getToolbarHeight()) + topMargin = -(statusBarHeight + getToolbarHeight()) } } - refreshLayout.setFloorHeight(DisplayUtils.getScreenWidth() - getToolbarHeight() - mStatusBarHeight) + refreshLayout.setFloorHeight(DisplayUtils.getScreenWidth() - getToolbarHeight() - statusBarHeight) refreshLayout.setOnMultiPurposeListener(object : SimpleMultiPurposeListener() { override fun onRefresh(refreshLayout: RefreshLayout) { val currentTabEntity = getCurrentTabEntity() SensorsBridge.trackEvent("CustomPageFlush", json { - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -541,10 +546,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar headerHeight: Int, maxDragHeight: Int ) { - mIsDragging = isDragging - mHeaderOffset = offset + this@SearchToolbarTabWrapperFragment.isDragging = isDragging + headerOffset = offset updateStyleOnHeaderMoving(offset) - headerContainer.translationY = -(mTwoLevelOpenOffset - offset).toFloat() + headerContainer.translationY = -(twoLevelOpenOffset - offset).toFloat() } override fun onStateChanged( @@ -561,10 +566,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar val isFinishTwoLevel = oldState == RefreshState.TwoLevel && newState == RefreshState.TwoLevelFinish val currentTabEntity = getCurrentTabEntity() - mPullDownPush?.run { + pullDownPush?.run { if (isAutoScrollToTwoLevel) { - mPullDownPushAction = "自动展开" - mTwoLevelOpenCount++ + pullDownPushAction = "自动展开" + twoLevelOpenCount++ SensorsBridge.trackEvent( "DropDownPushShow", json { @@ -572,10 +577,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar "drop_down_push_id" to id "game_name" to game?.name "game_id" to game?.id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -584,13 +589,13 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar com.gh.common.util.NewFlatLogUtils.logHomePushShow( id, "自动展开", - mTwoLevelOpenCount, + twoLevelOpenCount, game?.id ?: "", game?.name ?: "" ) } if (isShowTwoLevelByDrag) { - mPullDownPushAction = "主动展开" + pullDownPushAction = "主动展开" SensorsBridge.trackEvent( "DropDownPushShow", json { @@ -598,10 +603,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar "drop_down_push_id" to id "game_name" to game?.name "game_id" to game?.id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -610,13 +615,13 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar com.gh.common.util.NewFlatLogUtils.logHomePushShow( id, "主动展开", - mTwoLevelOpenCount, + twoLevelOpenCount, game?.id ?: "", game?.name ?: "" ) } if (isDragToTwoLevel) { - mTwoLevelOpenCount++ + twoLevelOpenCount++ SensorsBridge.trackEvent( "DropDownPushTrigger", @@ -624,10 +629,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar "drop_down_push_id" to id "game_name" to game?.name "game_id" to game?.id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -635,7 +640,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar ) com.gh.common.util.NewFlatLogUtils.logHomePushTrigger( id, - mTwoLevelOpenCount, + twoLevelOpenCount, game?.id ?: "", game?.name ?: "" ) @@ -643,30 +648,30 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } if (isScrollToTwoLevel) { - mShowTwoLevel = true + showTwoLevel = true refreshStatusBarStyle() } if (isFinishTwoLevel) { pausePullDownPushVideo() - mShowTwoLevel = false + showTwoLevel = false - if (mIsDragging) { - mAutoFinishTwoLevelHandler?.removeMessages(KEY_AUTO_FINISH_TWO_LEVEL) - mElapsedHelper.pauseCounting() - mPullDownPush?.run { + if (isDragging) { + autoFinishTwoLevelHandler?.removeMessages(KEY_AUTO_FINISH_TWO_LEVEL) + elapsedHelper.pauseCounting() + pullDownPush?.run { SensorsBridge.trackEvent( "DropDownPushClick", json { - "action" to mPullDownPushAction + "action" to pullDownPushAction "button_name" to "关闭推送" "drop_down_push_id" to id "game_name" to game?.name "game_id" to game?.id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -675,10 +680,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar com.gh.common.util.NewFlatLogUtils.logHomePushClose( id, "主动收起", - mTwoLevelOpenCount, + twoLevelOpenCount, game?.id ?: "", game?.name ?: "", - mElapsedHelper.elapsedTime + elapsedHelper.elapsedTime ) } } @@ -687,38 +692,38 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar when (newState) { RefreshState.TwoLevel -> { getValidSmartRefreshContent()?.setScrollEnabled(false) - mBinding.refreshLayout.isDisableContent = false + binding.refreshLayout.isDisableContent = false } RefreshState.None -> { getValidSmartRefreshContent()?.setScrollEnabled(true) - mShowTwoLevel = false - mIsDragging = false + showTwoLevel = false + isDragging = false twoLevelHeader.setFloorDuration(1000) - mBinding.refreshLayout.setFloorDuration(1000) + binding.refreshLayout.setFloorDuration(1000) classicsHeader.visibility = View.VISIBLE } RefreshState.PullDownToRefresh -> { - mShowTwoLevel = false - mBinding.classicsHeader.updateLayoutParams { - topMargin = getToolbarHeight() + mStatusBarHeight - 59F.dip2px() + showTwoLevel = false + binding.classicsHeader.updateLayoutParams { + topMargin = getToolbarHeight() + statusBarHeight - 59F.dip2px() } } RefreshState.PullDownCanceled, - RefreshState.ReleaseToRefresh -> mShowTwoLevel = false + RefreshState.ReleaseToRefresh -> showTwoLevel = false else -> { // do nothing } } - val clipChildren: Boolean + val clipChildrenTemp: Boolean when (newState) { RefreshState.TwoLevel, RefreshState.TwoLevelFinish -> { - clipChildren = false + clipChildrenTemp = false toolbarBackground.alpha = 0F statusBarBackground.alpha = 0F contentContainer.radius = 8F.dip2px().toFloat() @@ -726,7 +731,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar RefreshState.ReleaseToTwoLevel, RefreshState.TwoLevelReleased -> { - clipChildren = false + clipChildrenTemp = false toolbarBackground.alpha = 0F statusBarBackground.alpha = 0F headerBackground.alpha = 0F @@ -734,7 +739,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } else -> { - clipChildren = true + clipChildrenTemp = true toolbarBackground.alpha = 1F statusBarBackground.alpha = 1F headerBackground.alpha = 1F @@ -742,23 +747,23 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } } - if (mClipChildren != clipChildren) { - mClipChildren = clipChildren - wrapperLl.clipChildren = mClipChildren - mBinding.refreshLayout.clipChildren = mClipChildren + if (clipChildren != clipChildrenTemp) { + clipChildren = clipChildrenTemp + wrapperLl.clipChildren = clipChildren + binding.refreshLayout.clipChildren = clipChildren } } }) twoLevelHeader.setOnTwoLevelListener { - mPullDownPushExposureEvent?.timeInMillisecond = System.currentTimeMillis() - mPullDownPushExposureEvent?.time = TimeUtil.currentTime() - mPullDownPushExposureEvent?.payload?.sequence = mTwoLevelOpenCount - mPullDownPushExposureEvent?.let { + pullDownPushExposureEvent?.timeInMillisecond = System.currentTimeMillis() + pullDownPushExposureEvent?.time = TimeUtil.currentTime() + pullDownPushExposureEvent?.payload?.sequence = twoLevelOpenCount + pullDownPushExposureEvent?.let { ExposureManager.log(it) } - mElapsedHelper.resetCounting() - mElapsedHelper.resumeCounting() + elapsedHelper.resetCounting() + elapsedHelper.resumeCounting() playPullDownPushVideo() true } @@ -766,9 +771,9 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } private fun updatePullDownPushDownloadBtn() { - mBinding.run { - mPullDownPush?.game?.run { - mGameViewHolder?.let { + binding.run { + pullDownPush?.game?.run { + gameViewHolder?.let { DownloadItemUtils.updateItem(requireContext(), this, it) } DownloadItemUtils.setOnClickListener( @@ -779,22 +784,22 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar null, "自定义页面-下拉推送", location = "", - traceEvent = mPullDownPushExposureEvent, + traceEvent = pullDownPushExposureEvent, clickCallback = { updatePullDownPushDownloadBtn() val currentTabEntity = getCurrentTabEntity() SensorsBridge.trackEvent( "DropDownPushClick", json { - "action" to mPullDownPushAction + "action" to pullDownPushAction "button_name" to "下载按钮" "drop_down_push_id" to id "game_name" to name "game_id" to id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -811,20 +816,20 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar // 下拉进入/退出下拉推送时更新背景透明度 private fun updateStyleOnHeaderMoving(offset: Int) { if (context == null) return - mBinding.run { - if (offset >= mShowTwoLevelStartOffset) { + binding.run { + if (offset >= showTwoLevelStartOffset) { val oneLevelAlpha = - 1 - (offset - mShowTwoLevelStartOffset) / (mTwoLevelOpenOffset - mShowTwoLevelStartOffset).toFloat() + 1 - (offset - showTwoLevelStartOffset) / (twoLevelOpenOffset - showTwoLevelStartOffset).toFloat() tabBgView.alpha = oneLevelAlpha contentBgView.alpha = oneLevelAlpha - mViewModel.updateBackgroundAlpha(oneLevelAlpha) + viewModel.updateBackgroundAlpha(oneLevelAlpha) - if (mViewModel.isTabCustomPage(mLastSelectedPosition)) { + if (viewModel.isTabCustomPage(lastSelectedPosition)) { refreshStatusBarStyle() updateSearchToolbarStyle(true) updateRefreshHeaderStyle() if (getCurrentTabStyle()?.isSlideBackgroundColorEnable == false) { - if (mStyle == Style.SINGLE_LINE_TAB) { + if (style == Style.SINGLE_LINE_TAB) { updateTabStyleOnHeaderMoving( TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()), TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()), @@ -833,7 +838,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } } else { val lightStyle = - (mIsDisplayingLightContent && oneLevelAlpha >= PULL_TAB_TEXT_STYLE_UPDATE_PERCENT) || mStyle == Style.SINGLE_LINE_TAB + (isDisplayingLightContent && oneLevelAlpha >= PULL_TAB_TEXT_STYLE_UPDATE_PERCENT) || style == Style.SINGLE_LINE_TAB val tabSelectedColor = if (lightStyle) { TAB_DEFAULT_COLOR_LIGHT.toColor(requireContext()) } else { @@ -855,13 +860,13 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } else { tabBgView.alpha = 1F contentBgView.alpha = 1F - mViewModel.updateBackgroundAlpha(1F) + viewModel.updateBackgroundAlpha(1F) - if (mViewModel.isTabCustomPage(mLastSelectedPosition)) { + if (viewModel.isTabCustomPage(lastSelectedPosition)) { refreshStatusBarStyle() - updateSearchToolbarStyle(mIsDarkModeOn || mIsDisplayingLightContent) + updateSearchToolbarStyle(mIsDarkModeOn || isDisplayingLightContent) updateRefreshHeaderStyle() - if (getCurrentTabStyle()?.isSlideBackgroundColorEnable == false && mStyle == Style.SINGLE_LINE_TAB) { + if (getCurrentTabStyle()?.isSlideBackgroundColorEnable == false && style == Style.SINGLE_LINE_TAB) { updateTabStyleOnHeaderMoving( TAB_SELECTED_COLOR.toColor(requireContext()), TAB_DEFAULT_COLOR.toColor(requireContext()), @@ -872,20 +877,20 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } if (refreshLayout.state == RefreshState.TwoLevelFinish || refreshLayout.state == RefreshState.TwoLevel) { - headerBackground.alpha = 1 - offset / mTwoLevelOpenOffset.toFloat() + headerBackground.alpha = 1 - offset / twoLevelOpenOffset.toFloat() } } } private fun updateTabStyleOnHeaderMoving(tabSelectedColor: Int, tabDefaultColor: Int, indicatorDrawable: Int) { - if (mCurrentTabSelectedColor != tabSelectedColor || mCurrentTabDefaultColor != tabDefaultColor) { - mCurrentTabSelectedColor = tabSelectedColor - mCurrentTabDefaultColor = tabDefaultColor - updateTabStyle(mLastSelectedPosition, 0F, mCurrentTabDefaultColor, mCurrentTabSelectedColor) + if (currentTabSelectedColor != tabSelectedColor || currentTabDefaultColor != tabDefaultColor) { + currentTabSelectedColor = tabSelectedColor + currentTabDefaultColor = tabDefaultColor + updateTabStyle(lastSelectedPosition, 0F, currentTabDefaultColor, currentTabSelectedColor) } - if (mCurrentIndicatorDrawable != indicatorDrawable) { - mCurrentIndicatorDrawable = indicatorDrawable - mIndicatorView?.updateIndicatorDrawable(indicatorDrawable.toDrawable(requireContext())) + if (currentIndicatorDrawable != indicatorDrawable) { + currentIndicatorDrawable = indicatorDrawable + indicatorView?.updateIndicatorDrawable(indicatorDrawable.toDrawable(requireContext())) } } @@ -899,15 +904,21 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } return } - mBinding.run { - if (mMultiTabNavId == MainWrapperRepository.getInstance().defaultNavId) { - mPullDownPush = - mPullDownPush ?: MainWrapperRepository.getInstance().customPageLiveData.value?.linkPullDownPush + binding.run { + // 搜索栏隐藏时滚动到顶部 + if (viewModel.appBarOffset != 0) { + appbar.setExpanded(true) + } + (getFragment(viewPager.currentItem) as? IScrollable)?.scrollToTop() + + if (multiTabNavId == MainWrapperRepository.getInstance().defaultNavId) { + pullDownPush = + pullDownPush ?: MainWrapperRepository.getInstance().customPageLiveData.value?.linkPullDownPush } - if ((mPullDownPush == null) - || mFragmentList.isEmpty() - || mFragmentList.safelyGetInRelease(viewPager.currentItem) !is ISmartRefreshContent + if ((pullDownPush == null) + || fragmentList.isEmpty() + || fragmentList.safelyGetInRelease(viewPager.currentItem) !is ISmartRefreshContent ) { finishCallback.invoke() return @@ -918,7 +929,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar // 自动弹出 mBaseHandler.post { - mPullDownPush?.run { + pullDownPush?.run { val pullDownPushSet = HashSet(SPUtils.getStringSet(Constants.SP_PULL_DOWN_PUSH_POP_UP_SET)) twoLevelHeader.openTwoLevel(true) wrapperLl.clipChildren = false @@ -929,7 +940,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar classicsHeader.visibility = View.INVISIBLE pullDownPushSet.add(id) SPUtils.setStringSet(Constants.SP_PULL_DOWN_PUSH_POP_UP_SET, pullDownPushSet) - mAutoFinishTwoLevelHandler = object : Handler(Looper.getMainLooper()) { + autoFinishTwoLevelHandler = object : Handler(Looper.getMainLooper()) { override fun handleMessage(msg: Message) { super.handleMessage(msg) finishTwoLevel("自动收起") @@ -938,20 +949,20 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } when { putAwaySwitch == "video_finished" && video != null -> { - autoVideoView.setVideoAllCallBack(object : GSYSampleCallBack() { + autoVideoView?.setVideoAllCallBack(object : GSYSampleCallBack() { override fun onAutoComplete(url: String?, vararg objects: Any?) { super.onAutoComplete(url, *objects) - mAutoFinishTwoLevelHandler?.sendEmptyMessage(KEY_AUTO_FINISH_TWO_LEVEL) - autoVideoView.setVideoAllCallBack(null) + autoFinishTwoLevelHandler?.sendEmptyMessage(KEY_AUTO_FINISH_TWO_LEVEL) + autoVideoView?.setVideoAllCallBack(null) } }) } putAwaySwitch.toIntOrNull() != null -> { val autoFinishDelayTime = putAwaySwitch.toInt() * 1000L - mAutoFinishTwoLevelHandler?.sendEmptyMessageDelayed(KEY_AUTO_FINISH_TWO_LEVEL, autoFinishDelayTime) + autoFinishTwoLevelHandler?.sendEmptyMessageDelayed(KEY_AUTO_FINISH_TWO_LEVEL, autoFinishDelayTime) } else -> { - mAutoFinishTwoLevelCallback = finishCallback + autoFinishTwoLevelCallback = finishCallback } } } @@ -960,42 +971,54 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } override fun setPullDownPush(pullDownPush: PullDownPush?, pullDownPushHandler: PullDownPushHandler?) { - if (pullDownPush != null) { - setSmartRefreshEnabled(true) - if ((mPullDownPush?.id ?: "") == pullDownPush.id) return + if (autoVideoView == null) { + binding.autoVideoViewStub.setOnInflateListener { _, inflated -> + autoVideoView = LayoutAutoVideoViewBinding.bind(inflated).root + setPullDownPushInternal(pullDownPush, pullDownPushHandler) + } + binding.autoVideoViewStub.inflate() + } else { + setPullDownPushInternal(pullDownPush, pullDownPushHandler) + } + } - mPullDownPush = pullDownPush - mPullDownPush?.run { + private fun setPullDownPushInternal(push: PullDownPush?, pullDownPushHandler: PullDownPushHandler?) { + if (push != null) { + setSmartRefreshEnabled(true) + if ((pullDownPush?.id ?: "") == push.id) return + + pullDownPush = push + pullDownPush?.run { if (game != null) { game.sequence = 1 - mPullDownPushExposureEvent = ExposureEvent.createEventWithSourceConcat( + pullDownPushExposureEvent = ExposureEvent.createEventWithSourceConcat( game, basicSource = listOf(ExposureSource("自定义页面", "$customPageName+$customPageId")), source = listOf(ExposureSource("下拉推送", id)) ) } - mBinding.run { + binding.run { if (game != null) { gameNameTv.text = game.name GameItemViewHolder.initGameSubtitleAndAdLabel(game, gameSubtitleTv) updatePullDownPushDownloadBtn() headerContainer.setOnClickListener { - if (mShowTwoLevel) { - mPullDownPushClick = true + if (showTwoLevel) { + pullDownPushClick = true val currentTabEntity = getCurrentTabEntity() SensorsBridge.trackEvent( "DropDownPushClick", json { - "action" to mPullDownPushAction + "action" to pullDownPushAction "button_name" to "游戏详情" "drop_down_push_id" to id "game_name" to game.name "game_id" to game.id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -1005,7 +1028,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar requireContext(), game.id, "(自定义页面-下拉推送)", - mPullDownPushExposureEvent + pullDownPushExposureEvent ) } } @@ -1014,9 +1037,9 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar gameImageIv.goneIf(video != null) { ImageUtils.display(gameImageIv, imgUrl) } - autoVideoView.onVideoReset() - autoVideoView.goneIf(video == null) { - if (!autoVideoView.isInPlayingState) { + autoVideoView?.onVideoReset() + autoVideoView?.goneIf(video == null) { + if (autoVideoView?.isInPlayingState == false) { GSYVideoOptionBuilder() .setIsTouchWiget(false) .setUrl(video?.url ?: "") @@ -1027,9 +1050,9 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar .setLooping(false) .setShowFullAnimation(false) .build(autoVideoView) - autoVideoView.updateThumb(imgUrl) - autoVideoView.setParamsData(game, null) - autoVideoView.setOnVideoClickListener { + autoVideoView?.updateThumb(imgUrl) + autoVideoView?.setParamsData(game, null) + autoVideoView?.setOnVideoClickListener { headerContainer.performClick() } } @@ -1040,20 +1063,20 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar val pullDownPushSet = SPUtils.getStringSet(Constants.SP_PULL_DOWN_PUSH_POP_UP_SET) - val popupPush = mPullDownPush != null - && "on" == mPullDownPush!!.popSwitch - && !pullDownPushSet.contains(mPullDownPush!!.id) + val popupPush = pullDownPush != null + && "on" == pullDownPush!!.popSwitch + && !pullDownPushSet.contains(pullDownPush!!.id) pullDownPushHandler?.doPreProcess(this as? ISmartRefresh, popupPush) } private fun updateRefreshHeaderStyle(force: Boolean = false) { - if (mLightRefreshHeaderStyle == mIsDisplayingLightContent && !force) return - mLightRefreshHeaderStyle = mIsDisplayingLightContent - mBinding.classicsHeader.run { - val arrowColorFilterColor = if (mIsDisplayingLightContent) com.gh.gamecenter.common.R.color.text_aw_primary else com.gh.gamecenter.common.R.color.text_tertiary - val primaryColor = if (mIsDisplayingLightContent) com.gh.gamecenter.common.R.color.white else com.gh.gamecenter.common.R.color.ui_surface - val accentColor = if (mIsDisplayingLightContent) com.gh.gamecenter.common.R.color.white else com.gh.gamecenter.common.R.color.text_tertiary + if (lightRefreshHeaderStyle == isDisplayingLightContent && !force) return + lightRefreshHeaderStyle = isDisplayingLightContent + binding.classicsHeader.run { + val arrowColorFilterColor = if (isDisplayingLightContent) com.gh.gamecenter.common.R.color.text_aw_primary else com.gh.gamecenter.common.R.color.text_tertiary + val primaryColor = if (isDisplayingLightContent) com.gh.gamecenter.common.R.color.white else com.gh.gamecenter.common.R.color.ui_surface + val accentColor = if (isDisplayingLightContent) com.gh.gamecenter.common.R.color.white else com.gh.gamecenter.common.R.color.text_tertiary setArrowColorFilter(arrowColorFilterColor.toColor(requireContext())) setPrimaryColor(primaryColor.toColor(requireContext())) setAccentColor(accentColor.toColor(requireContext())) @@ -1062,9 +1085,9 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar // 播放下拉推送视频 private fun playPullDownPushVideo() { - mBinding.run { - if (!mPullDownPush?.video?.url.isNullOrEmpty()) { - if (autoVideoView.currentState != GSYVideoView.CURRENT_STATE_PAUSE) { + binding.run { + if (!pullDownPush?.video?.url.isNullOrEmpty()) { + if (autoVideoView?.currentState != GSYVideoView.CURRENT_STATE_PAUSE) { mBaseHandler.postDelayed({ val videoOption = SPUtils.getString(Constants.SP_HOME_OR_DETAIL_VIDEO_OPTION, Constants.VIDEO_OPTION_WIFI) @@ -1072,14 +1095,14 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar when (videoOption) { Constants.VIDEO_OPTION_ALL -> { - autoVideoView.onVideoReset() - autoVideoView.startPlayLogic(false) + autoVideoView?.onVideoReset() + autoVideoView?.startPlayLogic(false) } Constants.VIDEO_OPTION_WIFI -> { if (NetworkUtils.isWifiConnected(HaloApp.getInstance().application)) { - autoVideoView.onVideoReset() - autoVideoView.startPlayLogic(false) + autoVideoView?.onVideoReset() + autoVideoView?.startPlayLogic(false) } } @@ -1096,12 +1119,12 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } private fun pausePullDownPushVideo() { - mBinding.run { - if (mShowTwoLevel && !mPullDownPush?.video?.url.isNullOrEmpty()) { - autoVideoView.onVideoPause() - val currentPosition = autoVideoView.getCurrentPosition() - val videoUrl = autoVideoView.getUrl() - if (videoUrl.isNotEmpty()) { + binding.run { + if (showTwoLevel && !pullDownPush?.video?.url.isNullOrEmpty()) { + autoVideoView?.onVideoPause() + val currentPosition = autoVideoView?.getCurrentPosition() ?: 0L + val videoUrl = autoVideoView?.getUrl() + if (!videoUrl.isNullOrEmpty()) { ScrollCalculatorHelper.savePlaySchedule(MD5Utils.getContentMD5(videoUrl), currentPosition) } } @@ -1109,24 +1132,24 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } private fun resumePullDownPushVideo() { - mBinding.run { - if (!mFinishingTwoLevel && mShowTwoLevel && !mPullDownPush?.video?.url.isNullOrEmpty()) { - val videoUrl = autoVideoView.getUrl() - if (videoUrl.isNotEmpty()) { + binding.run { + if (!finishingTwoLevel && showTwoLevel && !pullDownPush?.video?.url.isNullOrEmpty()) { + val videoUrl = autoVideoView?.getUrl() + if (!videoUrl.isNullOrEmpty()) { val position = ScrollCalculatorHelper.getPlaySchedule(MD5Utils.getContentMD5(videoUrl)) //这里必须要延迟操作,否则会白屏 mBaseHandler.postDelayed({ if (position != 0L) { - autoVideoView.seekTo(position) - autoVideoView.onVideoResume(false) + autoVideoView?.seekTo(position) + autoVideoView?.onVideoResume(false) val topVideoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true) if (topVideoVoiceStatus) { - autoVideoView.mute() + autoVideoView?.mute() } else { - autoVideoView.unMute() + autoVideoView?.unMute() } } else { - autoVideoView.release() + autoVideoView?.release() } }, PULL_DOWN_PUSH_VIDEO_PLAY_DELAY) } @@ -1139,17 +1162,17 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar pausePullDownPushVideo() DownloadManager.getInstance().removeObserver(dataWatcher) - mSuperiorChain?.unregisterInferiorChain(mPriorityChain) + superiorChain?.unregisterInferiorChain(priorityChain) } @Subscribe(threadMode = ThreadMode.MAIN) fun onEventMainThread(status: EBDownloadStatus) { - mPackageViewModel.filterSameUpdateLiveData.value?.let { + packageViewModel.filterSameUpdateLiveData.value?.let { setDownloadHint(it) } // 下载被删除事件 if ("delete" == status.status) { - if (status.gameId == mPullDownPush?.game?.id) { + if (status.gameId == pullDownPush?.game?.id) { updatePullDownPushDownloadBtn() } } @@ -1164,36 +1187,36 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } override fun finishRefresh() { - mBinding.refreshLayout.finishRefresh(true) + binding.refreshLayout.finishRefresh(true) } override fun setSmartRefreshEnabled(isEnable: Boolean) { - mBinding.refreshLayout.setEnableRefresh(isEnable) + binding.refreshLayout.setEnableRefresh(isEnable) getValidSmartRefreshContent()?.setSwipeRefreshEnabled(!isEnable) getCurrentTabEntity()?.showPullDownPush = isEnable } override fun finishTwoLevel(action: String) { - if (mShowTwoLevel) { - mAutoFinishTwoLevelHandler?.removeMessages(KEY_AUTO_FINISH_TWO_LEVEL) - mBinding.twoLevelHeader.finishTwoLevel() - mAutoFinishTwoLevelCallback?.invoke() - mAutoFinishTwoLevelCallback = null - mElapsedHelper.pauseCounting() - mPullDownPush?.run { + if (showTwoLevel) { + autoFinishTwoLevelHandler?.removeMessages(KEY_AUTO_FINISH_TWO_LEVEL) + binding.twoLevelHeader.finishTwoLevel() + autoFinishTwoLevelCallback?.invoke() + autoFinishTwoLevelCallback = null + elapsedHelper.pauseCounting() + pullDownPush?.run { val currentTabEntity = getCurrentTabEntity() SensorsBridge.trackEvent( "DropDownPushClick", json { - "action" to mPullDownPushAction + "action" to pullDownPushAction "button_name" to "关闭推送" "drop_down_push_id" to id "game_name" to game?.name "game_id" to game?.id - "bottom_tab" to mBottomTabName - "several_tab_page_name" to mMultiTabNavName - "several_tab_page_id" to mMultiTabNavId - "position" to mLastSelectedPosition + "bottom_tab" to bottomTabName + "several_tab_page_name" to multiTabNavName + "several_tab_page_id" to multiTabNavId + "position" to lastSelectedPosition "tab_content" to currentTabEntity?.name "custom_page_name" to currentTabEntity?.link?.text "custom_page_id" to currentTabEntity?.link?.link @@ -1202,10 +1225,10 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar com.gh.common.util.NewFlatLogUtils.logHomePushClose( id, action, - mTwoLevelOpenCount, + twoLevelOpenCount, game?.id ?: "", game?.name ?: "", - mElapsedHelper.elapsedTime + elapsedHelper.elapsedTime ) } } @@ -1217,25 +1240,25 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar resumePullDownPushVideo() DownloadManager.getInstance().addObserver(dataWatcher) updatePullDownPushDownloadBtn() - mMainWrapperViewModel?.requestAccelerateNotificationPopup() - updateSearchToolbarStyle(mIsDarkModeOn || mIsDisplayingLightContent || mShowTwoLevel, true) + mainWrapperViewModel?.requestAccelerateNotificationPopup() + updateSearchToolbarStyle(mIsDarkModeOn || isDisplayingLightContent || showTwoLevel, true) if (CheckLoginUtils.isLogin()) { - mUnreadViewModel.retry() + unreadViewModel.retry() } mBaseHandler.post { - mSuperiorChain?.registerInferiorChain(mPriorityChain) + superiorChain?.registerInferiorChain(priorityChain) } } override fun onPageSelected(position: Int) { super.onPageSelected(position) getCurrentTabEntity()?.showPullDownPush?.let { setSmartRefreshEnabled(it) } - if (mShowTwoLevel) finishTwoLevel("跳转收起") + if (showTwoLevel) finishTwoLevel("跳转收起") } private fun updateIndicatorDrawable(indicatorView: TabIndicatorView?) { - if (mIsDisplayingLightContent) { + if (isDisplayingLightContent) { indicatorView?.updateIndicatorDrawable(R.drawable.ic_home_tab_indicator_white.toDrawable(requireContext())) } else { indicatorView?.updateIndicatorDrawable(R.drawable.ic_commodity_selected.toDrawable(requireContext())) @@ -1251,20 +1274,20 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar val tabStyle = tabEntityList.safelyGetInRelease(position)?.style // 处理当前 tab 和下一个 tab - if (nextPosition != mTabBindingList.size) { + if (nextPosition != tabBindingList.size) { val nextTabStyle = tabEntityList.safelyGetInRelease(nextPosition)?.style - var currentAppBarColor = tabStyle?.primaryColor ?: mBackgroundWhiteColor - var nextAppBarColor = nextTabStyle?.primaryColor ?: mBackgroundWhiteColor + var currentAppBarColor = tabStyle?.primaryColor ?: backgroundWhiteColor + var nextAppBarColor = nextTabStyle?.primaryColor ?: backgroundWhiteColor - if (currentAppBarColor == Color.WHITE) currentAppBarColor = mBackgroundWhiteColor - if (nextAppBarColor == Color.WHITE) nextAppBarColor = mBackgroundWhiteColor + if (currentAppBarColor == Color.WHITE) currentAppBarColor = backgroundWhiteColor + if (nextAppBarColor == Color.WHITE) nextAppBarColor = backgroundWhiteColor if (getFragment(position) is AmwayFragment) { - currentAppBarColor = if (mIsDarkModeOn) mBackgroundColor else mAmwayPrimaryColor + currentAppBarColor = if (mIsDarkModeOn) backgroundColor else amwayPrimaryColor tabStyle?.currentSelectColor = currentAppBarColor } if (getFragment(nextPosition) is AmwayFragment) { - nextAppBarColor = if (mIsDarkModeOn) mBackgroundColor else mAmwayPrimaryColor + nextAppBarColor = if (mIsDarkModeOn) backgroundColor else amwayPrimaryColor } val proximatelySelectedTabStyle = if (positionOffset < 0.5) tabStyle else nextTabStyle @@ -1276,43 +1299,43 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } // 颜色显示是否变更 - val isDisplayingLightContent = proximatelySelectedTabStyle?.useLightStyle ?: false || mShowTwoLevel - val isContentStyleChanged = isDisplayingLightContent != mIsDisplayingLightContent - mIsDisplayingLightContent = isDisplayingLightContent + val isDisplayingLightContentTemp = proximatelySelectedTabStyle?.useLightStyle ?: false || showTwoLevel + val isContentStyleChanged = isDisplayingLightContentTemp != isDisplayingLightContent + isDisplayingLightContent = isDisplayingLightContentTemp - if (!mShowTwoLevel) { - mCurrentTabSelectedColor = - if (mIsDisplayingLightContent) mTabDefaultLightColor else mTabSelectedColor - mCurrentTabDefaultColor = if (mIsDisplayingLightContent) mTabDefaultLightColor else mTabDefaultColor + if (!showTwoLevel) { + currentTabSelectedColor = + if (isDisplayingLightContent) tabDefaultLightColor else tabSelectedColor + currentTabDefaultColor = if (isDisplayingLightContent) tabDefaultLightColor else tabDefaultColor } if (isContentStyleChanged) { - mBinding.searchIv.setImageResource(if (mIsDisplayingLightContent) R.drawable.toolbar_search_light else R.drawable.toolbar_search) - if (!mShowTwoLevel) updateIndicatorDrawable(mIndicatorView) + binding.searchIv.setImageResource(if (isDisplayingLightContent) R.drawable.toolbar_search_light else R.drawable.toolbar_search) + if (!showTwoLevel) updateIndicatorDrawable(indicatorView) refreshStatusBarStyle() } - mCurrentAppBarColor = appBarColorInBetween - updateAppBarStyle(appBarColorInBetween, mIsDisplayingLightContent) + this.currentAppBarColor = appBarColorInBetween + updateAppBarStyle(appBarColorInBetween, isDisplayingLightContent) } else { - var currentAppBarColor = tabStyle?.primaryColor ?: mBackgroundWhiteColor + var currentAppBarColor = tabStyle?.primaryColor ?: backgroundWhiteColor if (mIsDarkModeOn && currentAppBarColor == Color.WHITE) { - currentAppBarColor = mBackgroundWhiteColor + currentAppBarColor = backgroundWhiteColor } if (getFragment(position) is AmwayFragment) { - currentAppBarColor = if (mIsDarkModeOn) mBackgroundColor else mAmwayPrimaryColor + currentAppBarColor = if (mIsDarkModeOn) backgroundColor else amwayPrimaryColor tabStyle?.currentSelectColor = currentAppBarColor } - mIsDisplayingLightContent = tabStyle?.useLightStyle == true || mShowTwoLevel - if (!mShowTwoLevel) { - mCurrentTabSelectedColor = - if (mIsDisplayingLightContent) mTabDefaultLightColor else mTabSelectedColor - mCurrentTabDefaultColor = if (mIsDisplayingLightContent) mTabDefaultLightColor else mTabDefaultColor + isDisplayingLightContent = tabStyle?.useLightStyle == true || showTwoLevel + if (!showTwoLevel) { + currentTabSelectedColor = + if (isDisplayingLightContent) tabDefaultLightColor else tabSelectedColor + currentTabDefaultColor = if (isDisplayingLightContent) tabDefaultLightColor else tabDefaultColor } - updateAppBarStyle(currentAppBarColor, mIsDisplayingLightContent) - mBinding.searchIv.setImageResource(if (mIsDisplayingLightContent) R.drawable.toolbar_search_light else R.drawable.toolbar_search) - if (!mShowTwoLevel) updateIndicatorDrawable(mIndicatorView) + updateAppBarStyle(currentAppBarColor, isDisplayingLightContent) + binding.searchIv.setImageResource(if (isDisplayingLightContent) R.drawable.toolbar_search_light else R.drawable.toolbar_search) + if (!showTwoLevel) updateIndicatorDrawable(indicatorView) refreshStatusBarStyle() } @@ -1333,8 +1356,8 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar updateTabStyle( selectedPosition, positionOffsetOnRealSelectedPosition, - mCurrentTabDefaultColor, - mCurrentTabSelectedColor + currentTabDefaultColor, + currentTabSelectedColor ) } @@ -1342,49 +1365,49 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar val currentTabStyle = getCurrentTabStyle() currentTabStyle?.offsetRatio = offset / totalHeight.toFloat() if (((currentTabStyle?.isSlideBackgroundColorShow == true || (currentTabStyle != null && isDarkModeChanged)) && offset >= totalHeight) - || (currentTabStyle?.isSlideBackgroundColorEnable == false && mViewModel.isTabCustomPage(mLastSelectedPosition)) + || (currentTabStyle?.isSlideBackgroundColorEnable == false && viewModel.isTabCustomPage(lastSelectedPosition)) ) { currentTabStyle.isSlideBackgroundColorShow = false - currentTabStyle.primaryColor = mBackgroundWhiteColor + currentTabStyle.primaryColor = backgroundWhiteColor currentTabStyle.useLightStyle = false - mIsDisplayingLightContent = mShowTwoLevel && !currentTabStyle.isSlideBackgroundColorEnable - updateAppBarColorWhenScrollChanged(mBackgroundWhiteColor) + isDisplayingLightContent = showTwoLevel && !currentTabStyle.isSlideBackgroundColorEnable + updateAppBarColorWhenScrollChanged(backgroundWhiteColor) mBaseHandler.post { refreshStatusBarStyle() } - if (!mShowTwoLevel || !currentTabStyle.isSlideBackgroundColorEnable) { - mCurrentTabSelectedColor = TAB_SELECTED_COLOR.toColor(requireContext()) - mCurrentTabDefaultColor = TAB_DEFAULT_COLOR.toColor(requireContext()) - mIndicatorView?.updateIndicatorDrawable(R.drawable.ic_commodity_selected.toDrawable()) - mBinding.searchIv.setImageResource(R.drawable.toolbar_search) - updateTabStyle(mLastSelectedPosition, 0F, mCurrentTabDefaultColor, mCurrentTabSelectedColor) + if (!showTwoLevel || !currentTabStyle.isSlideBackgroundColorEnable) { + currentTabSelectedColor = TAB_SELECTED_COLOR.toColor(requireContext()) + currentTabDefaultColor = TAB_DEFAULT_COLOR.toColor(requireContext()) + indicatorView?.updateIndicatorDrawable(R.drawable.ic_commodity_selected.toDrawable()) + binding.searchIv.setImageResource(R.drawable.toolbar_search) + updateTabStyle(lastSelectedPosition, 0F, currentTabDefaultColor, currentTabSelectedColor) } } else if (offset < totalHeight) { var currentSelectColor = currentTabStyle?.currentSelectColor ?: 0 - val offsetMeetsCriticalPoint = (currentTabStyle?.offsetRatio ?: 0F) < mOffsetCritical + val offsetMeetsCriticalPoint = (currentTabStyle?.offsetRatio ?: 0F) < offsetCritical currentTabStyle?.isSlideBackgroundColorShow = true - if (getFragment(mBinding.viewPager.currentItem) is AmwayFragment) { - currentSelectColor = if (mIsDarkModeOn) mBackgroundColor else mAmwayPrimaryColor + if (getFragment(binding.viewPager.currentItem) is AmwayFragment) { + currentSelectColor = if (mIsDarkModeOn) backgroundColor else amwayPrimaryColor } val colorInBetween = - ColorUtils.blendARGB(currentSelectColor, mBackgroundWhiteColor, currentTabStyle?.offsetRatio ?: 0F) + ColorUtils.blendARGB(currentSelectColor, backgroundWhiteColor, currentTabStyle?.offsetRatio ?: 0F) updateAppBarColorWhenScrollChanged(colorInBetween) currentTabStyle?.primaryColor = colorInBetween currentTabStyle?.useLightStyle = offsetMeetsCriticalPoint - if (mIsDisplayingLightContent != currentTabStyle?.useLightStyle) { - mIsDisplayingLightContent = offsetMeetsCriticalPoint + if (isDisplayingLightContent != currentTabStyle?.useLightStyle) { + isDisplayingLightContent = offsetMeetsCriticalPoint } mBaseHandler.post { refreshStatusBarStyle() } - if (!mShowTwoLevel) { - mCurrentTabSelectedColor = if (offsetMeetsCriticalPoint) mTabDefaultLightColor else mTabSelectedColor - mCurrentTabDefaultColor = if (offsetMeetsCriticalPoint) mTabDefaultLightColor else mTabDefaultColor - mIndicatorView?.updateIndicatorDrawable( + if (!showTwoLevel) { + currentTabSelectedColor = if (offsetMeetsCriticalPoint) tabDefaultLightColor else tabSelectedColor + currentTabDefaultColor = if (offsetMeetsCriticalPoint) tabDefaultLightColor else tabDefaultColor + indicatorView?.updateIndicatorDrawable( if (offsetMeetsCriticalPoint) { R.drawable.ic_home_tab_indicator_white.toDrawable() } else { R.drawable.ic_commodity_selected.toDrawable() } ) - mBinding.searchIv.setImageResource(if (offsetMeetsCriticalPoint) R.drawable.toolbar_search_light else R.drawable.toolbar_search) - updateTabStyle(mLastSelectedPosition, 0F, mCurrentTabDefaultColor, mCurrentTabSelectedColor) + binding.searchIv.setImageResource(if (offsetMeetsCriticalPoint) R.drawable.toolbar_search_light else R.drawable.toolbar_search) + updateTabStyle(lastSelectedPosition, 0F, currentTabDefaultColor, currentTabSelectedColor) } } } @@ -1397,7 +1420,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } val useLightStyle = color != com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()) || - (mShowTwoLevel && currentTabStyle?.isSlideBackgroundColorEnable == false) + (showTwoLevel && currentTabStyle?.isSlideBackgroundColorEnable == false) updateAppBarStyle(color, useLightStyle) } @@ -1405,8 +1428,8 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar val currentTab = getCurrentTabEntity() val currentTabStyle = getCurrentTabStyle() //此处的判断是防止banner在滑动过程中切换tab会导致背景设置错误 - if (mStyle != Style.NO_TAB && (currentTab?.link?.type != ViewPagerFragmentHelper.TYPE_CUSTOM_PAGE || currentTab.link.link != pageId)) { - val customPageTabStyle = mViewModel.getCustomPageTabEntity(pageId)?.style + if (style != Style.NO_TAB && (currentTab?.link?.type != ViewPagerFragmentHelper.TYPE_CUSTOM_PAGE || currentTab.link.link != pageId)) { + val customPageTabStyle = viewModel.getCustomPageTabEntity(pageId)?.style customPageTabStyle?.currentSelectColor = color if (customPageTabStyle?.isSlideBackgroundColorShow == true) { val colorInBetween = @@ -1432,63 +1455,63 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } } - override fun setSearchStyle(searchStyle: BottomTab.SearchStyle) { mSearchStyle = searchStyle } + override fun updateSearchStyle(searchStyle: BottomTab.SearchStyle) { this.searchStyle = searchStyle } override fun getCurrentTabIndex(): Int? = provideViewPager()?.currentItem override fun addTabGuideHandlerIfExists(chain: PriorityChain) { if (isDefaultCustomPageFragment()) { - chain.addHandler(mMultiTabGuideHandler) + chain.addHandler(multiTabGuideHandler) } } private fun getCurrentTabStyle(): MultiTabNav.LinkMultiTabNav.TabStyle? = - if (mStyle == Style.NO_TAB) mViewModel.noTabStyle else getCurrentTabEntity()?.style + if (style == Style.NO_TAB) viewModel.noTabStyle else getCurrentTabEntity()?.style /** * 更新 AppBar 的控件 style */ private fun updateAppBarStyle(color: Int, useLightStyle: Boolean) { - mBinding.toolbarBgView.setBackgroundColor(color) - mBinding.statusBar.setBackgroundColor(color) - mBinding.headerBgView.setBackgroundColor(color) - mBinding.tabBgView.setBackgroundColor(color) - mBinding.contentBgView.setBackgroundColor(color) + binding.toolbarBgView.setBackgroundColor(color) + binding.statusBar.setBackgroundColor(color) + binding.headerBgView.setBackgroundColor(color) + binding.tabBgView.setBackgroundColor(color) + binding.contentBgView.setBackgroundColor(color) updateSearchToolbarStyle(mIsDarkModeOn || useLightStyle) } private fun updateSearchToolbarStyle(useLightStyle: Boolean, force: Boolean = false) { - if (mLightSearchToolbarStyle == useLightStyle && !force) return - mLightSearchToolbarStyle = useLightStyle + if (lightSearchToolbarStyle == useLightStyle && !force) return + lightSearchToolbarStyle = useLightStyle - mBinding.searchToolbar.actionbarIvSearch.setImageResource(if (useLightStyle) R.drawable.toolbar_search_icon_light else com.gh.gamecenter.common.R.drawable.toolbar_search_icon) - mBinding.searchToolbar.actionbarDownload.setImageResource(if (useLightStyle) R.drawable.toolbar_download_light else R.drawable.toolbar_download) - mBinding.searchToolbar.actionbarMessage.setImageResource(if (useLightStyle) R.drawable.toolbar_message_light else R.drawable.toolbar_message) - mBinding.searchToolbar.actionbarTeenagerModelIv.setImageResource(if (useLightStyle) R.drawable.toolbar_teenager_light else R.drawable.toolbar_teenager) - mBinding.searchToolbar.actionbarTeenagerModelTv.setTextColor( + binding.searchToolbar.actionbarIvSearch.setImageResource(if (useLightStyle) R.drawable.toolbar_search_icon_light else com.gh.gamecenter.common.R.drawable.toolbar_search_icon) + binding.searchToolbar.actionbarDownload.setImageResource(if (useLightStyle) R.drawable.toolbar_download_light else R.drawable.toolbar_download) + binding.searchToolbar.actionbarMessage.setImageResource(if (useLightStyle) R.drawable.toolbar_message_light else R.drawable.toolbar_message) + binding.searchToolbar.actionbarTeenagerModelIv.setImageResource(if (useLightStyle) R.drawable.toolbar_teenager_light else R.drawable.toolbar_teenager) + binding.searchToolbar.actionbarTeenagerModelTv.setTextColor( if (useLightStyle) Color.WHITE else com.gh.gamecenter.common.R.color.text_secondary.toColor( requireContext() ) ) - mBinding.tabSearchToolbar.searchIv.setImageResource(if (useLightStyle) R.drawable.toolbar_search_icon_light else com.gh.gamecenter.common.R.drawable.toolbar_search_icon) - mBinding.tabSearchToolbar.menuDownloadIv.setImageResource(if (useLightStyle) R.drawable.toolbar_download_light else R.drawable.toolbar_download) + binding.tabSearchToolbar.searchIv.setImageResource(if (useLightStyle) R.drawable.toolbar_search_icon_light else com.gh.gamecenter.common.R.drawable.toolbar_search_icon) + binding.tabSearchToolbar.menuDownloadIv.setImageResource(if (useLightStyle) R.drawable.toolbar_download_light else R.drawable.toolbar_download) - mSearchRightView?.setImageResource(if (useLightStyle) R.drawable.toolbar_search_light else R.drawable.toolbar_search) - mTeenagerModelView?.setBackgroundResource(if (useLightStyle) R.drawable.button_round_black_alpha_10 else R.drawable.button_round_f2f4f7) - mSearchHintTv?.setHintTextColor( + searchRightView?.setImageResource(if (useLightStyle) R.drawable.toolbar_search_light else R.drawable.toolbar_search) + teenagerModelView?.setBackgroundResource(if (useLightStyle) R.drawable.button_round_black_alpha_10 else R.drawable.button_round_f2f4f7) + searchHintTv?.setHintTextColor( if (useLightStyle) com.gh.gamecenter.common.R.color.search_text_color_light.toColor(requireContext()) else com.gh.gamecenter.common.R.color.search_text_color_default.toColor( requireContext() ) ) - mSearchContainerView?.background = + searchContainerView?.background = if (useLightStyle) R.drawable.home_search_bg_light.toDrawable(requireContext()) else R.drawable.home_search_bg.toDrawable( requireContext() ) } override fun onBackPressed(): Boolean { - if (mShowTwoLevel) { + if (showTwoLevel) { finishTwoLevel("主动收起") return true } @@ -1496,23 +1519,23 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar } override fun showTabGuide(shouldShow: Boolean, guide: BottomTab.Guide?, guidePosition: Int) { - if (mStyle == Style.NO_TAB) return + if (style == Style.NO_TAB) return if (!isDefaultCustomPageFragment()) { - mPriorityChain.addHandler(mMultiTabGuideHandler) + priorityChain.addHandler(multiTabGuideHandler) } if (shouldShow && guide != null && guidePosition != -1) { - mTabLayout?.post { - val tabView = mTabLayout?.getTabAt(guidePosition)?.view + tabLayout?.post { + val tabView = tabLayout?.getTabAt(guidePosition)?.view if (tabView != null) { - val isSingleLineTab = mStyle == Style.SINGLE_LINE_TAB - mMultiTabGuideHandler.doPreProcess( + val isSingleLineTab = style == Style.SINGLE_LINE_TAB + multiTabGuideHandler.doPreProcess( true, requireActivity(), mBaseHandler, guide, - mTabLayout, + tabLayout, tabView, isSingleLineTab, parentFragment as? MainWrapperFragment, @@ -1520,16 +1543,16 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar ) } else { // 不显示 - mMultiTabGuideHandler.doPreProcess(false) + multiTabGuideHandler.doPreProcess(false) } } } else { - mMultiTabGuideHandler.doPreProcess(false) + multiTabGuideHandler.doPreProcess(false) } } private fun updateTabAndToolbarStyleOnDarkModeChanged() { - mViewModel.tabListLiveData.value?.forEach { + viewModel.tabListLiveData.value?.forEach { if (it.link?.type != ViewPagerFragmentHelper.TYPE_AMWAY) { it.style.primaryColor = com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()) } @@ -1538,11 +1561,11 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar if (currentTabEntity?.link?.type != ViewPagerFragmentHelper.TYPE_AMWAY && currentTabEntity?.link?.type != ViewPagerFragmentHelper.TYPE_CUSTOM_PAGE) { onScrollChanged(0, 0, true) } - mBinding.run { + binding.run { contentContainer.setCardBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext())) toolbarBackground.setBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext())) - if (mShowTwoLevel) { - updateStyleOnHeaderMoving(mHeaderOffset) + if (showTwoLevel) { + updateStyleOnHeaderMoving(headerOffset) } if (getCurrentTabStyle()?.isSlideBackgroundColorEnable == false) { toolbarBgView.setBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext())) @@ -1556,31 +1579,31 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar setSearchHint() // 打开下载按钮事件 - mDownloadView?.isVisible = Config.isShow() + downloadView?.isVisible = Config.isShow() } if (reuse.type == EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE) { - mFragmentList.forEachIndexed { index, fragment -> + fragmentList.forEachIndexed { index, fragment -> if (fragment is GameCollectionSquareFragment) { - mBinding.viewPager.currentItem = index + binding.viewPager.currentItem = index } } } if (reuse.type == Constants.FINISH_PULL_DOWN_PUSH) { - if (!mPullDownPushClick) { - mFinishingTwoLevel = true + if (!pullDownPushClick) { + finishingTwoLevel = true mBaseHandler.postDelayed({ finishTwoLevel("跳转收起") - mFinishingTwoLevel = false + finishingTwoLevel = false }, FINISH_TWO_LEVEL_DELAY) } - mPullDownPushClick = false + pullDownPushClick = false } } override fun onTabViewClick() { - if (mShowTwoLevel) { - mBinding.twoLevelHeader.setFloorDuration(100) - mBinding.refreshLayout.setFloorDuration(100) + if (showTwoLevel) { + binding.twoLevelHeader.setFloorDuration(100) + binding.refreshLayout.setFloorDuration(100) finishTwoLevel("跳转收起") } } @@ -1591,11 +1614,11 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar * @param force 是否强制刷新 */ private fun refreshStatusBarStyle(force: Boolean = false) { - val lightStatusBar = !mShowTwoLevel && !mIsDisplayingLightContent && !mIsDarkModeOn - if ((lightStatusBar != mLightStatusBar || force) && isSupportVisible) { - mLightStatusBar = lightStatusBar + val lightStatusBarTemp = !showTwoLevel && !isDisplayingLightContent && !mIsDarkModeOn + if ((lightStatusBarTemp != lightStatusBar || force) && isSupportVisible) { + lightStatusBar = lightStatusBarTemp DisplayUtils.transparentStatusBar(requireActivity()) - DisplayUtils.setLightStatusBar(requireActivity(), lightStatusBar) + DisplayUtils.setLightStatusBar(requireActivity(), lightStatusBarTemp) } } @@ -1604,7 +1627,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar */ override fun logTabSelected(tabEntity: MultiTabNav.LinkMultiTabNav, position: Int) { super.logTabSelected(tabEntity, position) - VHelper.mainEntranceMap[mBottomTabName] = tabEntity.name + VHelper.mainEntranceMap[bottomTabName] = tabEntity.name LogUtils.logHomeTopTabClick( tabEntity.name, tabEntity.link?.type, @@ -1625,29 +1648,29 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar override fun onDarkModeChanged() { super.onDarkModeChanged() - updateSearchToolbarStyle(mIsDarkModeOn || mIsDisplayingLightContent, true) + updateSearchToolbarStyle(mIsDarkModeOn || isDisplayingLightContent, true) updateRefreshHeaderStyle(true) updateTabAndToolbarStyleOnDarkModeChanged() updatePullDownPushDownloadBtn() } override fun registerInferiorChain(chain: PriorityChain) { - mInferiorChain = chain - if (mPriorityChain.isHandlerQueueEmpty()) { - mInferiorChain?.resume() + inferiorChain = chain + if (priorityChain.isHandlerQueueEmpty()) { + inferiorChain?.resume() } } override fun unregisterInferiorChain(chain: PriorityChain) { - if (mInferiorChain == chain) { - mInferiorChain = null + if (inferiorChain == chain) { + inferiorChain = null } } override fun onDestroyView() { super.onDestroyView() - mAutoFinishTwoLevelHandler?.removeCallbacksAndMessages(null) - mBinding.autoVideoView.release() + autoFinishTwoLevelHandler?.removeCallbacksAndMessages(null) + autoVideoView?.release() } enum class Style { diff --git a/app/src/main/java/com/gh/gamecenter/wrapper/TabWrapperFragment.kt b/app/src/main/java/com/gh/gamecenter/wrapper/TabWrapperFragment.kt index 336a95c328..dd382663a8 100644 --- a/app/src/main/java/com/gh/gamecenter/wrapper/TabWrapperFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/wrapper/TabWrapperFragment.kt @@ -27,18 +27,18 @@ import kotlin.math.roundToInt * 二级页面-多tab导航页(带Tab的外层Fragment) */ class TabWrapperFragment: BaseTabWrapperFragment(), ISmartRefresh, ISmartRefreshContent, ISuperiorChain { - private val mBinding by lazy { FragmentTabWrapperBinding.inflate(layoutInflater) } - private val mViewModel: TabWrapperViewModel by lazy { viewModelProvider(TabWrapperViewModel.Factory(mMultiTabNavId)) } - private var mInferiorChain: PriorityChain? = null - private val mPriorityChain by lazy { PriorityChain { mInferiorChain?.start() } } - private val mMultiTabGuideHandler by lazy { MultiTabGuideHandler(24) } + private val binding by lazy { FragmentTabWrapperBinding.inflate(layoutInflater) } + private val viewModel: TabWrapperViewModel by lazy { viewModelProvider(TabWrapperViewModel.Factory(multiTabNavId)) } + private var inferiorChain: PriorityChain? = null + private val priorityChain by lazy { PriorityChain { inferiorChain?.start() } } + private val multiTabGuideHandler by lazy { MultiTabGuideHandler(24) } override fun getLayoutId(): Int = 0 - override fun getInflatedLayout(): View = mBinding.root - override fun provideViewModel(): TabWrapperViewModel = mViewModel - override fun provideTabLayout(): TabLayout = mBinding.tabLayout - override fun provideViewPager(): ViewPager = mBinding.viewPager - override fun provideIndicatorView(): TabIndicatorView = mBinding.indicatorView + override fun getInflatedLayout(): View = binding.root + override fun provideViewModel(): TabWrapperViewModel = viewModel + override fun provideTabLayout(): TabLayout = binding.tabLayout + override fun provideViewPager(): ViewPager = binding.viewPager + override fun provideIndicatorView(): TabIndicatorView = binding.indicatorView override fun provideIndicatorWidth(): Int = 20 override fun provideTabTextSize(): Float = 14F override fun provideTabDefaultColor(): Int = com.gh.gamecenter.common.R.color.text_secondary @@ -46,7 +46,7 @@ class TabWrapperFragment: BaseTabWrapperFragment(), ISmartRefresh, ISmartRefresh override fun isTabScaleEnabled(): Boolean = false override fun addTabGuideHandlerIfExists(chain: PriorityChain) { if (isDefaultCustomPageFragment()) { - chain.addHandler(mMultiTabGuideHandler) + chain.addHandler(multiTabGuideHandler) } } @@ -83,7 +83,7 @@ class TabWrapperFragment: BaseTabWrapperFragment(), ISmartRefresh, ISmartRefresh positionOffset } - updateTabStyle(selectedPosition, positionOffsetOnRealSelectedPosition, mTabDefaultColor, mTabSelectedColor) + updateTabStyle(selectedPosition, positionOffsetOnRealSelectedPosition, tabDefaultColor, tabSelectedColor) } override fun onCreate(savedInstanceState: Bundle?) { @@ -98,53 +98,53 @@ class TabWrapperFragment: BaseTabWrapperFragment(), ISmartRefresh, ISmartRefresh override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - mViewModel.title.observe(viewLifecycleOwner, Observer { + viewModel.title.observe(viewLifecycleOwner, Observer { setNavigationTitle(it) }) } override fun hideTab() { - mBinding.tabContainer.visibility = View.GONE + binding.tabContainer.visibility = View.GONE } override fun showTabGuide(shouldShow: Boolean, guide: BottomTab.Guide?, guidePosition: Int) { if (!isDefaultCustomPageFragment()) { - mPriorityChain.addHandler(mMultiTabGuideHandler) - mPriorityChain.start() + priorityChain.addHandler(multiTabGuideHandler) + priorityChain.start() } if (shouldShow && guide != null && guidePosition != -1) { - mTabLayout?.post { - val tabView = mTabLayout?.getTabAt(guidePosition)?.view + tabLayout?.post { + val tabView = tabLayout?.getTabAt(guidePosition)?.view if (tabView != null) { - if (!isDefaultCustomPageFragment() && mPriorityChain.isHandlerQueueEmpty()) { + if (!isDefaultCustomPageFragment() && priorityChain.isHandlerQueueEmpty()) { MultiTabGuideHandler.showMultiTabGuide( true, requireActivity(), mBaseHandler as BaseHandler, guide, - mTabLayout!!, + tabLayout!!, tabView, false ) } else { - mMultiTabGuideHandler.doPreProcess( + multiTabGuideHandler.doPreProcess( true, requireActivity(), mBaseHandler, guide, - mTabLayout, + tabLayout, tabView, false ) } } else { // 不显示 - mMultiTabGuideHandler.doPreProcess(false) + multiTabGuideHandler.doPreProcess(false) } } } else { - mMultiTabGuideHandler.doPreProcess(false) + multiTabGuideHandler.doPreProcess(false) } } @@ -183,19 +183,19 @@ class TabWrapperFragment: BaseTabWrapperFragment(), ISmartRefresh, ISmartRefresh override fun onDarkModeChanged() { super.onDarkModeChanged() - updateTabStyle(mLastSelectedPosition, 0F, mTabDefaultColor, mTabSelectedColor) + updateTabStyle(lastSelectedPosition, 0F, tabDefaultColor, tabSelectedColor) } override fun registerInferiorChain(chain: PriorityChain) { - mInferiorChain = chain - if (mPriorityChain.isHandlerQueueEmpty()) { - mInferiorChain?.resume() + inferiorChain = chain + if (priorityChain.isHandlerQueueEmpty()) { + inferiorChain?.resume() } } override fun unregisterInferiorChain(chain: PriorityChain) { - if (mInferiorChain == chain) { - mInferiorChain = null + if (inferiorChain == chain) { + inferiorChain = null } } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_search_toolbar_tab_wrapper.xml b/app/src/main/res/layout/fragment_search_toolbar_tab_wrapper.xml index 0789fe95e0..256e970e1a 100644 --- a/app/src/main/res/layout/fragment_search_toolbar_tab_wrapper.xml +++ b/app/src/main/res/layout/fragment_search_toolbar_tab_wrapper.xml @@ -47,11 +47,11 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - - + - + - + android:layout_centerInParent="true" + android:layout="@layout/reuse_loading" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_tab_wrapper.xml b/app/src/main/res/layout/fragment_tab_wrapper.xml index 7c215156b4..dd191fae9c 100644 --- a/app/src/main/res/layout/fragment_tab_wrapper.xml +++ b/app/src/main/res/layout/fragment_tab_wrapper.xml @@ -40,30 +40,34 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/tabContainer" /> - + + - - - + app:layout_constraintTop_toTopOf="parent"/> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_auto_video_view.xml b/app/src/main/res/layout/layout_auto_video_view.xml new file mode 100644 index 0000000000..201b314b3d --- /dev/null +++ b/app/src/main/res/layout/layout_auto_video_view.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/module_common/src/main/assets/lottie/refresh_loading.json b/module_common/src/main/assets/lottie/refresh_loading.json new file mode 100644 index 0000000000..676eeca689 --- /dev/null +++ b/module_common/src/main/assets/lottie/refresh_loading.json @@ -0,0 +1 @@ +{"v":"5.12.2","fr":60,"ip":0,"op":60,"w":120,"h":120,"nm":"loading","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"小圆形-right","td":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[60,60,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":2,"s":[0,0]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":5,"s":[4,4]},{"i":{"x":[0.463,0.463],"y":[1,1]},"o":{"x":[0.753,0.753],"y":[0,0]},"t":15,"s":[4,4]},{"t":19,"s":[0,0]}],"ix":2},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":5,"s":[0,0],"to":[9,0],"ti":[-9,0]},{"t":20,"s":[54,0]}],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"圆形-right","tt":2,"tp":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[60,60,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":0,"s":[0,0]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":5,"s":[10,10]},{"i":{"x":[0.463,0.463],"y":[1,1]},"o":{"x":[0.753,0.753],"y":[0,0]},"t":15,"s":[10,10]},{"i":{"x":[0.833,0.833],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0,0]},"t":20,"s":[6,6]},{"i":{"x":[0.833,0.833],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0,0]},"t":21,"s":[0,0]},{"t":58,"s":[0,0]}],"ix":2},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":5,"s":[0,0],"to":[9,0],"ti":[-9,0]},{"t":20,"s":[54,0]}],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"圆环-right","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":20,"s":[1.8]},{"t":55,"s":[540]}],"ix":10},"p":{"a":0,"k":[60,60,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[36,36],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"圆环","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":19,"s":[100]},{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":20,"s":[99.5]},{"t":55,"s":[50]}],"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":90,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"小圆形-left","td":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[60,60,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":2,"s":[0,0]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":5,"s":[4,4]},{"i":{"x":[0.463,0.463],"y":[1,1]},"o":{"x":[0.753,0.753],"y":[0,0]},"t":15,"s":[4,4]},{"t":19,"s":[0,0]}],"ix":2},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":5,"s":[0,0],"to":[-9,0],"ti":[9,0]},{"t":20,"s":[-54,0]}],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"圆形-left","tt":2,"tp":4,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[60,60,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":0,"s":[0,0]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":5,"s":[10,10]},{"i":{"x":[0.463,0.463],"y":[1,1]},"o":{"x":[0.753,0.753],"y":[0,0]},"t":15,"s":[10,10]},{"i":{"x":[0.833,0.833],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0,0]},"t":20,"s":[6,6]},{"t":21,"s":[0,0]}],"ix":2},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":5,"s":[0,0],"to":[-9,0],"ti":[9,0]},{"t":20,"s":[-54,0]}],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"圆环-left","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":20,"s":[1.8]},{"t":55,"s":[540]}],"ix":10},"p":{"a":0,"k":[60,60,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[36,36],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"圆环","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":19,"s":[100]},{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":20,"s":[99.5]},{"t":55,"s":[50]}],"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":270,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":7,"ty":4,"nm":"logo","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[59.257,59.257,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.667,0.667,0.333],"y":[0,0,0]},"t":20,"s":[0,0,100]},{"i":{"x":[0,0,0.833],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.167],"y":[0,0,0]},"t":40,"s":[105,105,100]},{"t":50,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[-2.102,-3.881],[-8.718,-7.7],[-6.297,-1.334],[-3.107,-2.843],[-2.348,-0.811],[-8.964,0.206],[-10,2.115],[-5.015,2.618],[-8.841,10],[-1.979,3.522],[0.698,10],[10,7.208],[7.18,2.495],[6.298,6.191],[1.723,5.688],[1.98,1.992],[9.344,1.355],[7.313,-1.334],[0.698,-0.554],[2.103,-2.341],[8.719,-3.881],[5.795,-7.957],[0.441,-3.1],[2.226,-7.833],[-2.861,-10]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"logo","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}} \ No newline at end of file diff --git a/module_common/src/main/res/drawable/refresh_anim.xml b/module_common/src/main/res/drawable/refresh_anim.xml deleted file mode 100644 index 0fe71c7fdf..0000000000 --- a/module_common/src/main/res/drawable/refresh_anim.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/module_common/src/main/res/layout/reuse_loading.xml b/module_common/src/main/res/layout/reuse_loading.xml index f75775d4c3..80064fd863 100644 --- a/module_common/src/main/res/layout/reuse_loading.xml +++ b/module_common/src/main/res/layout/reuse_loading.xml @@ -1,16 +1,17 @@ - + app:lottie_autoPlay="true" + app:lottie_fileName="lottie/refresh_loading.json" + app:lottie_loop="true" /> \ No newline at end of file