package com.zj365.health.adapter.binddevice

import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.tamsiree.rxkit.RxTimeTool
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.zj365.health.databinding.ActBindDeviceListBinding
import com.xty.network.model.AnswerBean
import com.xty.network.model.BindDeviceListBean


open class BindDeviceAdapter: BaseAdapter<BindDeviceListBean>(R.layout.item_bind_device) {

    var isMe = true
    override fun convert(holder: BaseViewHolder, item: BindDeviceListBean) {
        if (isMe){
            holder.setEnabled(R.id.tvBIndButton,true)
            holder.setTextColor(R.id.tvBIndButton, ContextCompat.getColor(context,R.color.col_25C))
        }else{
            holder.setEnabled(R.id.tvBIndButton,false)
            holder.setTextColor(R.id.tvBIndButton, ContextCompat.getColor(context,R.color.white))
        }
        holder.setText(R.id.tvSnNum,item.sn)
            holder.setText(R.id.tvCreateDate,item.bindTime)
            holder.getView<TextView>(R.id.tvBIndButton).setOnClickListener {
                //解綁
                listener.invoke(item.sn,item.mac)
            }
    }
    fun setUnbindListener(listener: (sn:String?,mac:String?) -> Unit) {
        this.listener = listener
    }

    private lateinit var listener: (sn:String?,mac:String?) -> Unit


}