package com.swago.room.pk

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.swago.baseswago.cusview.SwagoLevelView
import com.swago.baseswago.model.live.pk.PKLiverModel
import com.swago.baseswago.util.AppContext
import com.swago.loadUrl
import com.swago.room.R
import de.hdodenhof.circleimageview.CircleImageView

class PKListAdapter : BaseQuickAdapter<PKLiverModel,BaseViewHolder>(R.layout.item_pk_search, arrayListOf()) {

    override fun convert(helper: BaseViewHolder?, item: PKLiverModel?) {
        helper?.apply {
            item?.let {
                setText(R.id.tvName,it.user_name)

                val ivAvatar = itemView.findViewById<CircleImageView>(R.id.ivAvatar)
                ivAvatar.loadUrl(itemView.context,it.user_head_img_url)
                val tvLevel = itemView.findViewById<SwagoLevelView>(R.id.tvLevel)
                tvLevel.setUserLevel(it.user_level)

                if (it.user_sex==0){
                    setImageResource(R.id.ivSex,R.mipmap.male)
                }else{
                    setImageResource(R.id.ivSex,R.mipmap.female)
                }

                setText(R.id.tvID,AppContext.getContext().resources.getString(R.string.id_x).format(it.id))
                setText(R.id.tvFans,AppContext.getContext().resources.getString(R.string.fans_x).format(it.user_fans_num))

                addOnClickListener(R.id.tvPK)

            }
        }
    }
}