Example #1
0
  @Override
  public boolean onTouch(View v, MotionEvent ev) {
    mDetector.onTouchEvent(ev);
    if (mRemoveEnabled
        && mDragging
        && (mRemoveMode == FLING_RIGHT_REMOVE || mRemoveMode == FLING_LEFT_REMOVE)) {
      mFlingRemoveDetector.onTouchEvent(ev);
    }

    int action = ev.getAction() & MotionEvent.ACTION_MASK;

    switch (action) {
      case MotionEvent.ACTION_DOWN:
        mCurrX = (int) ev.getX();
        mCurrY = (int) ev.getY();
        break;
      case MotionEvent.ACTION_UP:
        if (mRemoveEnabled) {
          final int x = (int) ev.getX();
          int thirdW = mDslv.getWidth() / 3;
          int twoThirdW = mDslv.getWidth() - thirdW;
          if ((mRemoveMode == SLIDE_RIGHT_REMOVE && x > twoThirdW)
              || (mRemoveMode == SLIDE_LEFT_REMOVE && x < thirdW)) {
            mDslv.stopDrag(true);
          }
        }
      case MotionEvent.ACTION_CANCEL:
        mDragging = false;
        break;
    }

    return false;
  }
Example #2
0
 @Override
 public final boolean onFling(
     MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
   // Log.d("mobeta", "on fling remove called");
   if (mRemoveEnabled) {
     switch (mRemoveMode) {
       case FLING_RIGHT_REMOVE:
         if (velocityX > mFlingSpeed) {
           mDslv.stopDrag(true);
         }
         break;
       case FLING_LEFT_REMOVE:
         if (velocityX < -mFlingSpeed) {
           mDslv.stopDrag(true);
         }
         break;
     }
   }
   return false;
 }