@@ -0,0 +1,3223 @@
+/*%0A *%0A *  * Copyright 2015 Eric Liu%0A *  *%0A *  * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  * you may not use this file except in compliance with the License.%0A *  * You may obtain a copy of the License at%0A *  *%0A *  *     http://www.apache.org/licenses/LICENSE-2.0%0A *  *%0A *  * Unless required by applicable law or agreed to in writing, software%0A *  * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  * See the License for the specific language governing permissions and%0A *  * limitations under the License.%0A *%0A */%0A%0Apackage com.liuguangqiang.recyclerview.adapter;%0A%0Aimport android.content.Context;%0Aimport android.support.v7.widget.RecyclerView;%0Aimport android.view.LayoutInflater;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by Eric on 15/7/7.%0A */%0Apublic abstract class BaseAdapter%3CT, VH extends RecyclerView.ViewHolder%3E extends RecyclerView.Adapter%3CVH%3E %7B%0A%0A    public Context mContext;%0A    public List%3CT%3E data = new ArrayList%3C%3E();%0A    public final LayoutInflater layoutInflater;%0A%0A    public OnItemClickListener onItemClickListener;%0A    public OnItemLongClickListener onItemLongClickListener;%0A%0A    public void setOnItemClickListener(OnItemClickListener onItemClickListener) %7B%0A        this.onItemClickListener = onItemClickListener;%0A    %7D%0A%0A    public void setOnItemLongClickListener(OnItemLongClickListener onItemLongClickListener) %7B%0A        this.onItemLongClickListener = onItemLongClickListener;%0A    %7D%0A%0A    public BaseAdapter(Context context, List%3CT%3E data) %7B%0A        this.mContext = context;%0A        this.data = data;%0A        this.layoutInflater = LayoutInflater.from(context);%0A    %7D%0A%0A    public LayoutInflater getLayoutInflater() %7B%0A        return layoutInflater;%0A    %7D%0A%0A    @Override%0A    public int getItemCount() %7B%0A        return data.size();%0A    %7D%0A%0A    @Override%0A    public void onBindViewHolder(VH holder, final int position) %7B%0A        if (holder.itemView != null) %7B%0A            if (onItemClickListener != null) %7B%0A                holder.itemView.setOnClickListener(new View.OnClickListener() %7B%0A                    @Override%0A                    public void onClick(View v) %7B%0A                        onItemClickListener.onItemClick(position);%0A                    %7D%0A                %7D);%0A            %7D%0A%0A            if (onItemLongClickListener != null) %7B%0A                holder.itemView.setOnLongClickListener(new View.OnLongClickListener() %7B%0A                    @Override%0A                    public boolean onLongClick(View v) %7B%0A                        onItemLongClickListener.onItemLongClick(position);%0A                        return false;%0A                    %7D%0A                %7D);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public VH onCreateViewHolder(ViewGroup parent, int viewType) %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public void onViewRecycled(VH holder) %7B%0A        super.onViewRecycled(holder);%0A    %7D%0A%0A    public interface OnItemClickListener %7B%0A%0A        void onItemClick(int position);%0A%0A    %7D%0A%0A    public interface OnItemLongClickListener %7B%0A%0A        void onItemLongClick(int position);%0A%0A    %7D%0A%0A%0A%7D%0A

Create BaseAdapter that extends RecylerView.Adapter.