public void onTouchEvent(MotionEvent event) {
   mGestureDetector.onTouchEvent(event);
   mScaleDetector.onTouchEvent(event);
   if (event.getAction() == MotionEvent.ACTION_UP) {
     mListener.onUp(event.getX(), event.getY());
   }
 }
Ejemplo n.º 2
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    mScaleGestureDetector.onTouchEvent(event);

    if (!mScaling) mGestureDetector.onTouchEvent(event);

    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
      mUserInteracting = true;
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
      mScrollDisabled = false;
      mUserInteracting = false;

      View v = mChildViews.get(mCurrent);
      if (v != null) {
        if (mScroller.isFinished()) {
          // If, at the end of user interaction, there is no
          // current inertial scroll in operation then animate
          // the view onto screen if necessary
          slideViewOntoScreen(v);
        }

        if (mScroller.isFinished()) {
          // If still there is no inertial scroll in operation
          // then the layout is stable
          postSettle(v);
        }
      }
    }

    requestLayout();
    return true;
  }
Ejemplo n.º 3
0
 @Override
 public boolean onTouchEvent(@NonNull MotionEvent ev) {
   stopAnimationsOnTouch = true;
   mScaleDetector.onTouchEvent(ev);
   if (!mScaleDetector.isInProgress()) mGestureDetector.onTouchEvent(ev);
   return true;
 }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    // Avoid short-circuit logic evaluation - ensure all gesture detectors see all events so
    // that they generate correct notifications.
    boolean handled = mScroller.onTouchEvent(event);
    handled |= mZoomer.onTouchEvent(event);
    handled |= mTapDetector.onTouchEvent(event);
    mSwipePinchDetector.onTouchEvent(event);

    switch (event.getActionMasked()) {
      case MotionEvent.ACTION_DOWN:
        mViewer.setAnimationEnabled(false);
        mSuppressCursorMovement = false;
        mSuppressFling = false;
        mSwipeCompleted = false;
        break;

      case MotionEvent.ACTION_POINTER_DOWN:
        mTotalMotionY = 0;
        break;

      case MotionEvent.ACTION_UP:
        releaseAnyHeldButton();
        break;

      default:
        break;
    }
    return handled;
  }
  @Override
  public boolean onTouchEvent(MotionEvent e) {
    boolean b = scaleGestureDetector.onTouchEvent(e);

    boolean c = gestureDetector.onTouchEvent(e);

    return b || c || super.onTouchEvent(e);
  }
  @Override
  public boolean onTouchEvent(MotionEvent event) {

    boolean retValue = mScaleGesture.onTouchEvent(event);

    retValue = mGestureDetector.onTouchEvent(event) || retValue;

    return retValue || super.onTouchEvent(event);
  }
Ejemplo n.º 7
0
 // Passes the touch event to ScaleGestureDetector so that its internal
 // state won't go wrong, but instructs the listener to ignore the result
 // of processing, if any.
 void passTouchEventThrough(MotionEvent event) {
   mMultiTouchListener.setTemporarilyIgnoreDetectorEvents(true);
   try {
     mMultiTouchDetector.onTouchEvent(event);
   } catch (Exception e) {
     Log.e(TAG, "ScaleGestureDetector got into a bad state!", e);
     assert (false);
   }
 }
Ejemplo n.º 8
0
 @Override
 public boolean onTouchEvent(MotionEvent me) {
   if (me.getAction() == MotionEvent.ACTION_UP) {
     // Save position data once the user has finished manipulating the TermView
     savePosition();
   }
   boolean scaleGestureHandled = scaleGestureDetector.onTouchEvent(me);
   boolean gestureHandled = gestureDetector.onTouchEvent(me);
   return scaleGestureHandled || gestureHandled;
 }
Ejemplo n.º 9
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   try {
     detector.onTouchEvent(event);
     handleSingleTouch(event);
   } catch (Exception e) {
     // Log.e(TAG, "Error " + e.getMessage());
   }
   return true;
 }
