package com.satsumasoftware.timetable.ui.adapter;

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

import com.satsumasoftware.timetable.R;
import com.satsumasoftware.timetable.framework.Assignment;

import java.util.ArrayList;

public class AssignmentsAdapter extends RecyclerView.Adapter<AssignmentsAdapter.AssignmentViewHolder> {

    private ArrayList<Assignment> mAssignments;

    public AssignmentsAdapter(ArrayList<Assignment> assignments) {
        mAssignments = assignments;
    }

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

    @Override
    public void onBindViewHolder(AssignmentViewHolder holder, int position) {
        Assignment assignment = mAssignments.get(position);

        holder.mTitle.setText(assignment.getTitle());
        holder.mDetail.setText(assignment.getDetail());
    }

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

    public class AssignmentViewHolder extends RecyclerView.ViewHolder {

        TextView mTitle, mDetail;

        AssignmentViewHolder(View itemView) {
            super(itemView);
            mTitle = (TextView) itemView.findViewById(R.id.title);
            mDetail = (TextView) itemView.findViewById(R.id.detail);
        }
    }

}

@@ -1303,18 +1303,50 @@
 wHolder 
+implements View.OnClickListener 
 %7B%0A
-
 %0A       
@@ -1444,24 +1444,71 @@
 (itemView);%0A
+            itemView.setOnClickListener(this);%0A
             
@@ -1631,16 +1631,16 @@
 etail);%0A
-
         
@@ -1640,16 +1640,534 @@
        %7D
+%0A%0A        @Override%0A        public void onClick(View view) %7B%0A            if (mOnEntryClickListener != null) %7B%0A                mOnEntryClickListener.onEntryClick(view, getLayoutPosition());%0A            %7D%0A        %7D%0A    %7D%0A%0A    private OnEntryClickListener mOnEntryClickListener;%0A%0A    public interface OnEntryClickListener %7B%0A        void onEntryClick(View view, int position);%0A    %7D%0A%0A    public void setOnEntryClickListener(OnEntryClickListener onEntryClickListener) %7B%0A        mOnEntryClickListener = onEntryClickListener;
 %0A    %7D%0A%0A

Add a click listener interface for AssignmentsAdapter