package com.gh.gamecenter.video

import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.TimeUtils
import com.gh.gamecenter.databinding.VideoNewItemBinding
import com.gh.gamecenter.entity.MyVideoEntity

class VideoItemViewHolder(var binding: VideoNewItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {

    fun bindVideoItem(entity: MyVideoEntity) {
        binding.run {
            root.setRootBackgroundDrawable(com.gh.gamecenter.common.R.drawable.background_shape_white_radius_6)
            videoTitle.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(root.context))
            userName.setTextColor(com.gh.gamecenter.common.R.color.text_tertiary.toColor(root.context))
            ImageUtils.display(videoCover, entity.poster)
            videoLikeCount.text = entity.vote.toSimpleCount()
            videoCommentCount.text = entity.commentCount.toSimpleCount()
            videoDuration.text = TimeUtils.formatVideoDuration(entity.length)
            videoTitle.text = entity.title
            ImageUtils.display(userIcon, entity.user.icon)
            userIcon.hierarchy.roundingParams = userIcon.hierarchy.roundingParams?.apply {
                borderColor = com.gh.gamecenter.common.R.color.ui_background.toColor(userIcon.context)
            }
            userName.text = entity.user.name
        }
    }
}