package com.xyzshell.myphoneinfo.adapter

import android.app.Activity
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.xyzshell.myphoneinfo.databinding.ItemAppListBinding


class AppListAdapter: RecyclerView.Adapter<AppListAdapter.ListViewHolder>() {
    private lateinit var context: Context
    private lateinit var listener: OnShowDialogListener
    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ListViewHolder {
        context = parent.context
        val binding= ItemAppListBinding.inflate(LayoutInflater.from(context), parent, false)
        return ListViewHolder(binding)
    }

    override fun onBindViewHolder(
        holder: ListViewHolder,
        position: Int
    ) {
        holder.binding.view.setOnClickListener {
            listener.onShowAppSelectDialog()
        }
//        if(position==itemCount-1){
//            holder.binding.view2.visibility=View.VISIBLE
//        }else{
//            holder.binding.view2.visibility=View.GONE
//        }
    }
    fun setOnclickListener(listener: OnShowDialogListener) {
        this.listener = listener
    }

    override fun getItemCount(): Int {
        return 13
    }

    class ListViewHolder(val binding: ItemAppListBinding): RecyclerView.ViewHolder(binding.root)
    interface OnShowDialogListener {
        fun onShowAppSelectDialog()
    }

}