package com.example.android.waitlist;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


public class GuestListAdapter extends RecyclerView.Adapter<GuestListAdapter.GuestViewHolder> {

    private Context mContext;
    // TODO (8) Add a new local variable mCount to store the count of items to be displayed in the recycler view

    /**
     * Constructor using the context and the db cursor
     *
     * @param context the calling context/activity
     */
    // TODO (9) Update the Adapter constructor to accept an integer for the count along with the context
    public GuestListAdapter(Context context) {
        this.mContext = context;
        // TODO (10) Set the local mCount to be equal to count
    }

    @Override
    public GuestViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        // Get the RecyclerView item layout
        LayoutInflater inflater = LayoutInflater.from(mContext);
        View view = inflater.inflate(R.layout.guest_list_item, parent, false);
        return new GuestViewHolder(view);
    }

    @Override
    public void onBindViewHolder(GuestViewHolder holder, int position) {

    }


    // TODO (11) Modify the getItemCount to return the mCount value rather than 0
    @Override
    public int getItemCount() {
        return 0;
    }


    /**
     * Inner class to hold the views needed to display a single item in the recycler-view
     */
    class GuestViewHolder extends RecyclerView.ViewHolder {

        // Will display the guest name
        TextView nameTextView;
        // Will display the party size number
        TextView partySizeTextView;

        /**
         * Constructor for our ViewHolder. Within this constructor, we get a reference to our
         * TextViews
         *
         * @param itemView The View that you inflated in
         *                 {@link GuestListAdapter#onCreateViewHolder(ViewGroup, int)}
         */
        public GuestViewHolder(View itemView) {
            super(itemView);
            nameTextView = (TextView) itemView.findViewById(R.id.name_text_view);
            partySizeTextView = (TextView) itemView.findViewById(R.id.party_size_text_view);
        }

    }
}
@@ -371,20 +371,25 @@
 %0A    // 
-TODO
+completed
  (8) Add
@@ -481,16 +481,36 @@
 ler view
+%0A    int mCount = 0;
 %0A%0A    /*
@@ -639,20 +639,25 @@
 %0A    // 
-TODO
+completed
  (9) Upd
@@ -785,16 +785,27 @@
  context
+, int count
 ) %7B%0A    
@@ -844,20 +844,25 @@
      // 
-TODO
+completed
  (10) Se
@@ -901,16 +901,40 @@
 o count%0A
+        mCount = count;%0A
     %7D%0A%0A 
@@ -1370,12 +1370,17 @@
  // 
-TODO
+completed
  (11
@@ -1507,17 +1507,22 @@
  return 
-0
+mCount
 ;%0A    %7D%0A

complete TODO 8-12