package com.swago.room.audio

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.swago.baseswago.cusview.SwagoImageView
import com.swago.baseswago.model.live.audio.AudioSeatModel
import com.swago.room.R

class AudioSeatAdapter :
    BaseQuickAdapter<AudioSeatModel, BaseViewHolder>(R.layout.item_audio_seat, arrayListOf()) {

    override fun convert(helper: BaseViewHolder?, item: AudioSeatModel?) {
        helper?.apply {
            item?.let {
                if (it.user_id == "0") {
                    setVisible(R.id.tvIntegration, false)
                    setVisible(R.id.ivAudioState, false)
                    setText(R.id.tvName, "No.${layoutPosition + 1}")
                    if (it.lock_status == 2) {
                        itemView.findViewById<SwagoImageView>(R.id.ivImageView)
                            .loadImage(R.mipmap.ic_audio_lock)
                    } else {
                        itemView.findViewById<SwagoImageView>(R.id.ivImageView)
                            .loadImage(R.mipmap.ic_audio_seat)
                    }
                } else {
                    itemView.findViewById<SwagoImageView>(R.id.ivImageView)
                        .loadImage(it.user_head_img_url ?: "")
                    setText(R.id.tvName, it.user_name)

                    setVisible(R.id.tvIntegration, true)
                    if (it.voice_jifen.isNullOrEmpty()) {
                        setText(R.id.tvIntegration, "0")
                    } else {
                        setText(R.id.tvIntegration, it.voice_jifen)
                    }


                    if (it.voice_status == 2) {
                        setVisible(R.id.ivAudioState, true)
                        setImageResource(R.id.ivAudioState, R.mipmap.live_mute)
                    } else {
                        if (it.showVoice==1){
                            setImageResource(R.id.ivAudioState, R.mipmap.live_unmute)
                            setVisible(R.id.ivAudioState, true)
                        }else{
                            setVisible(R.id.ivAudioState, false)
                        }

                    }
                }
            }
        }

    }
}
