package com.android2ee.recyclerview.adapter;

import java.util.List;

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

import com.android2ee.recyclerview.R;

/**
 * 
 * @author florian
 * RecyclerSimpleViewAdapter provide a simple RecyclerViewAdapter
 *
 */
public class RecyclerSimpleViewAdapter extends RecyclerView.Adapter<RecyclerSimpleViewAdapter.ViewHolder> {

	/**
	 * List items
	 */
    private List<String> items;
    /**
     * the resource id of item Layout
     */
    private int itemLayout;

    /**
     * Constructor RecyclerSimpleViewAdapter
     * @param items : the list items
     * @param itemLayout : the resource id of itemView
     */
    public RecyclerSimpleViewAdapter(List<String> items, int itemLayout) {
        this.items = items;
        this.itemLayout = itemLayout;
    }

    /**
	 * Create View Holder by Type
	 * @param parent, the view parent
	 * @param viewType : the type of View
	 */
    @Override 
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    	// get inflater and get view by resource id itemLayout
        View v = LayoutInflater.from(parent.getContext()).inflate(itemLayout, parent, false);
        // return ViewHolder with View
        return new ViewHolder(v);
    }

    /**
	 * Get the size of items in adapter
	 * @return the size of items in adapter
	 */
    @Override 
    public int getItemCount() {
        return items.size();
    }
    
    /**
	 * Bind View Holder with Items 
	 * @param holder: the view holder
	 * @param position : the current position
	 */
    @Override
	public void onBindViewHolder(RecyclerSimpleViewAdapter.ViewHolder holder, int position) {
    	// find item by position
		String item = items.get(position);
		// save information in holder, we have one type in this adapter
        holder.primaryText.setText(item);
        holder.itemView.setTag(item);
        
        if ((position % 2) == 0) {
        	Log.w("TAG", "color1");
        	holder.itemView.setBackgroundResource(R.color.color1);
        } else {
        	Log.w("TAG", "color2");
        	holder.itemView.setBackgroundResource(R.color.color2);
        }
	}
    
    /**
	 * 
	 * @author florian
	 * Class viewHolder
	 * Hold an textView
	 */
    public static class ViewHolder extends RecyclerView.ViewHolder {
    	// TextViex
        public TextView primaryText;
        
       /**
        * Constructor ViewHolder
        * @param itemView: the itemView
        */
        public ViewHolder(View itemView) {
            super(itemView);
            // link primaryText
            primaryText = (TextView) itemView.findViewById(android.R.id.text1);
        }
    }
}

@@ -2033,67 +2033,83 @@
     
-if ((position %25 2) == 0) %7B%0A        %09Log.w(%22TAG%22, %22color1%22);
+// pair impair position, different color%0A        if ((position %25 2) == 0) %7B
 %0A   
@@ -2165,24 +2165,24 @@
 or.color1);%0A
+
         %7D el
@@ -2190,41 +2190,8 @@
 e %7B%0A
-        %09Log.w(%22TAG%22, %22color2%22);%0A
     

Remove Log, and add comment