Advertisement
minafaw3

RecycleOntouchListner

Oct 25th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public class RecycleOntouchListner implements RecyclerView.OnItemTouchListener {
  2.  
  3. private GestureDetector mGestureDetector;
  4. private ClickListener mClickListner;
  5.  
  6. public RecycleOntouchListner(Context mContext, ClickListener clickListner) {
  7.  
  8. this.mClickListner = clickListner;
  9. mGestureDetector = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() {
  10. @Override
  11. public boolean onSingleTapUp(MotionEvent e) {
  12.  
  13. return true;
  14. }
  15. });
  16. }
  17.  
  18.  
  19. @Override
  20. public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
  21.  
  22. View child = rv.findChildViewUnder(e.getX(), e.getY());
  23. if (child != null && mClickListner != null && mGestureDetector.onTouchEvent(e)) {
  24. mClickListner.OnClick(child, rv.getChildAdapterPosition(child));
  25. return false;
  26.  
  27. }
  28. return false;
  29. }
  30.  
  31. @Override
  32. public void onTouchEvent(RecyclerView rv, MotionEvent e) {
  33.  
  34. }
  35.  
  36. @Override
  37. public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement