package io.blushine.android.ui.list;

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

/**
 * Edit an item by long clicking on it
 */
class ClickFunctionality<T> implements PostBindFunctionality<T> {
private ClickListener<T> mListener;

public ClickFunctionality(ClickListener<T> listener) {
	if (listener == null) {
		throw new IllegalArgumentException("listener is null");
	}

	mListener = listener;
}

@Override
public void applyFunctionality(AdvancedAdapter<T, ?> adapter, RecyclerView recyclerView) {
	// Does nothing
}

@Override
public void onPostBind(final AdvancedAdapter<T, ?> adapter, RecyclerView.ViewHolder viewHolder, final int position) {
	viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View view) {
			T item = adapter.getItem(position);
			mListener.onClick(item);
		}
	});
}
}

@@ -81,34 +81,8 @@
 iew;
-%0Aimport android.view.View;
 %0A%0A/*
@@ -229,23 +229,16 @@
 tener;%0A%0A
-public 
 ClickFun
@@ -277,16 +277,16 @@
 ener) %7B%0A
+
 %09if (lis
@@ -363,17 +363,18 @@
 l%22);%0A%09%7D%0A
+%09
 %0A
-
 %09mListen
@@ -621,14 +621,8 @@
 der,
- final
  int
@@ -678,85 +678,75 @@
 ner(
-new View.OnClickListener() %7B%0A%09%09@Override%0A%09%09public void onClick(View view) %7B%0A%09
+view -%3E %7B%0A%09%09int adapterPosition = viewHolder.getAdapterPosition();%0A
 %09%09T 
@@ -768,17 +768,24 @@
 getItem(
-p
+adapterP
 osition)
@@ -786,17 +786,16 @@
 ition);%0A
-%09
 %09%09mListe
@@ -817,12 +817,8 @@
 m);%0A
-%09%09%7D%0A
 %09%7D);

Fix so that onClick in adapters get the correct item