コード例 #1
0
ファイル: MapController.java プロジェクト: ric96/tangram-es
  public boolean onScale(ScaleGestureDetector detector) {
    // the velocity of the pinch in scale factor per ms
    float velocity =
        (detector.getCurrentSpan() - detector.getPreviousSpan()) / detector.getTimeDelta();
    float currentSpan = detector.getCurrentSpanX();
    float prevSpan = detector.getPreviousSpanX();

    double diff = Math.abs(currentSpan - prevSpan);

    /*
     * If Shove is in progress do not handle scale
     * If previous scale is handled then keep on handling scale
     * else give some buffer for shove to be processed
     */
    if (mDoubleTapScale
        || mScaleHandled
        || (!mShoveHandled
            && diff
                > PINCH_THRESHOLD
                    * Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels))) {
      mScaleHandled = true;
      float focusX = mDoubleTapScale ? mapView.getWidth() * 0.5f : detector.getFocusX();
      float focusY = mDoubleTapScale ? mapView.getHeight() * 0.5f : detector.getFocusY();
      mLastDoubleGestureTime = detector.getEventTime();
      handlePinchGesture(focusX, focusY, detector.getScaleFactor(), velocity);
      return true;
    }
    mScaleHandled = false;
    return false;
  }