diff --git a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.kt b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.kt index c94897e465..5767fc9c48 100644 --- a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.kt @@ -80,7 +80,7 @@ class GameDetailActivity : DownloadToolbarActivity() { override fun isAutoResetViewBackgroundEnabled(): Boolean = true override fun updateStaticViewBackground(view: View?) { - updateStaticView(view, listOf(R.id.menu_download_iv, R.id.gameBigEvent, R.id.backgroundIv)) + updateStaticView(view, listOf(R.id.menu_download_iv, R.id.gameBigEvent, R.id.cardContainer)) } companion object { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt index 242f470faa..9d42b2c9b2 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt @@ -650,7 +650,7 @@ class GameDetailFragment : ToolbarFragment(), IScrollable { initViewPage(data) - if (data.contentCard.size > 1) { + if (data.contentCard.size > 1 && data.mirrorStatus == "off") { initGameContentCard(data.contentCard) } @@ -1045,32 +1045,31 @@ class GameDetailFragment : ToolbarFragment(), IScrollable { mBodyBinding.contentCardContainer.visibility = View.VISIBLE if (linkEntityList.size >= 3) { linkEntityList.safelyGetInRelease(0)?.let { - mBodyBinding.contentCardContainer.addView(getLargeContentCardView(it, true), LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 2F)) + mBodyBinding.contentCardContainer.addView(getLargeContentCardView(it, true), LinearLayout.LayoutParams(0, 56F.dip2px(), 2F)) } linkEntityList.safelyGetInRelease(1)?.let { - mBodyBinding.contentCardContainer.addView(getSmallContentCardView(it), LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1F)) + mBodyBinding.contentCardContainer.addView(getSmallContentCardView(it), LinearLayout.LayoutParams(0, 56F.dip2px(), 1F)) } linkEntityList.safelyGetInRelease(2)?.let { - mBodyBinding.contentCardContainer.addView(getSmallContentCardView(it, true), LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1F)) + mBodyBinding.contentCardContainer.addView(getSmallContentCardView(it, true), LinearLayout.LayoutParams(0, 56F.dip2px(), 1F)) } } else if (linkEntityList.size == 2) { linkEntityList.safelyGetInRelease(0)?.let { - mBodyBinding.contentCardContainer.addView(getLargeContentCardView(it), LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1F)) + mBodyBinding.contentCardContainer.addView(getLargeContentCardView(it), LinearLayout.LayoutParams(0, 56F.dip2px(), 1F)) } linkEntityList.safelyGetInRelease(1)?.let { - mBodyBinding.contentCardContainer.addView(getLargeContentCardView(it, isLastView = true), LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1F)) + mBodyBinding.contentCardContainer.addView(getLargeContentCardView(it, isLastView = true), LinearLayout.LayoutParams(0, 56F.dip2px(), 1F)) } } } private fun getLargeContentCardView(contentCardEntity: ContentCardEntity, isHighlightBg: Boolean = false, isLastView: Boolean = false) = LayoutGameDetailContentCardLargeBinding.inflate(layoutInflater).apply { when { - isHighlightBg && !isLastView -> backgroundIv.setImageDrawable(R.drawable.bg_content_card_large_primary.toDrawable(requireContext())) - !isHighlightBg && !isLastView -> backgroundIv.setImageDrawable(R.drawable.bg_content_card_large.toDrawable(requireContext())) - !isHighlightBg && isLastView -> backgroundIv.setImageDrawable(R.drawable.bg_content_card_large_right.toDrawable(requireContext())) + isHighlightBg && !isLastView -> root.background = R.drawable.bg_content_card_large_primary.toDrawable(requireContext()) + !isHighlightBg && !isLastView -> root.background = R.drawable.bg_content_card_large.toDrawable(requireContext()) + !isHighlightBg && isLastView -> root.background = R.drawable.bg_content_card_large_right.toDrawable(requireContext()) } - spaceStart.layoutParams = spaceStart.layoutParams.apply { width = if (isLastView) 20F.dip2px() else 12F.dip2px()} - spaceEnd.layoutParams = spaceEnd.layoutParams.apply { width = if (isLastView) 8F.dip2px() else 12F.dip2px()} + root.setPadding(if (isLastView) 20F.dip2px() else 12F.dip2px(), 0, if (isLastView) 8F.dip2px() else 12F.dip2px(), 0) titleTv.text = contentCardEntity.title ImageUtils.display(iconIv, contentCardEntity.icon) if (contentCardEntity.des.isNotEmpty()) { @@ -1098,7 +1097,7 @@ class GameDetailFragment : ToolbarFragment(), IScrollable { }.root private fun getSmallContentCardView(contentCardEntity: ContentCardEntity, isLastView: Boolean = false) = LayoutGameDetailContentCardSmallBinding.inflate(layoutInflater).apply { - backgroundIv.setImageDrawable(if (isLastView) R.drawable.bg_content_card_small_right.toDrawable(requireContext()) else R.drawable.bg_content_card_small.toDrawable(requireContext())) + root.background = if (isLastView) R.drawable.bg_content_card_small_right.toDrawable(requireContext()) else R.drawable.bg_content_card_small.toDrawable(requireContext()) titleTv.text = contentCardEntity.title ImageUtils.display(iconIv, contentCardEntity.icon) redDotTv.goneIf(!(contentCardEntity.type == "func_server" || contentCardEntity.type == "func_libao")) @@ -1822,7 +1821,7 @@ class GameDetailFragment : ToolbarFragment(), IScrollable { mBinding.detailLlBottom.detailLlBottom.setBackgroundColor(R.color.background.toColor(requireContext())) updateToolbarStyle(mBodyBinding.gamedetailThumbSmall.visibility == View.VISIBLE) mViewModel.gameDetailLiveData.value?.data?.let { - if (it.contentCard.size > 1) { + if (it.contentCard.size > 1 && it.mirrorStatus == "off") { initGameContentCard(it.contentCard) } } diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt index 7a7e4410c3..f8197f989f 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt @@ -115,6 +115,17 @@ class GameDetailViewModel(application: Application, } } + private fun removeLatestServerIfNeeded(data: NewGameDetailEntity) { + var i = 0 + while (i < data.detailEntity.size) { + if (data.detailEntity[i].type == DetailEntity.Type.LATEST_SERVER.value) { + data.detailEntity.removeAt(i) + return + } + i++ + } + } + @SuppressLint("CheckResult") fun getGameDetailNew() { mSensitiveApi.getGameDetailNew(game?.id) @@ -129,13 +140,10 @@ class GameDetailViewModel(application: Application, && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT data.contentCard.forEach { + // 显示开服内容卡片时,游戏详情-详情tab不显示“最新开服” if (data.contentCard.size > 1 && it.type == "func_server") { - data.detailEntity.forEach detail@{ detailEntity -> - if (detailEntity.type == DetailEntity.Type.LATEST_SERVER.value) { - data.detailEntity.remove(detailEntity) - return@detail - } - } + removeLatestServerIfNeeded(data) + return@forEach } } diff --git a/app/src/main/res/layout/layout_game_detail_content_card_large.xml b/app/src/main/res/layout/layout_game_detail_content_card_large.xml index f3b249d5b3..0a939628f9 100644 --- a/app/src/main/res/layout/layout_game_detail_content_card_large.xml +++ b/app/src/main/res/layout/layout_game_detail_content_card_large.xml @@ -2,33 +2,19 @@ - - - - + android:layout_height="56dp" + android:background="@drawable/bg_content_card_large_primary" + android:paddingStart="12dp" + android:paddingEnd="12dp"> @@ -73,8 +59,8 @@ android:ellipsize="end" android:lines="1" android:textSize="@dimen/tag_text_size" - app:layout_constraintEnd_toStartOf="@+id/spaceEnd" - app:layout_constraintStart_toEndOf="@+id/spaceStart" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/iconIv" tools:text="文案内容" /> @@ -84,16 +70,8 @@ android:layout_height="14dp" android:layout_marginTop="4dp" android:visibility="gone" - app:layout_constraintEnd_toStartOf="@+id/spaceEnd" - app:layout_constraintStart_toEndOf="@+id/spaceStart" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/iconIv" /> - - \ No newline at end of file diff --git a/app/src/main/res/layout/layout_game_detail_content_card_small.xml b/app/src/main/res/layout/layout_game_detail_content_card_small.xml index a878f69ec8..25c7e7b27b 100644 --- a/app/src/main/res/layout/layout_game_detail_content_card_small.xml +++ b/app/src/main/res/layout/layout_game_detail_content_card_small.xml @@ -1,27 +1,19 @@ - - + android:layout_height="56dp" + android:background="@drawable/bg_content_card_small">