Ejemplo n.º 1
0
  @Override
  public boolean onTouch(View v, MotionEvent ev) {
    if (!mDslv.isDragEnabled() || mDslv.listViewIntercepted()) {
      return false;
    }

    mDetector.onTouchEvent(ev);
    if (mRemoveEnabled && mDragging && mRemoveMode == FLING_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 && mIsRemoving) {
          int x = mPositionX >= 0 ? mPositionX : -mPositionX;
          int removePoint = mDslv.getWidth() / 2;
          if (x > removePoint) {
            mDslv.stopDragWithVelocity(true, 0);
          }
        }
      case MotionEvent.ACTION_CANCEL:
        mIsRemoving = false;
        mDragging = false;
        break;
    }

    return false;
  }
Ejemplo n.º 2
0
 @Override
 public final boolean onFling(
     MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
   // Log.d("mobeta", "on fling remove called");
   if (mRemoveEnabled && mIsRemoving) {
     int w = mDslv.getWidth();
     int minPos = w / 5;
     if (velocityX > mFlingSpeed) {
       if (mPositionX > -minPos) {
         mDslv.stopDragWithVelocity(true, velocityX);
       }
     } else if (velocityX < -mFlingSpeed) {
       if (mPositionX < minPos) {
         mDslv.stopDragWithVelocity(true, velocityX);
       }
     }
     mIsRemoving = false;
   }
   return false;
 }