package com.example.profbola.bakingtime.utils;

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;

import com.example.profbola.bakingtime.R;
import com.example.profbola.bakingtime.models.Step;

/**
 * Created by prof.BOLA on 7/2/2017.
 */

public class StepAdapter extends RecyclerView.Adapter<StepAdapter.StepViewHolder> {

    private Context mContext;
    private Step[] mSteps;

    public StepAdapter(Context context) {
        mContext = context;
    }

    @Override
    public StepAdapter.StepViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext)
                .inflate(R.layout.step, parent, false);

        return new StepViewHolder(view);
    }

    @Override
    public void onBindViewHolder(StepAdapter.StepViewHolder holder, int position) {
        holder.bind(position);
    }

    @Override
    public int getItemCount() {
        if (null == mSteps) return 0;
        return mSteps.length;
    }

    public class StepViewHolder extends RecyclerView.ViewHolder {

        private final TextView id;
        private final TextView description;

        public StepViewHolder(View itemView) {
            super(itemView);

            id = (TextView) itemView.findViewById(R.id.step_id);
            description = (TextView) itemView.findViewById(R.id.step_description);
        }

        void bind(int position) {
            Step step = mSteps[position];
            id.setText(String.valueOf(step.id));
            description.setText(step.description);
        }
    }

    public void swapSteps(Step[] steps) {
        mSteps = steps;
        notifyDataSetChanged();
    }
}

@@ -339,16 +339,73 @@
 ls.Step;
+%0Aimport com.example.profbola.bakingtime.ui.StepsFragment;
 %0A%0A/**%0A *
@@ -590,77 +590,224 @@
 ps;%0A
-%0A    public StepAdapter(Context context) %7B%0A        mContext = context
+    private StepsFragment.OnVideoPlayerSelected mCallback;%0A%0A    public StepAdapter(Context context, StepsFragment.OnVideoPlayerSelected playerSelected) %7B%0A        mContext = context;%0A        mCallback = playerSelected
 ;%0A  
@@ -1391,16 +1391,60 @@
 ewHolder
+%0A            implements View.OnClickListener
  %7B%0A%0A    
@@ -1519,16 +1519,45 @@
 ption;%0A%0A
+        private Step mStep;%0A%0A
         
@@ -1764,32 +1764,80 @@
 ep_description);
+%0A%0A            itemView.setOnClickListener(this);
 %0A        %7D%0A%0A    
@@ -1882,14 +1882,10 @@
     
+m
 S
-tep s
 tep 
@@ -1942,17 +1942,18 @@
 valueOf(
-s
+mS
 tep.id))
@@ -1986,17 +1986,18 @@
 setText(
-s
+mS
 tep.desc
@@ -2015,16 +2015,126 @@
        %7D
+%0A%0A        @Override%0A        public void onClick(View v) %7B%0A            mCallback.videoClicked(mStep);%0A        %7D
 %0A    %7D%0A%0A

Implement OnClick, Add Callback and Change fields