plz help getting error View cannot be converted to MotionEvent and MotionEvent cannot be converted to View ..
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.OnItemTouchListener;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
public class RecyclerTouchListener implements OnItemTouchListener {
private ClickListener clickListener;
private GestureDetector gestureDetector;
public interface ClickListener {
void onClick(View view, int i);
void onLongClick(View view, int i);
}
public void onRequestDisallowInterceptTouchEvent(boolean z) {
}
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener) {
this.clickListener = clickListener;
this.gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
public boolean onSingleTapUp(MotionEvent motionEvent) {
return true;
}
public void onLongPress(MotionEvent motionEvent) {
motionEvent = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (motionEvent != null && clickListener != null) {
clickListener.onLongClick(motionEvent, recyclerView.getChildPosition(motionEvent));
}
}
});
}
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View findChildViewUnder = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
if (!(findChildViewUnder == null || this.clickListener == null || this.gestureDetector.onTouchEvent(motionEvent) == null)) {
this.clickListener.onClick(findChildViewUnder, recyclerView.getChildPosition(findChildViewUnder));
}
return null;
}
}
error list in single file
1-incomparable types: boolean and <null>
2-incompatible types: cannot be converted to boolean
3-incompatible types: View cannot be converted to MotionEvent
4-incompatible types: MotionEvent cannot be converted to View
don't know how I can solve this problem.
Thank you in advance for your help
I hope to be clear, I'm sorry if there are mistakes