package com.swago.user.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.swago.baseswago.model.mine.RoomBlackItem
import com.swago.user.R
import de.hdodenhof.circleimageview.CircleImageView

/**
 *@date 2022/2/26 11:01
 *description:
 */
class BlackLiveRoomAdapter : BaseQuickAdapter<RoomBlackItem, BaseViewHolder>(R.layout.item_black_room, arrayListOf()) {

    override fun convert(helper: BaseViewHolder, item: RoomBlackItem) {
        helper.apply {
            setText(R.id.tvName,item.user_name)
            setText(R.id.tvCreateTIme,item.created_at)

            val ivAvatar = itemView.findViewById<CircleImageView>(R.id.ivAvatar)
            Glide.with(itemView.context).load(item.user_head_img_url)
                .placeholder(R.mipmap.default_avatar)
                .error(R.mipmap.default_avatar).into(ivAvatar)
            addOnClickListener(R.id.ivStatus)

            if (item.is_forbid == 1){
                setImageResource(R.id.switch1,R.mipmap.switch_on)
            }else{
                setImageResource(R.id.switch1,R.mipmap.switch_off)
            }
            if (item.is_black == 1){
                setImageResource(R.id.switch2,R.mipmap.switch_on)
            }else{
                setImageResource(R.id.switch2,R.mipmap.switch_off)
            }

            addOnClickListener(R.id.switch1)
            addOnClickListener(R.id.switch2)

        }

    }
}