title: Badoo like Swipeable Cards
body: <p>So I've been in this for a while now and have been unable to figure out how to implement 4-way swipe recognition in android. I've found different links pointing to different solutions but none of them fulfill my requirements.</p>
  <p>What I wish to accomplish is to attain a &quot;Badoo&quot; like swipe gesture. Badoo is a Tinder like application. On swiping up/down the user's pictures are scrolled, and on left/right, the card is liked/disliked.</p>
  <p>The animation I wish to achieve is that on left/right the card follows the set left/right path and moves to like/dislike. On up/down the pictures snap to their next/previous ones.</p>
  <p>I've tried countless libraries over github that for swipeable cards and am now trying to implement a custom view for my requirements.</p>
  <p>Currently I'm trying to insert a VerticalViewPager inside a CardView. The problem here is that the VerticalViewPager is intercepting all touch events therefore I am unable to swipe my card right/left.</p>
  <p>This is my OnTouch event for the CardView item:</p>
  <pre><code>public boolean onTouch(View v, MotionEvent event) {
      switch (event.getAction()) {
      case MotionEvent.ACTION_MOVE:
          pager.requestDisallowInterceptTouchEvent(true);
          break;
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
          pager.requestDisallowInterceptTouchEvent(false);
          break;
      }
      return true;
  }
  </code></pre>
  <p>This is what I'm trying to achieve. This is what Badoo looks like:</p>
  <p>Badoo Screenshot 1: <a href="https://drive.google.com/open?id=0BzGcu10X5GRrTDZHRm4xT0tnQ1k" rel="nofollow noreferrer">https://drive.google.com/open?id=0BzGcu10X5GRrTDZHRm4xT0tnQ1k</a>
  Badoo Screenshot 2: <a href="https://drive.google.com/open?id=0BzGcu10X5GRrc2pvRTZKS2p2UEU" rel="nofollow noreferrer">https://drive.google.com/open?id=0BzGcu10X5GRrc2pvRTZKS2p2UEU</a></p>
  <p>If anyone knows of any similar libraries with a similar 4-way swipe gesture please let me know.</p>
  <h1>EDIT:</h1>
  <p>I've made a parent view for the card and the ViewPager, the CardView (cardViewParent) has a child cardView and cardView's child is a VerticalViewPager (mViewPager):</p>
  <pre><code>cardViewParent.setOnTouchListener(new View.OnTouchListener() {
              @Override
              public boolean onTouch(View view, MotionEvent event) {
                  Toast.makeText(context, &quot;incardviewPARENT&quot;, Toast.LENGTH_SHORT).show ();
  
                 float rawX = 0, rawY = 0;
  
                 switch (event.getAction()) {
  
  
                     case MotionEvent.ACTION_DOWN:
                          //gesture has begun
                          float x;
                          float y;
                          //cancel any current animations
  
                         mActivePointerId[0] = event.getPointerId(0);
  
                         x = event.getX();
                          y = event.getY();
                          rawX = event.getRawX();
                          rawY = event.getRawY();
  
  
                         initialXPress[0] = x;
                          initialYPress[0] = y;
                          initialRawXPress[0] = rawX;
                          initialRawYPress[0] = rawY;
  
                         break;
  
                     case MotionEvent.ACTION_MOVE:
                          //gesture is in progress
  
                         final int pointerIndex = event.findPointerIndex(mActivePointerId[0]);
                          //Log.i(&quot;pointer index: &quot; , Integer.toString(pointerIndex));
                          if (pointerIndex &lt; 0 || pointerIndex &gt; 0) {
                              break;
                          }
  
                         final float xMove = event.getX(pointerIndex);
                          final float yMove = event.getY(pointerIndex);
                          float rawDY = Math.abs(event.getRawY() - 
                          initialRawYPress[0]);
                          float rawDX = Math.abs(event.getRawX() - initialRawXPress[0]);
  
                         //calculate distance moved
                          final float dx = xMove - initialXPress[0];
                          final float dy = yMove - initialYPress[0];
                          Log.d(&quot;RAW DY:&quot;, &quot;&quot; + rawDY);
  
                         if(rawDY &gt; 100 &amp;&amp; !animationStart[0])
                          {
                              // vertical swipe detected
                              mViewPager.setSwipeable(true);
                              cardStack.setSWIPE_ENABLED(false);
                             // mViewPager.dispatchTouchEvent(event);
                              return false;
                          }
  
                         if((rawDY &lt;100 &amp;&amp; rawDX &gt; 100) || 
                         animationStart[0]) {
  
                             //horizontal swipe
  
                             animationStart[0] = true;
                              cardStack.setSWIPE_ENABLED(true);
                              mViewPager.setSwipeable(false);
                             // cardStack.dispatchTouchEvent(event);
                              return false;
  
                         }
  
                 }
  
                 return true;
  
             }
          });
  </code></pre>
  <p>If an Upwards Swipe Motion is detected then I'm enabling the ViewPager's swipe motion, else the CardStack's (swipe deck) swipe is enabled. The problem is that the swipe motion doesn't start in any direction.</p>