fix:【光环助手】游戏专题-游戏名称显示问题 https://jira.shanqu.cc/browse/GHZSCY-6463

This commit is contained in:
张晨
2024-08-08 14:17:38 +08:00
parent 0f596836dc
commit 373fa7fc80
2 changed files with 22 additions and 8 deletions

View File

@ -30,6 +30,13 @@ class CustomGameHorizontalSlideAdapter(
private var isShowFirstLine = false
private var isShowSecondLine = false
/**
* 当第一屏所有的 游戏名称都只有一行的长度时recyclerView的整体高度会被固定
* 后续就算出现了两行长度的游戏,标题栏仍然只能显示一行
* 所以:这里需要提前计算,当列表中出现一个需要展示两行标题高度的游戏,则所有游戏标题设为两行
* */
private var hasTwoLinesName = false
private lateinit var _data: CustomSubjectItem
private val subjectEntity: SubjectEntity
@ -39,18 +46,25 @@ class CustomGameHorizontalSlideAdapter(
fun setData(data: CustomSubjectItem, exposureEventList: List<ExposureEvent>?) {
isShowFirstLine = false
isShowSecondLine = false
hasTwoLinesName = false
_data = data
_exposureEventList = exposureEventList
data.data.data?.forEach {
if (!isShowFirstLine && it.assignRemark.firstLine.isNotEmpty()) {
isShowFirstLine = true
}
if (!isShowSecondLine && it.assignRemark.secondLine.isNotEmpty()) {
isShowSecondLine = true
}
val gameName = it.name ?: ""
if (!subjectEntity.showDownload && !hasTwoLinesName && gameName.length > 5) {
hasTwoLinesName = true
}
}
submitList(data.data.data)
}
override fun getKey(t: GameEntity): String {
if (!isShowFirstLine && t.assignRemark.firstLine.isNotEmpty()) {
isShowFirstLine = true
}
if (!isShowSecondLine && t.assignRemark.secondLine.isNotEmpty()) {
isShowSecondLine = true
}
return t.id
}
@ -64,7 +78,7 @@ class CustomGameHorizontalSlideAdapter(
holder.binding.root.layoutParams =
ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
holder.binding.simpleGameContainer.downloadBtn.goneIf(!subjectEntity.showDownload)
holder.binding.simpleGameContainer.gameName.maxLines = if (subjectEntity.showDownload) 1 else 2
holder.binding.simpleGameContainer.gameName.setLines(if (hasTwoLinesName) 2 else 1)
val gameEntity = getItem(position)
holder.binding.simpleGameContainer.run {
gameName.setTextColor(R.color.text_primary.toColor(root.context))