package com.gh.gamecenter.personalhome

import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.databinding.CommunityAnswerItemBinding
import com.gh.gamecenter.entity.PersonalHistoryEntity
import com.gh.gamecenter.forum.detail.ForumDetailActivity
import com.gh.gamecenter.qa.answer.BaseAnswerOrArticleItemViewHolder

class PersonalItemViewHolder(val binding: CommunityAnswerItemBinding) :
    BaseAnswerOrArticleItemViewHolder(binding.root) {

    fun bindPersonalItem(entity: PersonalHistoryEntity, entrance: String) {
        commentCount.isClickable = true
        bindCommendAndVote(entity.transformAnswerEntity(), entrance)

        if (entity.community.type == "official_bbs") {
            forumIcon?.displayGameIcon(entity.community.icon, null)
        } else {
            forumIcon?.displayGameIcon(
                entity.community.game?.getIcon(),
                entity.community.game?.iconSubscript,
                entity.community.game?.iconFloat
            )
        }

        forumNameContainer?.setOnClickListener {
            MtaHelper.onEvent(getEventId(entrance), getKey(entrance), entity.community.name)
            itemView.context.startActivity(
                ForumDetailActivity.getIntent(
                    itemView.context,
                    entity.community.id,
                    entrance
                )
            )
        }
    }
}