Ejemplo n.º 10
0
 // Passes the touch event to ScaleGestureDetector so that its internal state
 // won't go wrong. ScaleGestureDetector needs two pointers in a MotionEvent
 // to recognize a zoom gesture.
 boolean processTouchEvent(MotionEvent event) {
   // TODO: Need to deal with multi-touch transition
   mMultiTouchListener.setTemporarilyIgnoreDetectorEvents(false);
   try {
     return mMultiTouchDetector.onTouchEvent(event);
   } catch (Exception e) {
     Log.e(TAG, "ScaleGestureDetector got into a bad state!", e);
     assert (false);
   }
   return false;
 }
Ejemplo n.º 11
0
  public boolean onTouch(View v, MotionEvent event) {

    if (genericMotionListener != null) {
      genericMotionListener.onGenericMotion(v, event);
    }

    gestureDetector.onTouchEvent(event);
    scaleGestureDetector.onTouchEvent(event);
    shoveGestureDetector.onTouchEvent(event);
    rotateGestureDetector.onTouchEvent(event);

    return true;
  }
Ejemplo n.º 12
0
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   if (event.getPointerCount() > 1) {
     if (mGestureDetector.onTouchEvent(event)) return true;
   } else {
     if (mVisibleGrid == GRID_SMALL) {
       return mSmallRecView.onTouchEvent(event);
     } else if (mVisibleGrid == GRID_BIG) {
       return mBigRecView.onTouchEvent(event);
     }
   }
   return false;
 }
Ejemplo n.º 13
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    if (mDragController.onTouchEvent(event)) {
      return true;
    }

    scaleDetector.onTouchEvent(event);
    if (detector.onTouchEvent(event)) {
      return true;
    }
    super.onTouchEvent(event);
    return true;
  }
Ejemplo n.º 14
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   mScaleDetector.onTouchEvent(event);
   if (!mScaleDetector.isInProgress()) mGestureDetector.onTouchEvent(event);
   int action = event.getAction();
   switch (action & MotionEvent.ACTION_MASK) {
     case MotionEvent.ACTION_UP:
       if (getScale() < 1f) {
         zoomTo(1f, 50);
       }
       break;
   }
   return true;
 }
Ejemplo n.º 15
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    clearExtraInformationTextViews();
    scaleDetector.onTouchEvent(event);
    // Check if multitouch action or single touch based on pointer count.
    if (event.getPointerCount() > 1) {
      clearExtraInformationTextViews();
      gestureTypeTV.setText("MULTI TOUCH EVENT");
      textView3.setText("Num Pointers: " + event.getPointerCount());
      int action = MotionEventCompat.getActionMasked(event);
      textView4.setText(actionToString(action));
      int index = MotionEventCompat.getActionIndex(event);
      textView5.setText("Pointer index: " + index);
    } else gestureDetect.onTouchEvent(event);

    return true;
  }
Ejemplo n.º 16
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {

    switch (event.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        handleTouchStart(event);
        setActionMode(ACTION_MODE_DRAG);
        break;
      case MotionEvent.ACTION_MOVE:
        if (getActionMode() == ACTION_MODE_DRAG) {
          float distanceFromStart = getDragDistanceFromStart(event);
          if (distanceFromStart > 10.0f) {
            stopLongpressTimer();
            setStartedDragging(true);
          }
          if (isStartedDragging()) {
            updateCameraTranslation(event);
            invalidate();
          }
        }
        break;
      case MotionEvent.ACTION_POINTER_DOWN:
        setActionMode(ACTION_MODE_ZOOM);
        break;

      case MotionEvent.ACTION_UP:
        stopLongpressTimer();
        boolean clickIsFasterThanLongpress =
            System.currentTimeMillis() - getPressStartTimeInMilliSeconds() < LONGPRESS_TIME;
        if (!isStartedDragging() && clickIsFasterThanLongpress) {
          onClickEvent(event);
        }
        setActionMode(ACTION_MODE_NONE);
        break;

      case MotionEvent.ACTION_POINTER_UP:
        setActionMode(ACTION_MODE_NONE);
        break;
    }

    _zoomDetector.onTouchEvent(event);
    return true;
  }
