package com.zj365.mime.adapter

import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.common.getImageUrl
import com.xty.common.setImageUser
import com.zj365.mime.R
import com.xty.network.model.KeeperBean
import de.hdodenhof.circleimageview.CircleImageView

class KeeperAdapter : BaseAdapter<KeeperBean>(R.layout.item_keepr_mine) {
    val sexIcon by lazy{ arrayOf(R.mipmap.ic_male,R.mipmap.ic_female)}
    override fun convert(holder: BaseViewHolder, item: KeeperBean) {
        holder.getView<CircleImageView>(R.id.mPhoto).setImageUser(context, getImageUrl(item.avatar))
        holder.setText(R.id.mDocName, item.realname)
            .setImageResource(R.id.mImageSex,sexIcon[item.getGenderValue()])
            .setText(R.id.mPosition, item.positionName)
            .setText(
                R.id.mTvLoc,
                "${if (item.organization.isNullOrEmpty()) "无" else item.organization}  ${if (item.dictName.isNullOrEmpty()) "无" else item.dictName}"
            )

    }
}