package com.adealink.weparty.im.session.adapter.viewbinder

import android.view.LayoutInflater
import android.view.ViewGroup
import com.adealink.weparty.im.databinding.LayoutSessionMessageBaseBinding
import com.adealink.weparty.im.databinding.LayoutSessionMessageUnsupportBinding
import com.adealink.weparty.im.session.adapter.data.UnSupportMessageBean
import com.adealink.weparty.util.formatTimeTo
import com.tencent.qcloud.tuikit.timcommon.interfaces.OnItemClickListener

/**
 * 对照: UnSupportMessageBean
 */

class UnSupportMessageViewHolder(
    rootBinding: LayoutSessionMessageBaseBinding,
    binding: LayoutSessionMessageUnsupportBinding
) : MessageViewHolder<UnSupportMessageBean, LayoutSessionMessageUnsupportBinding>(
    rootBinding,
    binding
) {
    override fun onBindSelfMessage(
        binding: LayoutSessionMessageUnsupportBinding,
        msg: UnSupportMessageBean
    ) {
        setMessageTime(binding, msg)
    }

    override fun onBindOtherMessage(
        binding: LayoutSessionMessageUnsupportBinding,
        msg: UnSupportMessageBean
    ) {
        setMessageTime(binding, msg)
    }

    private fun setMessageTime(
        binding: LayoutSessionMessageUnsupportBinding,
        msg: UnSupportMessageBean
    ) {
        binding.tvTime.text = formatTimeTo((msg.data.messageTime * 1000), "HH:mm")
    }
}


class UnSupportMessageViewBinder(
    onItemClickListener: OnItemClickListener
) : BaseMessageViewBinder<UnSupportMessageBean, LayoutSessionMessageUnsupportBinding, UnSupportMessageViewHolder>(
    onItemClickListener
) {
    override fun onCreateMessageHolder(
        rootBinder: LayoutSessionMessageBaseBinding,
        inflater: LayoutInflater,
        parent: ViewGroup
    ): UnSupportMessageViewHolder {
        return UnSupportMessageViewHolder(
            rootBinder,
            LayoutSessionMessageUnsupportBinding.inflate(
                inflater,
                parent,
                true
            )
        )
    }


}