示例#1
0
  void elementHandler(int x, int y, int action) {
    for (Point point : points.getValues()) if (point.getRegion().contains(x, y)) return;

    switch (action) {
      case MotionEvent.ACTION_DOWN:
        mHandler.sendMessageDelayed(
            Message.obtain(mHandler, CODE_ELEMENT_LONGCLICK),
            ViewConfiguration.getLongPressTimeout());

        fX = x - getScVal(this.x);
        fY = y - getScVal(this.y);
        break;
      case MotionEvent.ACTION_MOVE:
        if (mMoovingPermitted) {
          dX = getGridCoord((x - fX) / getScaleFactor());
          dY = getGridCoord((y - fY) / getScaleFactor());

          if (this.x != dX | this.y != dY) {
            this.x = dX;
            this.y = dY;

            for (Link link : links) link.measure();

            onUpdate();
            getSdk().getSdkFragment().update();
            isPossibleToRemoving =
                getSdk().getSdkFragment().getRemovingElementView().checkRemoving(this);
          }
        }
        break;
      case MotionEvent.ACTION_UP:
        if (mMoovingPermitted) {
          mMoovingPermitted = false;
          getSdk().getSdkFragment().lockScroll(false);
          getSdk().getSdkFragment().setRemovingViewState(false);
          MainActivity.mainFragment.showTabs();
        } else if (mLinkCreationToggle) {
          mLinkCreationToggle = false;
        } else {
          if (!isSelected()) sdk.setSelectedElement(this);
        }

        if (mHandler.hasMessages(CODE_ELEMENT_LONGCLICK))
          mHandler.removeMessages(CODE_ELEMENT_LONGCLICK);

        if (isPossibleToRemoving) getSdk().getSdkFragment().getRemovingElementView().remove(this);
        break;
      case MotionEvent.ACTION_CANCEL:
        if (mHandler.hasMessages(CODE_ELEMENT_LONGCLICK))
          mHandler.removeMessages(CODE_ELEMENT_LONGCLICK);
        break;
    }
  }
示例#2
0
 public void measurePoints() {
   for (Point point : points.getValues()) point.measure();
 }