package com.datarecovery.master.module.member;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

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

import com.datarecovery.master.databinding.ItemNormalScenesBinding;


public class NormalScenesAdapter extends RecyclerView.Adapter<NormalScenesAdapter.ViewHolder> {


    private String[] list;

    @NonNull
    @Override
    public NormalScenesAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        Context context = parent.getContext();
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        return new ViewHolder(ItemNormalScenesBinding.inflate(layoutInflater, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull NormalScenesAdapter.ViewHolder holder, int position) {
        holder.bind(list[position]);
    }


    @SuppressLint("NotifyDataSetChanged")
    public void setData(String[] list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.length;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final ItemNormalScenesBinding binding;

        public ViewHolder(@NonNull ItemNormalScenesBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }

        public void bind(String content) {
            binding.tvScenesName.setText(content);
        }
    }
}
