package com.cheng.blzb.ui.fragment.mine.seat

import android.text.TextUtils
import android.widget.ImageView
import coil.load
import coil.transform.CircleCropTransformation
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cheng.blzb.R
import com.cheng.blzb.bean.SeatItemEntity

class SeatManageAdapter: BaseQuickAdapter<SeatItemEntity, BaseViewHolder>(R.layout.listitem_seat_manage) {

    init {
        addChildClickViewIds(R.id.btn_delete)
    }

    override fun convert(holder: BaseViewHolder, item: SeatItemEntity) {
        holder.getView<ImageView>(R.id.iv_avatar).load(item.avatar) {
            transformations(CircleCropTransformation())
        }
        holder.setText(R.id.tv_name, item.user_name)
        if (!TextUtils.isEmpty(item.phone)) {
            holder.setText(R.id.tv_phone, item.phone.replaceRange(3, 7, "****"))
        } else {
            holder.setText(R.id.tv_phone, "")
        }
    }
}