Guest User

Untitled

a guest
Jul 22nd, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. recyclerView.setOnTouchListener(new View.OnTouchListener() {
  2.             @Override
  3.             public boolean onTouch(View v, MotionEvent event) {
  4.                 directionDetector.onTouchEvent(event);
  5.                
  6.                 //passing UP action to widgets and reseting the direction
  7.                 if (event.getAction() == MotionEvent.ACTION_UP) {
  8.                     direction = null;
  9.                     motionLayout.onTouchEvent(event);
  10.                 }
  11.  
  12.                 //passing initial action to widgets
  13.                 if (event.getAction() == MotionEvent.ACTION_DOWN) {
  14.                     motionLayout.onTouchEvent(event);
  15.                 }
  16.  
  17.                 if (direction != null) {
  18.                     switch (direction) {
  19.                         case UP:
  20.                         case DOWN:
  21.                             return motionLayout.onTouchEvent(event);
  22.                         case LEFT:
  23.                         case RIGHT:
  24.                             return false;
  25.                     }
  26.                 }
  27.                 return false;
  28.             }
  29.         });
Add Comment
Please, Sign In to add comment