package com.swago.home.innerhome

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

/**
 *@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)
            Glide.with(itemView.context).load(item.user_head_img_url)
                .placeholder(R.mipmap.default_avatar)
                .error(R.mipmap.default_avatar).centerCrop().into(imageView)
//            setImageResource(R.id.ivCountry,R.drawable.flag_ac)
        }
    }
}