package com.ttiglobal.inttilectgpchat.blog.Helper;

import android.annotation.SuppressLint;
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.google.firebase.auth.FirebaseAuth;
import com.ttiglobal.inttilectgpchat.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Objects;

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

    private ArrayList<HashMap<String,String>> items;
    private Context context;

    public LikeRecyclerAdapter(Context context, ArrayList<HashMap<String,String>> items) {
        this.items = items;
        this.context = context;
    }

    @NonNull
    @Override
    public LikeRecyclerAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.like_layout, parent, false);
        return new LikeRecyclerAdapter.ViewHolder(v);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(@NonNull LikeRecyclerAdapter.ViewHolder holder, int position) {

        holder.comment_details.setText(items.get(position).get("like_id"));
        holder.view.setTag(items);
    }

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

    class ViewHolder extends RecyclerView.ViewHolder {
        View view;
        String user;
        private TextView comment_details, comment_name;

        private ViewHolder(View itemView) {
            super(itemView);
            view = itemView;
            user = Objects.requireNonNull(FirebaseAuth.getInstance().getCurrentUser()).getUid();
            comment_details = view.findViewById(R.id.comment_details);
            comment_name = view.findViewById(R.id.user_comment);
        }
    }
}