removing an item from a recyclerview

Source: http://stackoverflow.com/questions/26076965/android-recyclerview-addition-removal-of-items

        @Override
        public void onBindViewHolder(final ContactsSelectedViewHolder holder, final int position) {
            final Contact contact = mContactsSelected.get(position);
            setListeners(holder, position);
        }

        private void setListeners(ContactsSelectedViewHolder holder, final int position) {
            holder.removeIcon.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    int newPosition = holder.getAdapterPosition();
                    mContactsSelected.remove(newPosition);
                    notifyItemRemoved(newPosition);
                    notifyItemRangeChanged(newPosition,mContactsSelected.size());
                }
            });
        }