首页大图游戏 摘要前增加游戏标签

This commit is contained in:
kehaoyuan
2020-01-10 18:25:02 +08:00
parent 141a6df8ab
commit e40e655bfa
5 changed files with 27 additions and 8 deletions

View File

@ -2,20 +2,37 @@ package com.gh.gamecenter.home
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.style.RelativeSizeSpan
import com.gh.base.BaseRecyclerViewHolder
import com.gh.common.util.DisplayUtils
import com.gh.common.util.RandomUtils
import com.gh.common.util.toColor
import com.gh.common.view.RoundStrokeBackgroundColorSpan
import com.gh.gamecenter.R
import com.gh.gamecenter.databinding.HomeGameItemBinding
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.TagStyleEntity
import com.halo.assistant.HaloApp
class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
fun bindGame(game: GameEntity) {
val firstTag = if (game.getTag().isNotEmpty()) game.getTag()[0] + " " else ""
game.tagStyle = arrayListOf(TagStyleEntity(name = firstTag + game.brief, color = "999999"))
binding.data = game
val firstTag = if (game.tagStyle.isNotEmpty()) " " + game.tagStyle[0].name + " " else ""
val gameBrief = SpannableStringBuilder(firstTag + " " + game.brief)
if (firstTag.isNotEmpty()) {
val tagSpan = RoundStrokeBackgroundColorSpan(
R.color.text_979A9F.toColor(),
R.color.text_666666.toColor(),
DisplayUtils.dip2px(1F),
DisplayUtils.sp2px(HaloApp.getInstance().application, 9F))
gameBrief.setSpan(RelativeSizeSpan(0.8f), 0, firstTag.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
gameBrief.setSpan(tagSpan, 0, firstTag.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
binding.includeGame.gameTags.text = gameBrief
val hierarchy = binding.gameImage.hierarchy
try {
hierarchy.setPlaceholderImage(ColorDrawable(Color.parseColor(game.homeSetting.placeholderColor)))

View File

@ -7,6 +7,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.databind.BindingAdapters
import com.gh.common.exposure.ExposureEvent
import com.gh.common.util.DataLogUtils
import com.gh.common.util.DirectUtils
@ -79,7 +80,7 @@ class HomeSlideListAdapter(context: Context,
GameDetailActivity.startGameDetailActivity(mContext, linkGame.id, "(新首页-轮播图)", findExposureEvent(homeSlide.linkId))
}
}
BindingAdapters.setGameTags(holder.binding.includeGame.gameTags, homeSlide.linkGame?.tagStyle, 3)
holder.binding.unknownBackground.goneIf(DirectUtils.directLinkTypes.contains(homeSlide.linkType))
}