package com.renrenliao.im.ui.adapter

import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.renrenliao.im.R
import com.renrenliao.im.ext.gone
import com.renrenliao.im.ext.visible
import com.renrenliao.im.im.GroupEntity
import com.renrenliao.im.utils.DataCacheUtils
import com.renrenliao.im.utils.GlideUtils

/**
 **@ClassName GroupListAdapter
 **@Description
 **@Author gan
 **@Date 2022/6/10 16:37
 **/
class GroupListAdapter:BaseQuickAdapter<GroupEntity,BaseViewHolder>(R.layout.item_grouplist) {

    override fun convert(holder: BaseViewHolder, item: GroupEntity) {
        val tv_group_name = holder.getView<TextView>(R.id.tv_group_name)
        val tv_owner = holder.getView<TextView>(R.id.tv_owner)
        val tv_member_num = holder.getView<TextView>(R.id.tv_member_num)
        val iv_group = holder.getView<ImageView>(R.id.iv_group)
        val iv_silent = holder.getView<ImageView>(R.id.iv_silent)
        val iv_owner = holder.getView<ImageView>(R.id.iv_owner)

        tv_group_name.text = item.gName
        tv_owner.text = item.createUserName
        if (item.unnotify == 0){
            iv_silent.gone()
        }else{
            iv_silent.visible()
        }
        if (item.gOwnerUserUid == DataCacheUtils.getUid()){
            iv_owner.visible()
        }else{
            iv_owner.gone()
        }
        GlideUtils.loadUserImage(iv_group,item.groupAvatarImage)
    }
}