package com.bc_chat.circle.adapetr

import android.content.Context
import com.bc_chat.bc_base.entity.contact.CommentMine
import com.bc_chat.contacts.R
import com.bc_chat.contacts.databinding.ItemCommentMineLayoutBinding
import com.zhaohaoting.framework.abs.adapter.ListToAdapter
import com.zhaohaoting.framework.utils.format.MsTransformation
import com.zhaohaoting.framework.utils.glid.GlideUtils

/**
 * author：Created by zhaohaoting on 2019/8/27
 * email：526309416@qq.com
 * desc：
 */
class CommentMineAdapter(context: Context, val type: String) : ListToAdapter<CommentMine, List<CommentMine>>(context) {

    override fun getItemLayoutId(type: Int): Int = R.layout.item_comment_mine_layout

    override fun onBindViewHolderHF(baseViewHolder: BaseViewHolder<*>?, realPosition: Int, data: CommentMine?) {
        val binding = baseViewHolder?.dataBinding as ItemCommentMineLayoutBinding
        GlideUtils.loadCircleImage(context, data?.photo, binding.ivPhoto)
        binding.tvNick.text = data?.nickname
        binding.tvTime.text = MsTransformation.formatTimesBefore1(data?.c_time!! * 1000, System.currentTimeMillis())
        binding.tvContent.text = data.title
        binding.tvCommentContent.text = data.content
        binding.tvCommentReply.text = if ("1".equals(type)) "评论了您的帖子" else "回复了您的评论"
        binding.tvReply.setOnClickListener {
            onItemViewClickListener.onItemClick(baseViewHolder, it, realPosition)
        }
        binding.ivPhoto.setOnClickListener {
            onItemViewClickListener.onItemClick(baseViewHolder, it, realPosition)
        }
        binding.tvNick.setOnClickListener {
            onItemViewClickListener.onItemClick(baseViewHolder, it, realPosition)
        }
    }
}