package com.cscodetech.moverslorry.adepter;

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.OperatLayoutBinding;
import com.cscodetech.moverslorry.model.StatelistItem;
import com.cscodetech.moverslorry.retrofit.APIClient;
import com.cscodetech.moverslorry.utils.SessionManager;

import java.util.List;

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


    private Context mContext;
    private List<StatelistItem> typeList;

    SessionManager sessionManager;

    public interface RecyclerTouchListener {


    }

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





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

    public OperatAdapter(Context mContext, List<StatelistItem> 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.operat_layout, parent, false);
        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        StatelistItem item=typeList.get(position);
        Glide.with(mContext).load(APIClient.BASE_URL + "/" + item.getImg()).thumbnail(Glide.with(mContext).load(R.drawable.tprofile)).into(holder.binding.img);
        holder.binding.txtStats.setText(""+item.getTitle());
        holder.binding.txtLoad.setText(""+item.getTotalLoad()+" "+mContext.getResources().getString(R.string.load));
        holder.binding.txtLorry.setText(""+item.getTotalLorry() +" "+mContext.getResources().getString(R.string.lorry));


    }

    @Override
    public int getItemCount() {

        return typeList.size();
    }
}