package com.adealink.weparty.profile.dynamic.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.adealink.frame.aab.util.getCompatString
import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
import com.adealink.weparty.profile.R
import com.adealink.weparty.profile.databinding.LayoutDynamicCommentTitleBinding
import com.adealink.weparty.profile.dynamic.fragment.data.DynamicDetailCommentTitleItem

class DynamicCommentTitleViewBinder() :
    ItemViewBinder<DynamicDetailCommentTitleItem, DynamicCommentTitleViewBinder.ViewHolder>() {

    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup,
    ): ViewHolder {
        return ViewHolder(LayoutDynamicCommentTitleBinding.inflate(inflater, parent, false))
    }

    override fun onBindViewHolder(
        holder: ViewHolder,
        item: DynamicDetailCommentTitleItem
    ) {
        holder.update(item)
    }

    class ViewHolder(
        rootBinding: LayoutDynamicCommentTitleBinding,
    ) : BindingViewHolder<LayoutDynamicCommentTitleBinding>(rootBinding) {

        private var item: DynamicDetailCommentTitleItem? = null
        fun update(item: DynamicDetailCommentTitleItem) {
            this.item = item
            binding.tvComment.text =
                getCompatString(R.string.profile_dynamic_total_comment, item.total.toString())
        }

    }

}