package com.gh.gamecenter.game.bigimagerecommend

import com.gh.common.util.DirectUtils
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.databinding.BigImageRecommendItemBinding
import com.gh.gamecenter.entity.SubjectEntity

/**
 * 提问、帖子、视频帖、文章
 */
class BigImageRecommendViewHolder(val binding: BigImageRecommendItemBinding) :
    BaseRecyclerViewHolder<Any>(binding.root) {

    fun bindBigImageRecommend(subjectEntity: SubjectEntity, entrance: String, clickCallback: (LinkEntity) -> Unit) {
        binding.run {
            ImageUtils.display(poster, subjectEntity.image)
            recommendTag.goneIf(subjectEntity.recommendTag.isEmpty())
            recommendTextTwo.goneIf(subjectEntity.secondLineRecommend.isEmpty())
            recommendTag.text = subjectEntity.recommendTag
            recommendTextOne.text = subjectEntity.firstLineRecommend
            recommendTextTwo.text = subjectEntity.secondLineRecommend
            root.setOnClickListener {
                val linkEntity =
                    LinkEntity(link = subjectEntity.id, type = subjectEntity.type, linkText = subjectEntity.columnName)
                clickCallback.invoke(linkEntity)
                DirectUtils.directToLinkPage(root.context, linkEntity, entrance, "")
            }
        }
    }
}