Ejemplo n.º 17
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    setScaleType(ImageView.ScaleType.MATRIX);
    mScaleDetector.onTouchEvent(event);
    PointF curr = new PointF(event.getX(), event.getY());

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        mLast.set(curr);
        mStart.set(mLast);
        mMode = Mode.DRAG;
        break;

      case MotionEvent.ACTION_MOVE:
        if (mMode == Mode.DRAG) {
          float deltaX = curr.x - mLast.x;
          float deltaY = curr.y - mLast.y;
          float fixTransX = getFixDragTrans(deltaX, mViewWidth, mOrigWidth * mSaveScale);
          float fixTransY = getFixDragTrans(deltaY, mViewHeight, mOrigHeight * mSaveScale);
          mMatrix.postTranslate(fixTransX, fixTransY);
          fixTrans();
          mLast.set(curr.x, curr.y);
        }
        break;

      case MotionEvent.ACTION_UP:
        mMode = Mode.NONE;
        int xDiff = (int) Math.abs(curr.x - mStart.x);
        int yDiff = (int) Math.abs(curr.y - mStart.y);
        if (xDiff < CLICK && yDiff < CLICK) performClick();
        break;

      case MotionEvent.ACTION_POINTER_UP:
        mMode = Mode.NONE;
        break;

      default:
        return false;
    }

    setImageMatrix(mMatrix);
    return true;
  }
Ejemplo n.º 18
0
  /*
   * (non-Javadoc)
   *
   * @see android.view.View#onTouchEvent(android.view.MotionEvent)
   */
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    scaleDetector.onTouchEvent(event);
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
      dragStartX = event.getX();
      dragStartY = event.getY();
    } else if (event.getActionMasked() == MotionEvent.ACTION_UP
        || event.getActionMasked() == MotionEvent.ACTION_MOVE) {

      float deltaX = (event.getX() - dragStartX) / (scale * 25);
      float deltaY = (event.getY() - dragStartY) / (scale * 25);

      relativeX += deltaX;
      relativeY += deltaY;

      invalidate();
    }
    return true;
  }
          @Override
          public boolean onTouch(View view, MotionEvent event) {
            // Work in screen coordinates.
            final float oldX = event.getX();
            final float oldY = event.getY();
            event.setLocation(event.getRawX(), event.getRawY());

            mGestureDetector.onTouchEvent(event);
            mScaleGestureDetector.onTouchEvent(event);

            switch (event.getActionMasked()) {
              case MotionEvent.ACTION_UP:
              case MotionEvent.ACTION_CANCEL:
                saveWindowParams();
                break;
            }

            // Revert to window coordinates.
            event.setLocation(oldX, oldY);
            return true;
          }
Ejemplo n.º 20
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    mScaleGestureDetector.onTouchEvent(event);
    if (mGestureDetector.onTouchEvent(event)) {
      return true;
    }

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        mListener.waveformTouchStart(event.getX());
        break;
      case MotionEvent.ACTION_MOVE:
        mListener.waveformTouchMove(event.getX());
        break;
      case MotionEvent.ACTION_UP:
        mListener.waveformTouchEnd();
        break;
    }
    //   Log.i(GlobParam.LOG_TAG, "Ha entrat en WaveformView en onTouchEvent");
    return true;
  }
Ejemplo n.º 21
0
  @Override
  public boolean onTouch(View view, MotionEvent event) {
    if (detectors != null) detectors.onTouchEvent(event);

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        mSurfaceSizes.dx = event.getX();
        mSurfaceSizes.dy = event.getY();
        break;

      case MotionEvent.ACTION_MOVE:
        float x = event.getX();
        float y = event.getY();
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
        float left = lp.leftMargin + (x - mSurfaceSizes.dx);
        float top = lp.topMargin + (y - mSurfaceSizes.dy);
        if (mSurfaceSizes.listnrr != null && mSurfaceSizes.listnrr.zoom) {
          int srcw = lp.width;
          int srch = lp.height;

          int left_offset =
              (int)
                  (mSurfaceSizes.orig_width
                      - (mSurfaceSizes.orig_width * mSurfaceSizes.listnrr.scaleFactor));
          int top_offset =
              (int)
                  (mSurfaceSizes.orig_height
                      - (mSurfaceSizes.orig_height * mSurfaceSizes.listnrr.scaleFactor));
          Log.e("Player", "ACTION_MOVE2 " + left_offset + "," + top_offset);

          lp.leftMargin = left_offset;
          lp.topMargin = top_offset;
          lp.rightMargin = left_offset;
          lp.bottomMargin = top_offset;
        }
        view.setLayoutParams(lp);
        break;
    }
    return true;
  }
