package com.yidianling.im.session.viewholder

import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.config.HttpConfig
import com.yidianling.im.R
import com.yidianling.im.session.extension.CustomAttachmentInquiryEnd
import com.yidianling.im.session.extension.CustomAttachmentRecipel
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase

/**
 * 处方单创建消息类型
 */
class MsgViewHolderRecipel(adapter: BaseMultiItemFetchLoadAdapter<*, *>?) :
    MsgViewHolderBase(adapter) {

    private var name: TextView? = null
    private var time: TextView? = null
    private var item: ConstraintLayout? = null
    var itemBean: CustomAttachmentRecipel? = null
    override fun getContentResId(): Int {
        return R.layout.im_nim_recipel_layout
    }

    override fun inflateContentView() {
        name = findViewById(R.id.name)
        time = findViewById(R.id.recipel_time)
        item = findViewById(R.id.item)
    }

    override fun bindContentView() {
        itemBean = message.attachment as CustomAttachmentRecipel
        name?.text = itemBean?.fromSickness
        time?.text =itemBean?.fromDiagnoseTime
        hideItemBg()
        setAvatarRightInVisibity()
        item?.setOnClickListener {
            NewH5Activity.start(
                view?.context, H5Params(
                    "${HttpConfig.MEDICAL_H5URL}/ct/prescription/details?recipeId=${itemBean?.fromRecipelId}",
                    "处方详情"
                )
            )
        }
    }
}