package com.trevorhalvorson.actorflix;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by Trevor Halvorson on 12/30/2015.
 */
public class RecyclerViewItemClickListener implements RecyclerView.OnItemTouchListener {
    private OnItemClickListener mListener;

    public interface OnItemClickListener {
        public void onItemClick(View view, int position);
    }

    GestureDetector mGestureDetector;

    public RecyclerViewItemClickListener(Context context, OnItemClickListener listener) {
        mListener = listener;
        mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                return true;
            }
        });
    }

    @Override
    public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
        View childView = view.findChildViewUnder(e.getX(), e.getY());
        if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
            mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
        }
        return false;
    }

    @Override
    public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
    }

    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }
}
@@ -384,17 +384,21 @@
 istener 
-m
+click
 Listener
@@ -528,18 +528,17 @@
 etector 
-mG
+g
 estureDe
@@ -636,33 +636,37 @@
 ener) %7B%0A        
-m
+click
 Listener = liste
@@ -678,18 +678,17 @@
         
-mG
+g
 estureDe
@@ -1109,17 +1109,21 @@
 null && 
-m
+click
 Listener
@@ -1138,10 +1138,9 @@
  && 
-mG
+g
 estu
@@ -1181,17 +1181,21 @@
         
-m
+click
 Listener

Remove Hungarian notation in fields