package com.swago.home.innerhome

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.google.android.material.imageview.ShapeableImageView
import com.swago.baseswago.cusview.BoldTextView
import com.swago.baseswago.cusview.MediumTextView
import com.swago.baseswago.cusview.SwagoLevelView
import com.swago.baseswago.model.MomentModel
import com.swago.baseswago.model.home.HomeModel
import com.swago.home.R
import com.swago.loadUrl
import com.swago.loadWebp

/**
 *@date 2021/11/27 15:23
 *description:
 */
class HomeAdapter  : BaseQuickAdapter<MomentModel, BaseViewHolder>(R.layout.item_home, arrayListOf()) {

    override fun convert(helper: BaseViewHolder, item: MomentModel) {
        helper.apply {
            itemView.findViewById<BoldTextView>(R.id.tvName).text = item.user_name
            itemView.findViewById<MediumTextView>(R.id.tvHot).text = item.broadcast_hot
            itemView.findViewById<SwagoLevelView>(R.id.levelView).setUserLevel( item.user_level)
            if (item.user_sex == 1){
                setImageResource(R.id.ivSex,R.mipmap.female)
            }else{
                setImageResource(R.id.ivSex,R.mipmap.male)
            }
            val imageView = itemView.findViewById<ShapeableImageView>(R.id.ivAvatar)
            imageView.loadUrl(itemView.context,item.user_head_img_url)
            if (item.user_broadcast_status == 1){
                itemView.findViewById<ImageView>(R.id.ivLive).loadWebp(mContext,R.mipmap.icon_living)
                setVisible(R.id.llLive,true)
            }else{
                setVisible(R.id.llLive,false)
            }

            if (item.isForbid_status||item.user_broadcast_status==0){
                setGone(R.id.llGame,false)
            }else{
                val ivGameIcon = itemView.findViewById<ImageView>(R.id.ivGameIcon)
                ivGameIcon.loadUrl(itemView.context,item.game_url)
                setGone(R.id.llGame,true)

            }

//            setImageResource(R.id.ivCountry,R.drawable.flag_ac)
        }
    }
}