Ejemplo n.º 22
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    gestureDetector.onTouchEvent(event);

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        downPosX = event.getX();
        downPosY = event.getY();
        break;

      case MotionEvent.ACTION_MOVE:
        posX += event.getX() - downPosX;
        posY += event.getY() - downPosY;
        downPosX = event.getX();
        downPosY = event.getY();
        invalidate();
        break;

      default:
        break;
    }
    return true;
  }
Ejemplo n.º 23
0
 @Override
 public boolean onTouchEvent(MotionEvent ev) {
   mDetector.onTouchEvent(ev);
   return super.onTouchEvent(ev);
 }
Ejemplo n.º 24
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   mScaleDetector.onTouchEvent(event);
   mTapDetector.onTouchEvent(event);
   return true;
 }
Ejemplo n.º 25
0
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
    if (mVelocityTracker == null) {
      mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(ev);

    scaleGesture.onTouchEvent(ev);
    final float x = ev.getX();
    final float y = ev.getY();

    Log.i(LOG_TAG, "ev:" + ev.getAction() + " x=" + x + ", y=" + y);
    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        // Log.i(LOG_TAG, "event:down. x="+x+", y="+y);
        /*
         * If being flinged and user touches, stop the fling. isFinished
         * will be false if being flinged.
         */
        if (!mScroller.isFinished()) {
          mScroller.abortAnimation();
        }

        // Remember where the motion event started
        mLastMotionX = x;
        mLastMotionY = y;
        break;

      case MotionEvent.ACTION_UP:
        // Log.i(LOG_TAG, "event:up. x="+x+",y="+y);
        // if (mTouchState == TOUCH_STATE_SCROLLING) {
        final VelocityTracker velocityTracker = mVelocityTracker;
        velocityTracker.computeCurrentVelocity(1000);
        int velocityX = (int) velocityTracker.getXVelocity();
        int velocityY = (int) velocityTracker.getYVelocity();

        int newColumn = mCurrentColumn;
        int newRow = mCurrentRow;

        if ((velocityX > SNAP_VELOCITY) && (mCurrentColumn > 0)) {
          // Fling hard enough to move left
          // snapToScreen(mCurrentScreen - 1);
          newColumn = mCurrentColumn - 1;
        } else if ((velocityX < -SNAP_VELOCITY) && (mCurrentColumn < mNumColumns - 1)) {
          // Fling hard enough to move right
          // snapToScreen(mCurrentScreen + 1);
          newColumn = mCurrentColumn + 1;
        } else {
          newColumn = (mScrollX + (getWidth() / 2)) / getWidth();
          // snapToDestinationX();
        }

        if ((velocityY > SNAP_VELOCITY) && (mCurrentRow > 0)) {
          // Fling hard enough to move left
          // snapToScreen(mCurrentScreen - mNumColumns);
          newRow = mCurrentRow - 1;
        } else if ((velocityY < -SNAP_VELOCITY) && (mCurrentRow < mNumRows - 1)) {
          // Fling hard enough to move right
          // snapToScreen(mCurrentScreen + mNumColumns);
          newRow = mCurrentRow + 1;
        } else {
          newRow = (mScrollY + (getHeight() / 2)) / getHeight();
          // snapToDestinationY();
        }
        Log.i(LOG_TAG, "event:up. velocity=" + velocityX + "," + velocityY);
        snapToScreen(newRow, newColumn);

        if (mVelocityTracker != null) {
          mVelocityTracker.recycle();
          mVelocityTracker = null;
        }
        // }
        mTouchState = TOUCH_STATE_REST;
        break;
      case MotionEvent.ACTION_CANCEL:
        // Log.i(LOG_TAG, "event:cancel. x="+x+",y="+y);
        mTouchState = TOUCH_STATE_REST;
        break;
      case MotionEvent.ACTION_MOVE:
        // if (mTouchState == TOUCH_STATE_SCROLLING) {
        // Scroll to follow the motion event
        final int deltaX = (int) (mLastMotionX - x);
        final int deltaY = (int) (mLastMotionY - y);
        int scrollByX = 0, scrollByY = 0;

        mLastMotionX = x;
        mLastMotionY = y;

        // Log.i(LOG_TAG,
        // "event:move,x="+x+",y="+y+",deltaX="+deltaX+",deltaY="+deltaY+",mScrollX="+mScrollX+",mScrollY="+mScrollY);

        // calculate the movement of the x- coordinate
        if ((deltaX < 0) && (mScrollX + OVERSHOOT_AMOUNT > 0)) {
          scrollByX = Math.max(-(mScrollX + OVERSHOOT_AMOUNT), deltaX);
        } else if (deltaX > 0) {
          final int rightMost = getChildAt(mNumColumns - 1).getRight() + OVERSHOOT_AMOUNT;
          final int availableToScroll = rightMost - mScrollX - getWidth();
          // final int availableToScroll =
          // getChildAt(getChildCount()-1).getRight()-mScrollX-getWidth();
          // rightMost = (getWidth() * mNumColumns);
          // Log.d(LOG_TAG,"width="+getWidth()+",rightMost="+rightMost+",availableToScroll="+availableToScroll);
          if (availableToScroll > 0) {
            scrollByX = Math.min(availableToScroll, deltaX);
          }
        }

        // move the y- coordinate
        if ((deltaY < 0) && ((mScrollY + OVERSHOOT_AMOUNT) > 0)) {
          scrollByY = Math.max(-(mScrollY + OVERSHOOT_AMOUNT), deltaY);
        } else if (deltaY > 0) {
          int bottomMost = getChildAt(mNumRows * (mNumColumns - 1)).getBottom() + OVERSHOOT_AMOUNT;
          final int availableToScroll = bottomMost - mScrollY - getHeight();
          // bottomMost = (getHeight() * mNumRows);
          // Log.d(LOG_TAG,"height="+getHeight()+",bottomMost="+bottomMost+",availableToScroll="+availableToScroll);
          if (availableToScroll > 0) {
            scrollByY = Math.min(availableToScroll, deltaY);
          }
        }
        if ((scrollByX != 0) || (scrollByY != 0)) scrollBy(scrollByX, scrollByY);
        // }
        break;

      default:
        break;
    }
    mScrollX = this.getScrollX();
    mScrollY = this.getScrollY();

    return true;
  }
