package com.marshalchen.ultimaterecyclerview;

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

/**
 * Created by cym on 15-1-20.
 */
public abstract class UltimateViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.bottom_progressbar, parent, false);
        if (viewType == 1) return new ProgressBarViewHolder(v);
        return onCreateViewHolder(parent);

    }

    public abstract RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent);

    /**
     * Return the view type of the item at <code>position</code> for the purposes
     * of view recycling.
     * <p/>
     * <p>The default implementation of this method returns 0, making the assumption of
     * a single view type for the adapter. Unlike ListView adapters, types need not
     * be contiguous. Consider using id resources to uniquely identify item view types.
     *
     * @param position position to query
     * @return integer value identifying the type of the view needed to represent the item at
     * <code>position</code>. Type codes need not be contiguous.
     */
    @Override
    public int getItemViewType(int position) {
        if (position == getItemCount() - 1) {
            return 1;
        } else
            return super.getItemViewType(position);
    }


    /**
     * Returns the total number of items in the data set hold by the adapter.
     *
     * @return The total number of items in this adapter.
     */
    @Override
    public int getItemCount() {
        return getAdapterItemCount() + 1;
    }

    /**
     * Returns the number of items in the adapter bound to the parent RecyclerView.
     *
     * @return The number of items in the bound adapter
     */
    public abstract int getAdapterItemCount();

//    public void insertItem(int position) {
//        insert(position);
//        notifyItemInserted(position);
//    }
//
//    public abstract void insert(int position);


    public void toggleSelection(int pos) {
        notifyItemChanged(pos);
    }


    public void clearSelection(int pos) {
        notifyItemChanged(pos);
    }

    public void clearSelections() {
        notifyDataSetChanged();
    }

    class ProgressBarViewHolder extends RecyclerView.ViewHolder {
        public ProgressBarViewHolder(View itemView) {
            super(itemView);
        }

    }


}

@@ -181,16 +181,70 @@
 Group;%0A%0A
+import java.util.Collections;%0Aimport java.util.List;%0A%0A
 /**%0A * C
@@ -2431,57 +2431,631 @@
 oid 
-clearSelections() %7B%0A        notifyDataSetChanged(
+setSelected(int pos) %7B%0A        notifyItemChanged(pos);%0A    %7D%0A%0A%0A%0A    public void swapPositions(List%3C?%3E list, int from, int to) %7B%0A        Collections.swap(list, from, to);%0A    %7D%0A%0A    public %3CT%3E void insert(List%3CT%3E list, T object, int position) %7B%0A        list.add(position, object);%0A        notifyItemInserted(position);%0A        notifyItemChanged(position + 1);%0A    %7D%0A%0A    public void remove(List%3C?%3E list,int position) %7B%0A        list.remove(position);%0A        notifyItemRemoved(position);%0A    %7D%0A%0A    public void clear(List%3C?%3E list) %7B%0A        int size = list.size();%0A        list.clear();%0A        notifyItemRangeRemoved(0, size
 );%0A 

add some adapter method of UltimateViewAdapter