package com.cscodetech.moverslorry.adepter;

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

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.cscodetech.moverslorry.R;
import com.cscodetech.moverslorry.databinding.ReviewLayoutBinding;
import com.cscodetech.moverslorry.model.TotalReviewUserWiseItem;
import com.cscodetech.moverslorry.retrofit.APIClient;

import java.util.List;

public class ReviewAdapter extends RecyclerView.Adapter<ReviewAdapter.MyViewHolder> {



    private Context mContext;
    private List<TotalReviewUserWiseItem> typeList;


    public class MyViewHolder extends RecyclerView.ViewHolder {
        private ReviewLayoutBinding binding;






        public MyViewHolder(View view) {
            super(view);
            binding = ReviewLayoutBinding.bind(view);
        }
    }

    public ReviewAdapter(Context mContext, List<TotalReviewUserWiseItem> typeList) {
        this.mContext = mContext;
        this.typeList = typeList;



    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView;
        itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.review_layout, parent, false);
        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, @SuppressLint("RecyclerView") int position) {

        Glide.with(mContext).load(APIClient.BASE_URL + "/" + typeList.get(position).getUserImg()).thumbnail(Glide.with(mContext).load(R.drawable.tprofile)).into(holder.binding.imgs);
        holder.binding.txtName.setText(""+typeList.get(position).getCustomername());
        holder.binding.txtRates.setText(""+typeList.get(position).getRateNumber());
        holder.binding.txtTextreview.setText(""+typeList.get(position).getRateText());



    }

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