Ejemplo n.º 26
0
  @Override
  public boolean onTouch(View v, MotionEvent event) {

    if (mGestureDetector.onTouchEvent(event)) return true;
    mScaleGestureDetector.onTouchEvent(event);

    float x = 0, y = 0;
    // 拿到触摸点的个数
    final int pointerCount = event.getPointerCount();
    // 得到多个触摸点的x与y均值
    for (int i = 0; i < pointerCount; i++) {
      x += event.getX(i);
      y += event.getY(i);
    }
    x = x / pointerCount;
    y = y / pointerCount;

    /** 每当触摸点发生变化时,重置mLasX , mLastY */
    if (pointerCount != lastPointerCount) {
      isCanDrag = false;
      mLastX = x;
      mLastY = y;
    }

    lastPointerCount = pointerCount;
    RectF rectF = getMatrixRectF();
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        if (rectF.width() > getWidth() || rectF.height() > getHeight()) {
          getParent().requestDisallowInterceptTouchEvent(true);
        }
        break;
      case MotionEvent.ACTION_MOVE:
        if (rectF.width() > getWidth() || rectF.height() > getHeight()) {
          getParent().requestDisallowInterceptTouchEvent(true);
        }
        Log.e(TAG, "ACTION_MOVE");
        float dx = x - mLastX;
        float dy = y - mLastY;

        if (!isCanDrag) {
          isCanDrag = isCanDrag(dx, dy);
        }
        if (isCanDrag) {

          if (getDrawable() != null) {
            // if (getMatrixRectF().left == 0 && dx > 0)
            // {
            // getParent().requestDisallowInterceptTouchEvent(false);
            // }
            //
            // if (getMatrixRectF().right == getWidth() && dx < 0)
            // {
            // getParent().requestDisallowInterceptTouchEvent(false);
            // }
            isCheckLeftAndRight = isCheckTopAndBottom = true;
            // 如果宽度小于屏幕宽度,则禁止左右移动
            if (rectF.width() < getWidth()) {
              dx = 0;
              isCheckLeftAndRight = false;
            }
            // 如果高度小雨屏幕高度,则禁止上下移动
            if (rectF.height() < getHeight()) {
              dy = 0;
              isCheckTopAndBottom = false;
            }

            mScaleMatrix.postTranslate(dx, dy);
            checkMatrixBounds();
            setImageMatrix(mScaleMatrix);
          }
        }
        mLastX = x;
        mLastY = y;
        break;

      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        Log.e(TAG, "ACTION_UP");
        lastPointerCount = 0;
        break;
    }

    return true;
  }
