package com.yidianling.medical.im.view

import android.content.Context
import android.view.View
import android.widget.LinearLayout
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.avchatkit.common.util.TimeUtil
import com.yidianling.im.R
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import kotlinx.android.synthetic.main.medical_im_system_item_view.view.*

/**
 * 互动列表系统消息itemView
 */
class MedicalSystemItemView(mContext: Context) : LinearLayout(mContext) {

    init {
        val params = LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT
        )
        layoutParams = params
        View.inflate(mContext, R.layout.medical_im_system_item_view, this)
    }

    fun initData(bean: ChatItemBean?) {
        bean?.let {

            if (bean.timeStr.isNotEmpty()) {
                chat_message_time.text = bean.timeStr
            }

            if (bean.title.isNotEmpty()) {
                chat_message_content.text = bean.title
            } else {
                chat_message_content.text = "暂无新消息"
            }

            if (bean.unReadNum > 0) {
                chat_message_unread_num.visibility = View.VISIBLE
            } else {
                chat_message_unread_num.visibility = View.GONE
            }
        }
    }

}