package com.bc_chat.circle.adapetr

import android.content.Context
import com.bc_chat.bc_base.entity.contact.Fans
import com.bc_chat.bc_base.utils.gone
import com.bc_chat.bc_base.utils.visible
import com.bc_chat.contacts.R
import com.zhaohaoting.framework.abs.adapter.ListToAdapter
import com.bc_chat.contacts.databinding.ItemFansLayoutBinding
import com.zhaohaoting.framework.utils.glid.GlideUtils

/**
 * author：Created by zhaohaoting on 2019/8/29
 * email：526309416@qq.com
 * desc：
 */
class FansAdapter(context: Context, val type: String) : ListToAdapter<Fans, List<Fans>>(context) {

    override fun getItemLayoutId(type: Int): Int = R.layout.item_fans_layout

    override fun onBindViewHolderHF(baseViewHolder: BaseViewHolder<*>?, realPosition: Int, data: Fans?) {
        val binding = baseViewHolder?.dataBinding as ItemFansLayoutBinding
        GlideUtils.loadCircleImage(context, data?.photo, binding.ivPhoto)
        if ("1".equals(type)) {
            binding.tvCancelFollow.visible()
        } else {
            binding.tvCancelFollow.gone()
        }
        binding.tvName.text = data?.nickName
        onItemViewClickListener?.let {
            binding.tvCancelFollow.setOnClickListener {
                onItemViewClickListener.onItemClick(baseViewHolder, binding.tvCancelFollow, realPosition);
            }
        }
    }
}