package com.hi.music.player.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

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

import com.hi.music.player.databinding.ItemSuggestionBinding;

public class AdapterSuggestion extends BaseAdapter<String, ItemSuggestionBinding> {

    @Override
    protected ItemSuggestionBinding getViewBinding(ViewGroup parent) {
        return ItemSuggestionBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        VHolder<ItemSuggestionBinding> itemHolder = (VHolder<ItemSuggestionBinding>) holder;
        ItemSuggestionBinding vb = itemHolder.getVb();
        String text = data.get(position);
        vb.tvSuggestion.setText(text);
        vb.relayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(homeItemClickListener!= null){
                    homeItemClickListener.onClickItemSuggestion(true,text);
                }

            }
        });

        vb.imFillIn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(homeItemClickListener!= null){
                    homeItemClickListener.onClickItemSuggestion(false,text);
                }
            }
        });
    }


}