Ejemplo n.º 27
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   if (mScaleDetector != null) {
     mScaleDetector.onTouchEvent(event);
     if (!mScaleDetector.isInProgress()) {
       if (mGestureDetector != null) {
         mGestureDetector.onTouchEvent(event);
       }
     }
   }
   float x = event.getX();
   float y = event.getY();
   int action = event.getAction();
   switch (action & MotionEvent.ACTION_MASK) {
     case MotionEvent.ACTION_DOWN:
       if (INNER_RECT) {
         if (circleContain(x, y, mBitmapRectPoints[0], mBitmapRectPoints[1], mRadius, mRadius)) {
           mDragPoint.set(mBitmapRectPoints[0], mBitmapRectPoints[1]);
         } else if (circleContain(
             x, y, mBitmapRectPoints[2], mBitmapRectPoints[3], mRadius, mRadius)) {
           mDragPoint.set(mBitmapRectPoints[2], mBitmapRectPoints[3]);
         } else if (circleContain(
             x, y, mBitmapRectPoints[4], mBitmapRectPoints[5], mRadius, mRadius)) {
           mDragPoint.set(mBitmapRectPoints[4], mBitmapRectPoints[5]);
         } else if (circleContain(
             x, y, mBitmapRectPoints[6], mBitmapRectPoints[7], mRadius, mRadius)) {
           mDragPoint.set(mBitmapRectPoints[6], mBitmapRectPoints[7]);
         } else {
           break;
         }
       } else {
         if (circleContain(x, y, mMarginRectF.left, mMarginRectF.top, mRadius, mRadius)) {
           mDragPoint.set(mMarginRectF.left, mMarginRectF.top);
         } else if (circleContain(x, y, mMarginRectF.right, mMarginRectF.top, mRadius, mRadius)) {
           mDragPoint.set(mMarginRectF.right, mMarginRectF.top);
         } else if (circleContain(
             x, y, mMarginRectF.left, mMarginRectF.bottom, mRadius, mRadius)) {
           mDragPoint.set(mMarginRectF.left, mMarginRectF.bottom);
         } else if (circleContain(
             x, y, mMarginRectF.right, mMarginRectF.bottom, mRadius, mRadius)) {
           mDragPoint.set(mMarginRectF.right, mMarginRectF.bottom);
         } else {
           break;
         }
       }
       postInvalidate();
       break;
     case MotionEvent.ACTION_MOVE:
       if (mDragPoint.x == INVALID_POINT && mDragPoint.y == INVALID_POINT) {
         break;
       }
       float scale = Float.NEGATIVE_INFINITY;
       float newSpanX = 0;
       float newSpanY = 0;
       float oldSpanX = 0;
       float oldSpanY = 0;
       float scaleX = 0;
       float scaleY = 0;
       if (INNER_RECT) {
         if (circleContain(
             mDragPoint.x,
             mDragPoint.y,
             mMarginRectF.left,
             mMarginRectF.top,
             mMarginRectF.centerX(),
             mMarginRectF.centerY())) {
           newSpanX = mMarginRectF.centerX() - x;
           newSpanY = mMarginRectF.centerY() - y;
           oldSpanX = mMarginRectF.centerX() - mDragPoint.x;
           oldSpanY = mMarginRectF.centerY() - mDragPoint.y;
         } else if (circleContain(
             mDragPoint.x,
             mDragPoint.y,
             mMarginRectF.left,
             mMarginRectF.bottom,
             mMarginRectF.centerX(),
             mMarginRectF.centerY())) {
           newSpanX = mMarginRectF.centerX() - x;
           newSpanY = y - mMarginRectF.centerY();
           oldSpanX = mMarginRectF.centerX() - mDragPoint.x;
           oldSpanY = mDragPoint.y - mMarginRectF.centerY();
         } else if (circleContain(
             mDragPoint.x,
             mDragPoint.y,
             mMarginRectF.right,
             mMarginRectF.top,
             mMarginRectF.centerX(),
             mMarginRectF.centerY())) {
           newSpanX = x - mMarginRectF.centerX();
           newSpanY = mMarginRectF.centerY() - y;
           oldSpanX = mDragPoint.x - mMarginRectF.centerX();
           oldSpanY = mMarginRectF.centerY() - mDragPoint.y;
         } else {
           newSpanX = x - mMarginRectF.centerX();
           newSpanY = y - mMarginRectF.centerY();
           oldSpanX = mDragPoint.x - mMarginRectF.centerX();
           oldSpanY = mDragPoint.y - mMarginRectF.centerY();
         }
       } else {
         if (mDragPoint.x == mMarginRectF.left) {
           if (mDragPoint.y == mMarginRectF.top) {
             newSpanX = mMarginRectF.centerX() - x;
             newSpanY = mMarginRectF.centerY() - y;
             oldSpanX = mMarginRectF.centerX() - mMarginRectF.left;
             oldSpanY = mMarginRectF.centerY() - mMarginRectF.top;
           } else {
             newSpanX = mMarginRectF.centerX() - x;
             newSpanY = y - mMarginRectF.centerY();
             oldSpanX = mMarginRectF.centerX() - mMarginRectF.left;
             oldSpanY = mMarginRectF.bottom - mMarginRectF.centerY();
           }
         } else {
           if (mDragPoint.y == mMarginRectF.top) {
             newSpanX = x - mMarginRectF.centerX();
             newSpanY = mMarginRectF.centerY() - y;
             oldSpanX = mMarginRectF.right - mMarginRectF.centerX();
             oldSpanY = mMarginRectF.centerY() - mMarginRectF.top;
           } else {
             newSpanX = x - mMarginRectF.centerX();
             newSpanY = y - mMarginRectF.centerY();
             oldSpanX = mMarginRectF.right - mMarginRectF.centerX();
             oldSpanY = mMarginRectF.bottom - mMarginRectF.centerY();
           }
         }
       }
       scaleX = newSpanX / oldSpanX;
       scaleY = newSpanY / oldSpanY;
       scale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
       if (INNER_RECT) {
         float radius =
             computeRadius(
                 x, y, mDragPoint.x, mDragPoint.y, mMarginRectF.centerX(), mMarginRectF.centerY());
         postScaleWithRadius(scale, radius, mMarginRectF.centerX(), mMarginRectF.centerY());
       } else {
         postScale(scale, mMarginRectF.centerX(), mMarginRectF.centerY());
       }
       break;
     case MotionEvent.ACTION_UP:
       if (getScale() < 1f) {
         zoomTo(1f, 50);
       }
     default:
       mDragPoint.set(INVALID_POINT, INVALID_POINT);
       postInvalidate();
       break;
   }
   return true;
 }
Ejemplo n.º 28
0
 public boolean onTouchEvent(MotionEvent ev) {
   mGD.onTouchEvent(ev);
   mSGD.onTouchEvent(ev);
   mRGD.onTouchEvent(ev);
   return true;
 }
Ejemplo n.º 29
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   scaleDetector.onTouchEvent(event);
   swipeDetector.onTouchEvent(event);
   return super.onTouchEvent(event);
 }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   return mDetector.onTouchEvent(event);
 }