fix:【光环助手V5.12.0】游戏详情新增“内容卡片”功能(0727测试2-4、8(3)) https://git.shanqu.cc/pm/halo/halo-app-issues/-/issues/1953
This commit is contained in:
@ -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 {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,33 +2,19 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/cardContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backgroundIv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/bg_content_card_large_primary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/spaceStart"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/bg_content_card_large_primary"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/iconIv"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="11dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/spaceStart"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
@ -61,7 +47,7 @@
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/spaceEnd"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="32" />
|
||||
|
||||
@ -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" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/spaceEnd"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/backgroundIv"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -1,27 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/cardContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backgroundIv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/bg_content_card_small"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/bg_content_card_small">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/iconIv"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="11dp"
|
||||
app:layout_constraintEnd_toEndOf="@id/backgroundIv"
|
||||
app:layout_constraintStart_toStartOf="@id/backgroundIv"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
@ -31,11 +23,11 @@
|
||||
android:layout_marginTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/text_title"
|
||||
android:textSize="@dimen/tag_text_size"
|
||||
android:textAlignment="center"
|
||||
app:layout_constraintEnd_toEndOf="@+id/backgroundIv"
|
||||
app:layout_constraintStart_toStartOf="@+id/backgroundIv"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iconIv"
|
||||
tools:text="最新开服最新开服" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user