Ejemplo n.º 1
0
 // complete the OnGestureListener interface
 @Override
 public boolean onSingleTapUp(MotionEvent ev) {
   if (mRemoveEnabled && mRemoveMode == CLICK_REMOVE) {
     if (mClickRemoveHitPos != MISS) {
       mDslv.removeItem(mClickRemoveHitPos - mDslv.getHeaderViewsCount());
     }
   }
   return true;
 }
Ejemplo n.º 2
0
  /**
   * Sets flags to restrict certain motions of the floating View based on DragSortController
   * settings (such as remove mode). Starts the drag on the DragSortListView.
   *
   * @param position The list item position (includes headers).
   * @param deltaX Touch x-coord minus left edge of floating View.
   * @param deltaY Touch y-coord minus top edge of floating View.
   * @return True if drag started, false otherwise.
   */
  public boolean startDrag(int position, int deltaX, int deltaY) {

    int dragFlags = 0;
    if (mSortEnabled && !mIsRemoving) {
      dragFlags |= DragSortListView.DRAG_POS_Y | DragSortListView.DRAG_NEG_Y;
    }
    if (mRemoveEnabled && mIsRemoving) {
      dragFlags |= DragSortListView.DRAG_POS_X;
      dragFlags |= DragSortListView.DRAG_NEG_X;
    }

    mDragging = mDslv.startDrag(position - mDslv.getHeaderViewsCount(), dragFlags, deltaX, deltaY);
    return mDragging;
  }
Ejemplo n.º 3
0
  /**
   * Sets flags to restrict certain motions of the floating View based on DragSortController
   * settings (such as remove mode). Starts the drag on the DragSortListView.
   *
   * @param position The list item position (includes headers).
   * @param deltaX Touch x-coord minus left edge of floating View.
   * @param deltaY Touch y-coord minus top edge of floating View.
   * @return True if drag started, false otherwise.
   */
  public boolean startDrag(int position, int deltaX, int deltaY) {

    int dragFlags = 0;
    if (mSortEnabled) {
      dragFlags |= DragSortListView.DRAG_POS_Y | DragSortListView.DRAG_NEG_Y;
      // dragFlags |= DRAG_POS_Y; //for fun
    }
    if (mRemoveEnabled) {
      if (mRemoveMode == FLING_RIGHT_REMOVE) {
        dragFlags |= DragSortListView.DRAG_POS_X;
      } else if (mRemoveMode == FLING_LEFT_REMOVE) {
        dragFlags |= DragSortListView.DRAG_NEG_X;
      }
    }

    mDragging = mDslv.startDrag(position - mDslv.getHeaderViewsCount(), dragFlags, deltaX, deltaY);
    return mDragging;
  }
Ejemplo n.º 4
0
  /**
   * Checks for the touch of an item's drag handle (specified by {@link #setDragHandleId(int)}), and
   * returns that item's position if a drag handle touch was detected.
   *
   * @param ev The ACTION_DOWN MotionEvent.
   * @return The list position of the item whose drag handle was touched; MISS if unsuccessful.
   */
  public int dragHandleHitPosition(MotionEvent ev) {
    final int x = (int) ev.getX();
    final int y = (int) ev.getY();

    int touchPos = mDslv.pointToPosition(x, y); // includes headers/footers

    final int numHeaders = mDslv.getHeaderViewsCount();
    final int numFooters = mDslv.getFooterViewsCount();
    final int count = mDslv.getCount();

    // Log.d("mobeta", "touch down on position " + itemnum);
    // We're only interested if the touch was on an
    // item that's not a header or footer.
    if (touchPos != AdapterView.INVALID_POSITION
        && touchPos >= numHeaders
        && touchPos < (count - numFooters)) {
      final View item = mDslv.getChildAt(touchPos - mDslv.getFirstVisiblePosition());
      final int rawX = (int) ev.getRawX();
      final int rawY = (int) ev.getRawY();

      // View dragBox = (View) item.getTag();
      View dragBox = (View) item.findViewById(mDragHandleId);
      if (dragBox != null) {
        dragBox.getLocationOnScreen(mTempLoc);

        if (rawX > mTempLoc[0]
            && rawY > mTempLoc[1]
            && rawX < mTempLoc[0] + dragBox.getWidth()
            && rawY < mTempLoc[1] + dragBox.getHeight()) {

          mItemX = item.getLeft();
          mItemY = item.getTop();

          return touchPos;
        }
      }
    }

    return MISS;
  }