Пример #1
0
  private boolean findAppropriateDropHandle(DragEvent event) {
    Log.i(TAG, "Loc of parent: x:" + mLocationOnScreen[0] + " y:" + mLocationOnScreen[1]);
    mDragLocationOnScreen[0] = (int) (mLocationOnScreen[0] + event.getX());
    mDragLocationOnScreen[1] = (int) (mLocationOnScreen[1] + event.getY());
    Log.i(
        TAG,
        "FPN Drag location relative, x: "
            + mDragLocationOnScreen[0]
            + " y: "
            + mDragLocationOnScreen[1]);

    if (mCurrentDropHandleView != null) {
      ((DropAcceptable) mCurrentDropHandleView).onDrop(event);
      mCurrentDropHandleView = null;
      return true;
    } else {
      return false;
    }
  }
Пример #2
0
  private boolean findAppropriateDragMoveHandle(DragEvent event) {
    Log.i(TAG, "Loc of parent: x:" + mLocationOnScreen[0] + " y:" + mLocationOnScreen[1]);
    mDragLocationOnScreen[0] = (int) (mLocationOnScreen[0] + event.getX());
    mDragLocationOnScreen[1] = (int) (mLocationOnScreen[1] + event.getY());
    Log.i(
        TAG,
        "FPN Drag location relative, x: "
            + mDragLocationOnScreen[0]
            + " y: "
            + mDragLocationOnScreen[1]);

    boolean moveOnHandleView;
    if (mCurrentDropHandleView != null) {
      Log.i(TAG, "There is drop handle view, test it!");
      // Test if still move on the drop handle view
      moveOnHandleView =
          ViewUtil.isViewContained(
              mCurrentDropHandleView, mDragLocationOnScreen[0], mDragLocationOnScreen[1]);

      if (!moveOnHandleView) {
        // Exit
        ((DropAcceptable) mCurrentDropHandleView).onDragExited(event);
        mCurrentDropHandleView = null;
        return false;
      } else {
        return true;
      }
    } else {
      // Test if there is a new view become drop handle
      boolean foundNewDropHandle = false;
      for (int i = 0; i < mNavigatorContainer.getChildCount(); i++) {
        View view = mNavigatorContainer.getChildAt(i);

        moveOnHandleView =
            ViewUtil.isViewContained(view, mDragLocationOnScreen[0], mDragLocationOnScreen[1]);
        if (moveOnHandleView) {
          Log.i(
              TAG,
              "Drag enter child view: "
                  + i
                  + " class: "
                  + view.getClass().getSimpleName()
                  + " l: "
                  + view.getLeft()
                  + " width: "
                  + view.getWidth()
                  + " t: "
                  + view.getTop()
                  + " height: "
                  + view.getHeight()
                  + " r: "
                  + view.getRight()
                  + " b: "
                  + view.getBottom());
          if (view instanceof DropAcceptable) {
            mCurrentDropHandleView = view;
            foundNewDropHandle = true;
            ((DropAcceptable) mCurrentDropHandleView).onDragEntered(event);
          }

          if (foundNewDropHandle) {
            Log.i(TAG, "Find new drop handle view!");
            return true;
          } else {
            Log.i(TAG, "Not find new drop handle view yet!");
          }
        }
      }

      return false;
    }
  }