package com.zj365.health.weight

import android.content.Context
import android.view.Gravity
import androidx.recyclerview.widget.LinearLayoutManager
import com.xty.base.dialog.BaseDialog
import com.zj365.health.adapter.RelationAdapter
import com.zj365.health.databinding.DialogRelationBinding
import com.xty.network.model.RelationList

class RelationDialog(context: Context,var click:()->Unit) : BaseDialog(context) {
    val binding by lazy{ DialogRelationBinding.inflate(layoutInflater)}
    val adapter by lazy{ RelationAdapter() }
    override fun setLayout()=binding.root

    override fun initView() {
        super.initView()
        window!!.setGravity(Gravity.CENTER)
        intAdapter()
    }
    private fun intAdapter() {
        binding.mRecycle.layoutManager=LinearLayoutManager(context)
        binding.mRecycle.adapter=adapter
        adapter.setOnItemClickListener { _, view, position ->
            //adapter.current=position
            //adapter.notifyDataSetChanged()
            click.invoke()
            dismiss()
        }
    }

    fun showDialog(list:MutableList<RelationList>?){
        show()
        adapter.setNewInstance(list)
    }
}