微调首页轮播图上边距
This commit is contained in:
@ -193,6 +193,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_UUID = "uuid";
|
||||
public static final String KEY_IS_HOME_VIDEO = "isHomeVideo";
|
||||
public static final String KEY_IS_HOME = "isHome";
|
||||
public static final String KEY_TAB_COUNT = "tab_count";
|
||||
public static final String KEY_WEB_SHARE = "webShare";
|
||||
public static final String KEY_ACTIVITY_NAME = "activityName";//活动名称
|
||||
public static final String KEY_PAGINATION_TYPE = "paginationType";//活动分页方式
|
||||
|
||||
@ -250,7 +250,7 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
val fragmentList = arrayListOf<Fragment>()
|
||||
for (tab in tabList) {
|
||||
val fragment = when (tab.type) {
|
||||
"home" -> HomeFragment()
|
||||
"home" -> HomeFragment().with(Bundle())
|
||||
"top_game_comment" -> AmwayFragment().with(Bundle())
|
||||
"block" -> GameFragment().with(Bundle().apply {
|
||||
putParcelable(EntranceUtils.KEY_BLOCK_DATA, tab)
|
||||
@ -290,8 +290,9 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
"bbs" -> Fragment()
|
||||
else -> Fragment()
|
||||
}
|
||||
fragment.arguments?.putInt(EntranceUtils.KEY_TAB_COUNT, tabList.size)
|
||||
fragment.arguments?.putBoolean(EntranceUtils.KEY_IS_HOME, true)
|
||||
fragment.arguments?.putParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE, ExposureSource("首页顶部Tab栏", tab.name!!))
|
||||
fragment.arguments?.putParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE, ExposureSource("首页顶部Tab栏", tab.name ?: ""))
|
||||
fragmentList.add(fragment)
|
||||
}
|
||||
return fragmentList
|
||||
|
||||
@ -64,6 +64,7 @@ class HomeFragment : BaseFragment<Any>() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mViewModel = ViewModelProviders.of(this).get(HomeViewModel::class.java)
|
||||
mViewModel.homeOnlyWithoutOtherTab = arguments?.getInt(EntranceUtils.KEY_TAB_COUNT) == 1
|
||||
mViewModel.itemDataList.observeNonNull(this, callback = {
|
||||
mListAdapter.submitList(it)
|
||||
})
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.home
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.constant.ItemViewType
|
||||
@ -131,7 +132,13 @@ class HomeFragmentAdapter(context: Context,
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (holder) {
|
||||
is HomeSlideListViewHolder -> holder.bindSlideList(mDataList[position], mBasicExposureSource)
|
||||
is HomeSlideListViewHolder -> {
|
||||
// 根据首页是否有其它 tab 设置不同的 marginTop
|
||||
val marginTop = if (viewModel.homeOnlyWithoutOtherTab) 4F.dip2px() else 0
|
||||
(holder.binding.recyclerView.layoutParams as ConstraintLayout.LayoutParams)
|
||||
.setMargins(0, marginTop, 0, 0)
|
||||
holder.bindSlideList(mDataList[position], mBasicExposureSource)
|
||||
}
|
||||
is HomeRecommendItemViewHolder -> holder.bindRecommend(mDataList[position].recommends!!)
|
||||
is HomeAmwayListViewHolder -> bindAmway(holder, position)
|
||||
is HomeGameItemViewHolder -> bindAttachGame(holder, position)
|
||||
|
||||
@ -46,6 +46,9 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
// 所有专题里的所有游戏 ID 集合,供替换时排重用
|
||||
private var mSubjectGameIdList = hashSetOf<String>()
|
||||
|
||||
// 首页是否只有首页,不显示其它 tab
|
||||
var homeOnlyWithoutOtherTab = false
|
||||
|
||||
var itemDataList: MediatorLiveData<List<HomeItemData>> = MediatorLiveData()
|
||||
var positionAndPackageMap = HashMap<String, Int>() // key: packageName + position, value: position
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
<dimen name="home_item_padding">16dp</dimen>
|
||||
<dimen name="home_large_image_radius">6dp</dimen>
|
||||
<dimen name="home_recyclerview_padding_top">8dp</dimen>
|
||||
<dimen name="home_recyclerview_padding_top">4dp</dimen>
|
||||
|
||||
<dimen name="home_column_collection_height">122dp</dimen>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user