@@ -0,0 +1,3985 @@
+package me.pc.mobile.helper.v14.util;%0A%0Aimport android.support.v7.widget.RecyclerView;%0Aimport android.view.View;%0A%0Aimport com.creditease.zhiwang.R;%0A%0A/**%0A * Created by Pan Chen on 4/1/16 : 15:15.%0A * Company : www.CreditEase.cn;%0A * Email : chenpan1@creditease.cn;%0A * Motto : If you can take it, you can make it.%0A */%0Apublic class RecyclerViewItemClickSupport %7B%0A        private final RecyclerView mRecyclerView;%0A        private OnItemClickListener mOnItemClickListener;%0A        private OnItemLongClickListener mOnItemLongClickListener;%0A        private View.OnClickListener mOnClickListener = new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                if (mOnItemClickListener != null) %7B%0A                    RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v);%0A                    mOnItemClickListener.onItemClicked(mRecyclerView, holder.getAdapterPosition(), v);%0A                %7D%0A            %7D%0A        %7D;%0A        private View.OnLongClickListener mOnLongClickListener = new View.OnLongClickListener() %7B%0A            @Override%0A            public boolean onLongClick(View v) %7B%0A                if (mOnItemLongClickListener != null) %7B%0A                    RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v);%0A                    return mOnItemLongClickListener.onItemLongClicked(mRecyclerView, holder.getAdapterPosition(), v);%0A                %7D%0A                return false;%0A            %7D%0A        %7D;%0A        private RecyclerView.OnChildAttachStateChangeListener mAttachListener%0A                = new RecyclerView.OnChildAttachStateChangeListener() %7B%0A            @Override%0A            public void onChildViewAttachedToWindow(View view) %7B%0A                if (mOnItemClickListener != null) %7B%0A                    view.setOnClickListener(mOnClickListener);%0A                %7D%0A                if (mOnItemLongClickListener != null) %7B%0A                    view.setOnLongClickListener(mOnLongClickListener);%0A                %7D%0A            %7D%0A%0A            @Override%0A            public void onChildViewDetachedFromWindow(View view) %7B%0A%0A            %7D%0A        %7D;%0A%0A        private RecyclerViewItemClickSupport(RecyclerView recyclerView) %7B%0A            mRecyclerView = recyclerView;%0A            mRecyclerView.setTag(R.id.recycler_view_item_click_support, this);%0A            mRecyclerView.addOnChildAttachStateChangeListener(mAttachListener);%0A        %7D%0A%0A        public static RecyclerViewItemClickSupport addTo(RecyclerView view) %7B%0A            RecyclerViewItemClickSupport support = (RecyclerViewItemClickSupport) view.getTag(R.id.recycler_view_item_click_support);%0A            if (support == null) %7B%0A                support = new RecyclerViewItemClickSupport(view);%0A            %7D%0A            return support;%0A        %7D%0A%0A        public static RecyclerViewItemClickSupport removeFrom(RecyclerView view) %7B%0A            RecyclerViewItemClickSupport support = (RecyclerViewItemClickSupport) view.getTag(R.id.recycler_view_item_click_support);%0A            if (support != null) %7B%0A                support.detach(view);%0A            %7D%0A            return support;%0A        %7D%0A%0A        public RecyclerViewItemClickSupport setOnItemClickListener(OnItemClickListener listener) %7B%0A            mOnItemClickListener = listener;%0A            return this;%0A        %7D%0A%0A        public RecyclerViewItemClickSupport setOnItemLongClickListener(OnItemLongClickListener listener) %7B%0A            mOnItemLongClickListener = listener;%0A            return this;%0A        %7D%0A%0A        private void detach(RecyclerView view) %7B%0A            view.removeOnChildAttachStateChangeListener(mAttachListener);%0A            view.setTag(R.id.recycler_view_item_click_support, null);%0A        %7D%0A%0A        public interface OnItemClickListener %7B%0A%0A            void onItemClicked(RecyclerView recyclerView, int position, View v);%0A        %7D%0A%0A        public interface OnItemLongClickListener %7B%0A%0A            boolean onItemLongClicked(RecyclerView recyclerView, int position, View v);%0A        %7D%0A    %7D%0A

Create RecyclerViewItemClickSupport.java