完成首页顶部Tab栏功能(20210426测试问题) https://git.ghzs.com/pm/halo-app-issues/-/issues/1215
This commit is contained in:
@ -148,6 +148,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_RECOMMENDS_CONTENTS = "isRecommendsContents";
|
||||
public static final String KEY_VERSION_UPDATE = "versionUpdate";
|
||||
public static final String KEY_CHECK_QUESTION_CONCERN = "check_question_concern";
|
||||
public static final String KEY_IS_COLUMN_COLLECTION = "is_column_collection";//是专题合集
|
||||
public static final String KEY_DRAFT_ID = "draft_id";
|
||||
public static final String KEY_KAIFU_LIST = "kaifuList";
|
||||
public static final String KEY_CATEGORY = "category";
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.Observer
|
||||
import com.gh.base.fragment.LazyFragment
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.viewModelProviderFromParent
|
||||
import com.gh.common.view.FixLinearLayoutManager
|
||||
import com.gh.gamecenter.R
|
||||
@ -68,6 +70,12 @@ class CatalogFragment : LazyFragment() {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (arguments?.getBoolean(EntranceUtils.KEY_IS_HOME) == true) {
|
||||
mBinding?.divider?.visibility = View.GONE
|
||||
mBinding?.root?.setBackgroundColor(Color.WHITE)
|
||||
mBinding?.root?.setPadding(0, 8F.dip2px(), 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRealLayoutInflated(inflatedView: View) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.category2
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
@ -57,8 +58,10 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
directoryRv.layoutParams.width = width
|
||||
|
||||
if (arguments?.getBoolean(EntranceUtils.KEY_IS_HOME) == true) {
|
||||
root.setBackgroundColor(Color.WHITE)
|
||||
root.setPadding(0, 8F.dip2px(), 0, 0)
|
||||
directoryRv.isNestedScrollingEnabled = false
|
||||
directoryContainer.setPadding(0, 0, 0, requireContext().resources.getDimension(R.dimen.main_bottom_tab_height).toInt())
|
||||
// directoryContainer.setPadding(0, 0, 0, requireContext().resources.getDimension(R.dimen.main_bottom_tab_height).toInt())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,10 +30,12 @@ import com.gh.gamecenter.home.HomeFragment
|
||||
import com.gh.gamecenter.servers.GameServersPublishFragment
|
||||
import com.gh.gamecenter.servers.GameServersTestFragment
|
||||
import com.gh.gamecenter.subject.SubjectFragment
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.halo.assistant.fragment.WebFragment
|
||||
import com.lightgame.utils.Utils
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
/**
|
||||
* 主页以 ViewPager 的形式实现,不需要替换主 Fragment
|
||||
*/
|
||||
@ -82,6 +84,15 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
mDefaultSelectedTab = mViewModel?.defaultTabPosition ?: 0
|
||||
}
|
||||
initViewPager(it)
|
||||
|
||||
// 当 tab 为一个的时候隐藏顶部 tab 栏,停用 nestedScroll
|
||||
if (it.size == 1) {
|
||||
mBinding?.tabContainer?.visibility = View.GONE
|
||||
(mBinding?.collapsingToolbar?.layoutParams as? AppBarLayout.LayoutParams)?.let { lp ->
|
||||
lp.scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL
|
||||
}
|
||||
}
|
||||
|
||||
mBinding?.noConnectionContainer?.reuseNoConnection?.visibility = View.GONE
|
||||
mBinding?.loadingContainer?.reuseLlLoading?.visibility = View.GONE
|
||||
})
|
||||
@ -222,7 +233,7 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
tabLayout.setupWithViewPager(mBinding?.viewPager)
|
||||
indicatorView.setupWithTabLayout(mBinding?.tabLayout)
|
||||
indicatorView.setupWithViewPager(mBinding?.viewPager)
|
||||
indicatorView.setIndicatorWidth(20)
|
||||
indicatorView.setIndicatorWidth(18)
|
||||
for (i in 0 until mBinding?.tabLayout?.tabCount!!) {
|
||||
val tab = mBinding?.tabLayout?.getTabAt(i) ?: continue
|
||||
val tabTitle = if (tab.text != null) tab.text.toString() else ""
|
||||
@ -264,6 +275,7 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
putString(EntranceUtils.KEY_COLLECTION_ID, tab.link)
|
||||
putInt(EntranceUtils.KEY_POSITION, 0)
|
||||
putString(EntranceUtils.KEY_COLUMNNAME, tab.text)
|
||||
putBoolean(EntranceUtils.KEY_IS_COLUMN_COLLECTION, true)
|
||||
})
|
||||
"column" -> SubjectFragment().with(Bundle().apply {
|
||||
putString(EntranceUtils.KEY_ENTRANCE, "首页")
|
||||
|
||||
@ -79,6 +79,7 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
|
||||
?: SubjectTabFragment()
|
||||
val bundle = arguments
|
||||
bundle?.putParcelableArrayList(EntranceUtils.KEY_DATA, subjectDataList)
|
||||
bundle?.putBoolean(EntranceUtils.KEY_IS_COLUMN_COLLECTION, true)
|
||||
|
||||
fragment.arguments = bundle
|
||||
mBinding?.placeholder?.visibility = View.VISIBLE
|
||||
|
||||
@ -21,7 +21,6 @@ import com.gh.gamecenter.entity.SubjectData
|
||||
import com.gh.gamecenter.entity.SubjectSettingEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.OnTitleClickListener
|
||||
import com.lightgame.download.DataWatcher
|
||||
@ -87,7 +86,7 @@ class SubjectListFragment : LazyListFragment<GameEntity, SubjectListViewModel>()
|
||||
}
|
||||
|
||||
override fun onFragmentFirstVisible() {
|
||||
mIsColumnCollection = activity is ColumnCollectionDetailActivity
|
||||
mIsColumnCollection = arguments?.getBoolean(EntranceUtils.KEY_IS_COLUMN_COLLECTION, false) ?: false
|
||||
super.onFragmentFirstVisible()
|
||||
mSkeletonScreen = Skeleton
|
||||
.bind(mCachedView.findViewById<View>(R.id.list_skeleton))
|
||||
|
||||
@ -77,6 +77,7 @@ class SubjectViewModel(application: Application, var subjectData: SubjectData?)
|
||||
subjectData?.tagType = response.tag
|
||||
subjectData?.briefStyle = response.briefStyle
|
||||
subjectData?.showSuffix = response.showSuffix
|
||||
subjectData?.isOrder = response.order
|
||||
subjectSettingLD.postValue(response)
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/text_eeeeee" />
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
layout="@layout/reuse_loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true" />
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include
|
||||
android:id="@+id/noConnectionContainer"
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
android:layout_height="0dp" />
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/statusBar">
|
||||
@ -49,8 +50,8 @@
|
||||
<RelativeLayout
|
||||
android:id="@+id/tabContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:paddingBottom="4dp">
|
||||
android:layout_height="52dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.gh.common.view.TabIndicatorView
|
||||
android:id="@+id/indicatorView"
|
||||
|
||||
Reference in New Issue
Block a user