package com.gh.gamecenter.video

import com.gh.gamecenter.R
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(R.drawable.background_shape_white_radius_6)
            videoTitle.setTextColor(R.color.text_title.toColor(root.context))
            userName.setTextColor(R.color.text_subtitleDesc.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 = R.color.background.toColor(userIcon.context)
            }
            userName.text = entity.user.name
        }
    }
}