package com.navinfo.outdoor.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.navinfo.outdoor.R;
import com.navinfo.outdoor.bean.BankPathBean;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class BankAdapter extends RecyclerView.Adapter<BankAdapter.ViewHolder> {
    private List<BankPathBean> bankPathBeans ;
    private Context context;

    public BankAdapter(List<BankPathBean> bankPathBeans, Context context) {
        this.bankPathBeans = bankPathBeans;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.bankadapteritem, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull @NotNull ViewHolder holder, int position) {
        holder.tvitem.setText(bankPathBeans.get(position).getLabel());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBankClick.onClick(position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return bankPathBeans.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvitem;

        public ViewHolder(@NonNull @NotNull View itemView) {
            super(itemView);
            tvitem = itemView.findViewById(R.id.tv_bank);
        }
    }
    public interface OnBankClick {
        void onClick(int pos);
    }

    private OnBankClick onBankClick;

    public void setOnBankClick(OnBankClick onBankClick) {
        this.onBankClick = onBankClick;
    }
}
