package com.example.salonappnew;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import android.widget.Toast;

import com.example.salonappnew.models.Comments;
import com.example.salonappnew.models.MedicineWeek;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;

import java.util.ArrayList;

public class CommentAdapter extends BaseAdapter {




    //Firebase storage
    FirebaseAuth mFirebaseAuth;
    FirebaseStorage storage;
    StorageReference storageReference;
    FirebaseFirestore db = FirebaseFirestore.getInstance();

    Context c;
    ArrayList<Comments> originalArray,tmpArray;


    public CommentAdapter(Context c, ArrayList<Comments> originalArray){
        this.c = c;
        this.originalArray = originalArray;
        this.tmpArray = originalArray;
    }


    @Override
    public Object getItem(int position) {
        return originalArray.get(position);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View row = inflater.inflate(R.layout.comment_list_item,null);



        TextView txtComment =row.findViewById(R.id.txtComment);


        if(originalArray.get(position).isParentComment){
            txtComment.setText(originalArray.get(position).getpComment());
        }else {
            txtComment.setText(originalArray.get(position).getdComment());
        }










        row.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //INTENT to medicine activities week -> MedicineWeekActivities.java

            }
        });

        return row;
    }

    @Override
    public int getCount() {
        return originalArray.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

}