package com.pixelnx.localhelp.ui.notice;

import android.content.Context;
import android.content.Intent;

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

import android.widget.LinearLayout;


import androidx.annotation.NonNull;

import androidx.recyclerview.widget.RecyclerView;

import com.pixelnx.localhelp.R;

import com.pixelnx.localhelp.ui.order.ActivityCancelled;
import com.pixelnx.localhelp.ui.order.ActivityNewOrder;

import com.pixelnx.localhelp.ui.user.ActivityPreviousOrderList;
import com.pixelnx.localhelp.utils.widgets.CustomTextMedium;


import java.util.List;

public class AdapterNoticeList extends RecyclerView.Adapter<AdapterNoticeList.HolderSearchAdapter> {
    List<ModelNotice.OrderData> subCategoryData;
    Context mContext;



    public AdapterNoticeList(Context mContext, List<ModelNotice.OrderData> data) {

        this.subCategoryData = data;
        this.mContext = mContext;

    }

    @NonNull
    @Override
    public HolderSearchAdapter onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_notice, viewGroup, false);
        return new HolderSearchAdapter(view);

    }

    @Override
    public void onBindViewHolder(@NonNull final HolderSearchAdapter holder, final int i) {

holder.orderId.setText("Order Number : "+subCategoryData.get(i).getId());
holder.orderMsg.setText(""+subCategoryData.get(i).getMsg());
holder.llNotice.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        if(subCategoryData.get(i).getDeliveryStatus().equalsIgnoreCase("0")){
            Intent intent =new Intent(mContext, ActivityNewOrder.class);
            mContext.startActivity(intent);

        }
        if(subCategoryData.get(i).getDeliveryStatus().equalsIgnoreCase("1")){
            Intent intent =new Intent(mContext, ActivityPreviousOrderList.class);
            mContext.startActivity(intent);

        }
        if(subCategoryData.get(i).getDeliveryStatus().equalsIgnoreCase("2")){
            Intent intent =new Intent(mContext, ActivityPreviousOrderList.class);
            mContext.startActivity(intent);

        }
        if(subCategoryData.get(i).getDeliveryStatus().equalsIgnoreCase("3")){
            Intent intent =new Intent(mContext, ActivityCancelled.class);
            intent.putExtra("customer","3");
            mContext.startActivity(intent);

        }

    }
});







    }

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

    public static class HolderSearchAdapter extends RecyclerView.ViewHolder {



        CustomTextMedium orderId;
        CustomTextMedium  orderMsg;
        LinearLayout llNotice;


        public HolderSearchAdapter(@NonNull View itemView) {
            super(itemView);


            orderId = itemView.findViewById(R.id.orderId);
            orderMsg = itemView.findViewById(R.id.orderMsg);
            llNotice = itemView.findViewById(R.id.llNotice);



        }
    }

}
