Example #1
0
 @Override
 public boolean onScale(ScaleGestureDetector detector) {
   if (ignoreDetectorEvents()) return false;
   // It is possible that pinchBegin() was never called when we reach here.
   // This happens when webkit handles the 2nd touch down event. That causes
   // ContentView to ignore the onScaleBegin() call. And if webkit does not
   // handle the touch move events afterwards, we will face a situation
   // that pinchBy() is called without any pinchBegin().
   // To solve this problem, we call pinchBegin() here if it is never called.
   if (!mPinchEventSent) {
     mContentViewCore
         .getContentViewGestureHandler()
         .pinchBegin(
             detector.getEventTime(), (int) detector.getFocusX(), (int) detector.getFocusY());
     mPinchEventSent = true;
   }
   mContentViewCore
       .getContentViewGestureHandler()
       .pinchBy(
           detector.getEventTime(),
           (int) detector.getFocusX(),
           (int) detector.getFocusY(),
           detector.getScaleFactor());
   return true;
 }
Example #2
0
  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;
  }
Example #3
0
 @Override
 public void onScaleEnd(ScaleGestureDetector detector) {
   if (!mPinchEventSent || !mContentViewCore.isAlive()) return;
   mContentViewCore.getContentViewGestureHandler().pinchEnd(detector.getEventTime());
   mPinchEventSent = false;
 }