diff --git a/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt index 9dc4b61b42..04e6c8bc74 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/game/GameItemViewHolder.kt @@ -4,6 +4,7 @@ import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.view.View import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintSet import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.common.databind.BindingAdapters import com.gh.gamecenter.common.utils.dip2px @@ -49,11 +50,11 @@ class GameItemViewHolder(var binding: GameItemBinding) : BaseRecyclerViewHolder< gameDes.text = entity.decoratedDes recommendStar.rating = entity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((entity.serverLabel == null || entity.advanceDownload) && entity.subtitle.isNotEmpty())) - if ((entity.serverLabel == null || entity.advanceDownload) && entity.subtitle.isNotEmpty()) { + if (entity.serverLabel == null && entity.subtitle.isNotEmpty() && !entity.advanceDownload) { gameSubtitleTv.run { - text = if (entity.advanceDownload) "预下载" else entity.subtitle - if (entity.subtitleStyle != null && !entity.advanceDownload) { + visibility = View.VISIBLE + text = entity.subtitle + if (entity.subtitleStyle != null) { setTextColor(Color.parseColor("#${entity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -65,15 +66,26 @@ class GameItemViewHolder(var binding: GameItemBinding) : BaseRecyclerViewHolder< setColor(Color.parseColor("#${entity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (entity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (entity.serverLabel != null && !entity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } } diff --git a/app/src/main/java/com/gh/gamecenter/game/vertical/GameItemUi.kt b/app/src/main/java/com/gh/gamecenter/game/vertical/GameItemUi.kt index 1d69733e4e..c33a3539a7 100644 --- a/app/src/main/java/com/gh/gamecenter/game/vertical/GameItemUi.kt +++ b/app/src/main/java/com/gh/gamecenter/game/vertical/GameItemUi.kt @@ -66,15 +66,15 @@ class GameItemUi(override val ctx: Context) : Ui { downloadTv = initDownloadTv() gameDesTv = initGameDesTv() gameRatingTv = initGameRatingTv() - recommendIv = SimpleDraweeView(ctx) + recommendIv = SimpleDraweeView(ctx).apply { id = R.id.recommendIv } recommendTv = initRecommendTv() downloadSpeedTv = initDownloadSpeedTv() downloadPercentageTv = initDownloadPercentageTv() downloadProgressBar = initDownloadProgressBar() - gameTagContainer = GameTagContainerView(ctx) - mGameDesSpace = space { } + gameTagContainer = GameTagContainerView(ctx).apply { id = R.id.label_list } + mGameDesSpace = space { }.apply { id = R.id.gameDesSpace } recommendConstraintLayout = initRecommendConstraintLayout() - gameInfoGroup = group(downloadSpeedTv, downloadPercentageTv) + gameInfoGroup = group(downloadSpeedTv, downloadPercentageTv).apply { id = R.id.gameInfoContainer } add(iconIv, lParams(dip(64), dip(64)) { topOfParent() @@ -180,10 +180,13 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initIconView(): GameIconView { - return GameIconView(ctx) + return GameIconView(ctx).apply { + id = R.id.gameIconView + } } private fun initOrderTv() = textView { + id = R.id.gameOrder centerText() minWidth = dip(24) minHeight = dip(24) @@ -194,6 +197,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initGameNameTv() = textView { + id = R.id.game_name setSingleLine() includeFontPadding = false typeface = Typeface.DEFAULT_BOLD @@ -203,6 +207,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initGameSubtitleTv() = textView { + id = R.id.gameSubtitleTv setSingleLine() includeFontPadding = false textSize = 10F @@ -213,6 +218,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initServerTypeTv() = textView { + id = R.id.game_server_type textSize = 9F setTextColor(Color.WHITE) gravity = Gravity.CENTER @@ -227,6 +233,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initGameDesTv() = textView { + id = R.id.game_des textSize = 10F setSingleLine() includeFontPadding = false @@ -235,6 +242,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initDownloadTv() = textView { + id = R.id.download_btn textSize = 12F setTextColor(Color.WHITE) text = "下载" @@ -243,6 +251,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initGameRatingTv() = textView { + id = R.id.game_rating typeface = Typeface.DEFAULT_BOLD compoundDrawablePadding = dip(4) includeFontPadding = false @@ -251,6 +260,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initRecommendConstraintLayout() = constraintLayout { + id = R.id.recommendContainer startPadding = dip(4) endPadding = dip(8) visibility = View.GONE @@ -276,6 +286,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initRecommendTv() = textView { + id = R.id.recommendTv textSize = 10F maxLines = 1 includeFontPadding = false @@ -287,6 +298,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initDownloadPercentageTv() = textView { + id = R.id.download_percentage textSize = 9F setSingleLine() ellipsize = TextUtils.TruncateAt.END @@ -296,6 +308,7 @@ class GameItemUi(override val ctx: Context) : Ui { } private fun initDownloadSpeedTv() = textView { + id = R.id.download_speed textSize = 9F setSingleLine() ellipsize = TextUtils.TruncateAt.END @@ -305,6 +318,7 @@ class GameItemUi(override val ctx: Context) : Ui { private fun initDownloadProgressBar(): ProgressBar { return ProgressBar(ctx, null, android.R.attr.progressBarStyleHorizontal).apply { + id = R.id.game_progressbar max = 1000 progress = 500 progressDrawable = ContextCompat.getDrawable(context, R.drawable.progressbar_bg_style) diff --git a/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt index 2a9dc98543..c492c634f0 100644 --- a/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt @@ -4,7 +4,9 @@ import android.content.Context import android.graphics.Color import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable +import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView import com.gh.common.databind.BindingAdapters import com.gh.common.util.DownloadItemUtils @@ -85,11 +87,11 @@ class GameVerticalAdapter( BindingAdapters.setGameTags(gameTagContainer, gameEntity) GameItemViewHolder.initServerType(gameNameTv, serverTypeTv, gameEntity) gameDesTv.text = gameEntity.decoratedDes - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -101,15 +103,26 @@ class GameVerticalAdapter( setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } mGameDesSpace.post { gameSubtitleTv.maxWidth = mGameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.game_server_type, ConstraintSet.START) + }.applyTo(root) + } var gameRatingPaddingEnd = 0 var gameRatingDrawableStart: Drawable? = null diff --git a/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt b/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt index af7d85f1b3..4dd36619f0 100644 --- a/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/gamecollection/detail/GameCollectionDetailAdapter.kt @@ -11,6 +11,7 @@ import android.text.TextUtils import android.util.SparseArray import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.gh.common.databind.BindingAdapters @@ -592,11 +593,11 @@ open class GameCollectionDetailAdapter( gameRating.setTextColor(if (gameEntity.commentCount > 3) R.color.theme_font.toColor(mContext) else R.color.theme.toColor(mContext)) gameDes.text = gameEntity.decoratedDes recommendStar.rating = gameEntity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -608,15 +609,26 @@ open class GameCollectionDetailAdapter( setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } root.setPadding( 16F.dip2px(), 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 eef6f1f1b5..e0f9e82d62 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt @@ -848,7 +848,7 @@ class GameDetailFragment : ToolbarFragment() { } mBodyBinding.gamedetailTvName.text = mGameEntity!!.name - if (mGameEntity!!.subtitle.isNotEmpty()) { + if (mGameEntity!!.subtitle.isNotEmpty() || mGameEntity!!.advanceDownload) { initGameSubtitle(mBodyBinding.gamedetailTvName, mGameEntity!!.subtitle, mGameEntity!!.subtitleStyle, mGameEntity!!.advanceDownload) } mBodyBinding.gamedetailTvName.isSelected = true diff --git a/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt index 8210b35d9c..a0ed9eb2fb 100644 --- a/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt @@ -4,6 +4,7 @@ import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.graphics.drawable.GradientDrawable import android.view.View +import androidx.constraintlayout.widget.ConstraintSet import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.core.utils.RandomUtils import com.gh.gamecenter.R @@ -27,11 +28,11 @@ class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerVie View.VISIBLE } else View.GONE }, 5) - binding.gameSubtitleTv.goneIf(!((game.serverLabel == null || game.advanceDownload) && game.subtitle.isNotEmpty())) - if ((game.serverLabel == null || game.advanceDownload) && game.subtitle.isNotEmpty()) { + if (game.serverLabel == null && game.subtitle.isNotEmpty() && !game.advanceDownload) { binding.gameSubtitleTv.run { - text = if (game.advanceDownload) "预下载" else game.subtitle - if (game.subtitleStyle != null && !game.advanceDownload) { + visibility = View.VISIBLE + text = game.subtitle + if (game.subtitleStyle != null) { setTextColor(Color.parseColor("#${game.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -43,15 +44,26 @@ class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerVie setColor(Color.parseColor("#${game.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } binding.gameTags.post { binding.gameSubtitleTv.maxWidth = binding.gameTags.width + 24F.dip2px() } } + if (game.advanceDownload) { + binding.gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (game.serverLabel != null && !game.advanceDownload) { + ConstraintSet().apply { + clone(binding.root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(binding.root) + } val hierarchy = binding.gameImage.hierarchy try { diff --git a/app/src/main/java/com/gh/gamecenter/home/slide/HomeSlideListItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/home/slide/HomeSlideListItemViewHolder.kt index 0ad53de755..c32f59e409 100644 --- a/app/src/main/java/com/gh/gamecenter/home/slide/HomeSlideListItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/home/slide/HomeSlideListItemViewHolder.kt @@ -4,6 +4,7 @@ import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.graphics.drawable.GradientDrawable import android.view.View +import androidx.constraintlayout.widget.ConstraintSet import com.facebook.imagepipeline.image.ImageInfo import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.R @@ -39,11 +40,11 @@ class HomeSlideListItemViewHolder(val binding: HomeSlideListItemBinding) : BaseR binding.includeGame.gameName.setTextColor(R.color.white.toColor()) homeSlide.linkGame?.let { - binding.includeGame.gameSubtitleTv.goneIf(!((it.serverLabel == null || it.advanceDownload) && it.subtitle.isNotEmpty())) - if ((it.serverLabel == null || it.advanceDownload) && it.subtitle.isNotEmpty()) { + if (it.serverLabel == null && it.subtitle.isNotEmpty() && !it.advanceDownload) { binding.includeGame.gameSubtitleTv.run { - text = if (it.advanceDownload) "预下载" else it.subtitle - if (it.subtitleStyle != null && !it.advanceDownload) { + visibility = View.VISIBLE + text = it.subtitle + if (it.subtitleStyle != null) { setTextColor(Color.parseColor("#${it.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -55,12 +56,23 @@ class HomeSlideListItemViewHolder(val binding: HomeSlideListItemBinding) : BaseR setColor(Color.parseColor("#${it.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } } + if (it.advanceDownload) { + binding.includeGame.gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (it.serverLabel != null && !it.advanceDownload) { + ConstraintSet().apply { + clone(binding.includeGame.root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(binding.includeGame.root) + } } binding.bottomGradient.visibility = View.GONE diff --git a/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt b/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt index da87c01f02..e50320129e 100644 --- a/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mygame/MyFollowedGameAdapter.kt @@ -6,6 +6,7 @@ import android.graphics.drawable.GradientDrawable import android.util.SparseArray import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters @@ -81,11 +82,11 @@ class MyFollowedGameAdapter(context: Context, var mViewModel: MyFollowedGameView gameRating.setTextColor(if (gameEntity.commentCount > 3) R.color.theme_font.toColor(mContext) else R.color.theme.toColor(mContext)) gameDes.text = gameEntity.decoratedDes recommendStar.rating = gameEntity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -97,15 +98,26 @@ class MyFollowedGameAdapter(context: Context, var mViewModel: MyFollowedGameView setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } root.setBackgroundColor(R.color.background_white.toColor(mContext)) moreBtn.visibility = View.GONE diff --git a/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt b/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt index 9c632c782c..379c9ac128 100644 --- a/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mygame/MyReservationAdapter.kt @@ -4,7 +4,9 @@ import android.content.Context import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.util.SparseArray +import android.view.View import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.common.constant.ItemViewType import com.gh.common.databind.BindingAdapters @@ -85,11 +87,11 @@ class MyReservationAdapter(context: Context, var mViewModel: MyReservationViewMo gameRating.setTextColor(if (gameEntity.commentCount > 3) R.color.theme_font.toColor(mContext) else R.color.theme.toColor(mContext)) gameDes.text = gameEntity.decoratedDes recommendStar.rating = gameEntity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -101,15 +103,26 @@ class MyReservationAdapter(context: Context, var mViewModel: MyReservationViewMo setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } } diff --git a/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt b/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt index ba7d072401..3aee832cbc 100644 --- a/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/mygame/PlayedGameAdapter.kt @@ -12,6 +12,7 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.core.AppExecutor import com.gh.gamecenter.common.constant.ItemViewType @@ -132,11 +133,11 @@ open class PlayedGameAdapter( gameRating.setTextColor(if (gameEntity.commentCount > 3) R.color.theme_font.toColor() else R.color.theme.toColor()) gameDes.text = gameEntity.decoratedDes recommendStar.rating = gameEntity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -148,15 +149,26 @@ open class PlayedGameAdapter( setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } holder.binding.gameItemIncluded.run { diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt b/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt index c9e7b18ba9..dd138e8b4d 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameIndexAdapter.kt @@ -9,6 +9,7 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import androidx.collection.ArrayMap +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.ItemViewType @@ -137,11 +138,11 @@ class SearchGameIndexAdapter( gameRating.setTextColor(if (gameEntity.commentCount > 3) R.color.theme_font.toColor() else R.color.theme.toColor()) gameDes.text = gameEntity.decoratedDes recommendStar.rating = gameEntity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -153,15 +154,26 @@ class SearchGameIndexAdapter( setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } binding.topDivider.goneIf(position == 0) binding.gameItemIncluded.root.setPadding( diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt b/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt index 3dafe546d6..47bcd32261 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameResultAdapter.kt @@ -8,6 +8,7 @@ import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import androidx.collection.ArrayMap +import androidx.constraintlayout.widget.ConstraintSet import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.ItemViewType @@ -202,11 +203,11 @@ class SearchGameResultAdapter( gameRating.setTextColor(if (gameEntity.commentCount > 3) R.color.theme_font.toColor() else R.color.theme.toColor()) gameDes.text = gameEntity.decoratedDes recommendStar.rating = gameEntity.recommendStar.toFloat() - gameSubtitleTv.goneIf(!((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty())) - if ((gameEntity.serverLabel == null || gameEntity.advanceDownload) && gameEntity.subtitle.isNotEmpty()) { + if (gameEntity.serverLabel == null && gameEntity.subtitle.isNotEmpty() && !gameEntity.advanceDownload) { gameSubtitleTv.run { - text = if (gameEntity.advanceDownload) "预下载" else gameEntity.subtitle - if (gameEntity.subtitleStyle != null && !gameEntity.advanceDownload) { + visibility = View.VISIBLE + text = gameEntity.subtitle + if (gameEntity.subtitleStyle != null) { setTextColor(Color.parseColor("#${gameEntity.subtitleStyle?.color}")) background = GradientDrawable().apply { cornerRadius = 2F.dip2px().toFloat() @@ -218,15 +219,26 @@ class SearchGameResultAdapter( setColor(Color.parseColor("#${gameEntity.subtitleStyle?.background}")) } } - } else { - setTextColor(R.color.text_subtitle.toColor(context)) - background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) } } gameDesSpace.post { gameSubtitleTv.maxWidth = gameDesSpace.width } } + if (gameEntity.advanceDownload) { + gameSubtitleTv.apply { + visibility = View.VISIBLE + text = "预下载" + setTextColor(R.color.text_subtitle.toColor(context)) + background = R.drawable.bg_advance_download_game_subtitle.toDrawable(context) + } + } + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) { + ConstraintSet().apply { + clone(root) + connect(R.id.game_name, ConstraintSet.END, R.id.recent_played_tag, ConstraintSet.START) + }.applyTo(root) + } } binding.gameItemIncluded.root.setPadding(16F.dip2px(), 16F.dip2px(), 16F.dip2px(), 16F.dip2px()) holder.initServerType(gameEntity) diff --git a/app/src/main/res/layout/game_item.xml b/app/src/main/res/layout/game_item.xml index dca5f4484c..e2762f90b0 100644 --- a/app/src/main/res/layout/game_item.xml +++ b/app/src/main/res/layout/game_item.xml @@ -108,7 +108,7 @@ android:id="@+id/game_kaifu_type" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" + android:layout_marginLeft="4dp" android:background="@color/theme" android:gravity="center" android:maxLines="1"