private boolean onUp(MotionEvent event, MapView mapView) {
    if (this.onTargetClickListener != null && this.isAClick) {
      this.clickUpCoords[0] = event.getX();
      this.clickUpCoords[1] = event.getY();

      if (Math.abs(this.clickUpCoords[0] - this.clickDownCoords[0]) < 10
          && Math.abs(this.clickUpCoords[1] - this.clickDownCoords[1]) < 10) {
        IGeoPoint igeoPoint =
            mapView.getProjection().fromPixels((int) event.getX(), (int) event.getY());
        GeoPoint geoPoint = new GeoPoint(igeoPoint.getLatitudeE6(), igeoPoint.getLongitudeE6());
        if (event.getEventTime() - this.clickDownTime
                < android.view.ViewConfiguration.getLongPressTimeout()
            && isEventOnTarget(event, mapView)) {
          this.lockPosition = true;
          this.onTargetClickListener.onClick(getMyLocation());
          return true;
        } else if (this.lockPosition == false
            && event.getEventTime() - this.clickDownTime
                >= 0) { // android.view.ViewConfiguration.getP) {
          setLocation(geoPoint);
          mapView.invalidate();
          return true;
        }
      }
      this.isAClick = false;
    }
    return false;
  }
  private void setContext(MotionEvent curr) {
    if (mCurrEvent != null) {
      mCurrEvent.recycle();
    }
    mCurrEvent = MotionEvent.obtain(curr);

    mCurrLen = -1;
    mPrevLen = -1;
    mScaleFactor = -1;

    final MotionEvent prev = mPrevEvent;

    final float px0 = prev.getX(0);
    final float py0 = prev.getY(0);
    final float px1 = prev.getX(1);
    final float py1 = prev.getY(1);
    final float cx0 = curr.getX(0);
    final float cy0 = curr.getY(0);
    final float cx1 = curr.getX(1);
    final float cy1 = curr.getY(1);

    final float pvx = px1 - px0;
    final float pvy = py1 - py0;
    final float cvx = cx1 - cx0;
    final float cvy = cy1 - cy0;
    mPrevFingerDiffX = pvx;
    mPrevFingerDiffY = pvy;
    mCurrFingerDiffX = cvx;
    mCurrFingerDiffY = cvy;

    mTimeDelta = curr.getEventTime() - prev.getEventTime();
    mCurrPressure = curr.getPressure(0) + curr.getPressure(1);
    mPrevPressure = prev.getPressure(0) + prev.getPressure(1);
  }
  public boolean onTouchEvent(final MotionEvent event) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        {
          if (event.getEventTime() - last_tap < 333) tap_count = tap_count + 1;
          else tap_count = 1;

          last_tap = event.getEventTime();

          ToucheBegan(event.getX(0), event.getY(0), tap_count);
          break;
        }

      case MotionEvent.ACTION_MOVE:
        {
          ToucheMoved(event.getX(0), event.getY(0), tap_count);
          break;
        }

      case MotionEvent.ACTION_UP:
        {
          ToucheEnded(event.getX(0), event.getY(0), tap_count);
          break;
        }
    }

    return true;
  }
  public boolean onTouch(View view, MotionEvent motionevent) {
    int i = motionevent.getActionMasked();
    int j = motionevent.getPointerCount();
    switch (mTwoSwipeState) {
      case INITIAL:
        if (i == 0 && j == 1) mTwoSwipeState = TwoPointerSwipeState.ONE_DOWN;
        break;
      case ONE_DOWN:
        if (i == 5) {
          if (j == 2) {
            mTwoSwipeState = TwoPointerSwipeState.TWO_DOWN;
            motionevent.getPointerCoords(0, mPointerStart[0]);
            motionevent.getPointerCoords(1, mPointerStart[1]);
            mStartTime = motionevent.getEventTime();
            if (verifyPointerDistance(mPointerStart))
              mTwoSwipeState = TwoPointerSwipeState.TWO_DOWN;
            else mTwoSwipeState = TwoPointerSwipeState.INITIAL;
          } else {
            mTwoSwipeState = TwoPointerSwipeState.INITIAL;
          }
        } else if (i == 1 || i == 6) mTwoSwipeState = TwoPointerSwipeState.INITIAL;
        break;
      case TWO_DOWN:
        if (j != 2) mTwoSwipeState = TwoPointerSwipeState.INITIAL;
        else if (i == 6) {
          motionevent.getPointerCoords(0, mPointerEnd[0]);
          motionevent.getPointerCoords(1, mPointerEnd[1]);
          mEndTime = motionevent.getEventTime();
          if (verifyPointerDistance(mPointerEnd)) mTwoSwipeState = TwoPointerSwipeState.ONE_UP;
          else mTwoSwipeState = TwoPointerSwipeState.INITIAL;
        }
        break;
      case ONE_UP:
        if (j != 1) mTwoSwipeState = TwoPointerSwipeState.INITIAL;
        else if (i == 5 || i == 0) mTwoSwipeState = TwoPointerSwipeState.INITIAL;
        else if (i == 1)
          if (motionevent.getEventTime() - mEndTime > 100L) {
            mTwoSwipeState = TwoPointerSwipeState.INITIAL;
          } else {
            mTwoSwipeState = TwoPointerSwipeState.INITIAL;
            long l = mEndTime - mStartTime;
            if (l > 0L && l <= 500L) {
              float f = (1000F * (mPointerEnd[0].x - mPointerStart[0].x)) / (float) l;
              float f1 = (1000F * (mPointerEnd[0].y - mPointerStart[0].y)) / (float) l;
              onTwoPointerSwipe(mPointerStart[0], mPointerEnd[0], f, f1);
            }
          }
        break;
      default:
        break;
    }

    return mGestureDetector.onTouchEvent(motionevent);
  }
 private boolean isConsideredDoubleTap(MotionEvent motionevent, MotionEvent motionevent1, MotionEvent motionevent2)
 {
     if (mAlwaysInBiggerTapRegion && motionevent2.getEventTime() - motionevent1.getEventTime() <= (long)DOUBLE_TAP_TIMEOUT)
     {
         int i = (int)motionevent.getX() - (int)motionevent2.getX();
         int j = (int)motionevent.getY() - (int)motionevent2.getY();
         if (i * i + j * j < mDoubleTapSlopSquare)
         {
             return true;
         }
     }
     return false;
 }
    private boolean isConsideredDoubleTap(
        MotionEvent firstDown, MotionEvent firstUp, MotionEvent secondDown) {
      if (!mAlwaysInBiggerTapRegion) {
        return false;
      }

      if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT) {
        return false;
      }

      int deltaX = (int) firstDown.getX() - (int) secondDown.getX();
      int deltaY = (int) firstDown.getY() - (int) secondDown.getY();
      return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare);
    }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    int action = event.getAction();
    float x = event.getX();
    float y = event.getY();
    float deltaX = Math.abs(x - mFirstDownX);
    float deltaY = Math.abs(y - mFirstDownY);
    switch (action) {
      case MotionEvent.ACTION_DOWN:
        attemptClaimDrag();
        mFirstDownX = x;
        mFirstDownY = y;
        mCurBtnPic = mBtnPressed;
        mBtnInitPos = mChecked ? mBtnOnPos : mBtnOffPos;
        break;
      case MotionEvent.ACTION_MOVE:
        // 拖动着的时间
        float time = event.getEventTime() - event.getDownTime();
        // 当前按钮的位置
        mBtnPos = mBtnInitPos + event.getX() - mFirstDownX;
        if (mBtnPos >= mBtnOffPos) {
          mBtnPos = mBtnOffPos;
        }
        if (mBtnPos <= mBtnOnPos) {
          mBtnPos = mBtnOnPos;
        }
        mTurningOn = mBtnPos > (mBtnOffPos - mBtnOnPos) / 2 + mBtnOnPos;

        mRealPos = getRealPos(mBtnPos);
        break;
      case MotionEvent.ACTION_UP:
        mCurBtnPic = mBtnNormal;
        time = event.getEventTime() - event.getDownTime();
        if (deltaY < mTouchSlop && deltaX < mTouchSlop && time < mClickTimeout) {
          if (mPerformClick == null) {
            mPerformClick = new PerformClick();
          }
          if (!post(mPerformClick)) {
            performClick();
          }
        } else {
          startAnimation(!mTurningOn);
        }
        break;
    }

    invalidate();
    return isEnabled();
  }
 @Override
 public void onPointerEvent(MotionEvent motionEvent) {
   final int action = motionEvent.getAction();
   switch (action & MotionEvent.ACTION_MASK) {
     case MotionEvent.ACTION_DOWN:
       mPointerId = motionEvent.getPointerId(0);
       mDownX = motionEvent.getX();
       mDownY = motionEvent.getY();
       break;
     case MotionEvent.ACTION_MOVE:
       if (mPointerId >= 0) {
         int index = motionEvent.findPointerIndex(mPointerId);
         /// M : ALPS01259500, JE at motionEvent.getX
         /// The value of index sometimes was less than 0
         /// Before using it, need to check the value @{
         if (index < 0) {
           mPointerId = -1;
           break;
         }
         /// @}
         if ((motionEvent.getEventTime() - motionEvent.getDownTime()) > TAP_TIMEOUT_MSEC
             || (motionEvent.getX(index) - mDownX) > mMotionSlop
             || (motionEvent.getY(index) - mDownY) > mMotionSlop) {
           mPointerId = -1;
         }
       }
       break;
     case MotionEvent.ACTION_UP:
     case MotionEvent.ACTION_POINTER_UP:
       {
         int index =
             (action & MotionEvent.ACTION_POINTER_INDEX_MASK)
                 >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
         // Extract the index of the pointer that left the touch sensor
         if (mPointerId == motionEvent.getPointerId(index)) {
           final int x = (int) motionEvent.getX(index);
           final int y = (int) motionEvent.getY(index);
           if ((motionEvent.getEventTime() - motionEvent.getDownTime()) < TAP_TIMEOUT_MSEC
               && (x - mDownX) < mMotionSlop
               && (y - mDownY) < mMotionSlop
               && !mTouchExcludeRegion.contains(x, y)) {
             mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, mDisplayContent).sendToTarget();
           }
           mPointerId = -1;
         }
         break;
       }
   }
 }
Beispiel #9
0
 @Override
 public boolean onDoubleTapEvent(MotionEvent ev) {
   if (ev.getEventTime() - lastDownEventTime < DOUBLE_TAP_TIME) {
     zoomModel.toggleZoomControls();
     if (null != mPageModel) {
       mPageModel.setCurrentPage(currentPageModel.getCurrentPageIndex());
       mPageModel.setPageCount(decodeService.getPageCount());
       mPageModel.toggleSeekControls();
     }
     return true;
   } else {
     lastDownEventTime = ev.getEventTime();
   }
   return false;
 }
Beispiel #10
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   int action = event.getAction();
   float x = event.getX();
   float y = event.getY();
   float deltaX = Math.abs(x - mFirstDownX);
   float deltaY = Math.abs(y - mFirstDownY);
   switch (action) {
     case MotionEvent.ACTION_DOWN:
       ViewParent mParent = getParent();
       if (mParent != null) {
         // 通知父控件不要拦截本view的触摸事件
         mParent.requestDisallowInterceptTouchEvent(true);
       }
       mFirstDownX = x;
       mFirstDownY = y;
       bmCurBtnPic = bmBtnPressed;
       startBtnPos = mChecked ? onBtnPos : offBtnPos;
       break;
     case MotionEvent.ACTION_MOVE:
       float time = event.getEventTime() - event.getDownTime();
       curBtnPos = startBtnPos + event.getX() - mFirstDownX;
       if (curBtnPos >= onBtnPos) {
         curBtnPos = onBtnPos;
       }
       if (curBtnPos <= offBtnPos) {
         curBtnPos = offBtnPos;
       }
       mTurningOn = curBtnPos > bgWidth / 2 - btnWidth / 2;
       break;
     case MotionEvent.ACTION_UP:
       bmCurBtnPic = bmBtnNormal;
       time = event.getEventTime() - event.getDownTime();
       if (deltaY < mTouchSlop && deltaX < mTouchSlop && time < mClickTimeout) {
         if (mPerformClick == null) {
           mPerformClick = new PerformClick();
         }
         if (!post(mPerformClick)) {
           performClick();
         }
       } else {
         startAnimation(mTurningOn);
       }
       break;
   }
   invalidate();
   return isEnabled();
 }
    public boolean onTouchEvent(MotionEvent motionevent)
    {
        motionevent.getAction();
        JVM INSTR tableswitch 0 3: default 36
    //                   0 38
    //                   1 133
    //                   2 74
    //                   3 121;
           goto _L1 _L2 _L3 _L4 _L5
_L1:
        return true;
_L2:
        mIsCapturingGesture = true;
        mIsClickCandidate = true;
        mActionDownTime = motionevent.getEventTime();
        mActionDownX = motionevent.getX();
        mActionDownY = motionevent.getY();
        return true;
_L4:
        if (Math.abs(motionevent.getX() - mActionDownX) > mSingleTapSlopPx || Math.abs(motionevent.getY() - mActionDownY) > mSingleTapSlopPx)
        {
            mIsClickCandidate = false;
            return true;
        }
          goto _L1
  private void track(MotionEvent event) {
    mX.saveTouchPos();
    mY.saveTouchPos();

    for (int i = 0; i < event.getHistorySize(); i++) {
      track(
          event.getHistoricalX(0, i), event.getHistoricalY(0, i), event.getHistoricalEventTime(i));
    }
    track(event.getX(0), event.getY(0), event.getEventTime());

    if (stopped()) {
      if (mState == PanZoomState.PANNING) {
        setState(PanZoomState.PANNING_HOLD);
      } else if (mState == PanZoomState.PANNING_LOCKED) {
        setState(PanZoomState.PANNING_HOLD_LOCKED);
      } else {
        // should never happen, but handle anyway for robustness
        Log.e(LOGTAG, "Impossible case " + mState + " when stopped in track");
        setState(PanZoomState.PANNING_HOLD_LOCKED);
      }
    }

    mX.startPan();
    mY.startPan();
    updatePosition();
  }
  private boolean onTouchStart(MotionEvent event) {
    // user is taking control of movement, so stop
    // any auto-movement we have going
    stopAnimationTimer();

    switch (mState) {
      case ANIMATED_ZOOM:
        // We just interrupted a double-tap animation, so force a redraw in
        // case this touchstart is just a tap that doesn't end up triggering
        // a redraw
        mTarget.setForceRedraw();
        // fall through
      case FLING:
      case BOUNCE:
      case NOTHING:
      case WAITING_LISTENERS:
        startTouch(event.getX(0), event.getY(0), event.getEventTime());
        return false;
      case TOUCHING:
      case PANNING:
      case PANNING_LOCKED:
      case PANNING_HOLD:
      case PANNING_HOLD_LOCKED:
      case PINCHING:
        Log.e(LOGTAG, "Received impossible touch down while in " + mState);
        return false;
    }
    Log.e(LOGTAG, "Unhandled case " + mState + " in onTouchStart");
    return false;
  }
  private boolean processTouch(MotionEvent event) {
    // Checking if that event was already processed
    // (by onInterceptTouchEvent prior to onTouchEvent)
    long eventTime = event.getEventTime();
    int action = event.getActionMasked();

    if (lastTouchEventTime == eventTime && lastTouchEventAction == action) {
      return lastTouchEventResult;
    }

    lastTouchEventTime = eventTime;
    lastTouchEventAction = action;

    if (getCount() > 0) {
      // Fixing event's Y position due to performed translation
      MotionEvent eventCopy = MotionEvent.obtain(event);
      eventCopy.offsetLocation(0, getTranslationY());
      lastTouchEventResult = gestureDetector.onTouchEvent(eventCopy);
      eventCopy.recycle();
    } else {
      lastTouchEventResult = false;
    }

    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
      onUpOrCancel();
    }

    return lastTouchEventResult;
  }
Beispiel #15
0
 public boolean onTouchEvent(MotionEvent event) {
   boolean eventCatch = false;
   long time = event.getEventTime();
   eventCatch = evaluateTouch(event);
   if (!eventCatch) {
     Vector<ARSphericalView> arViewReverse = new Vector<ARSphericalView>(getArViews());
     Collections.sort(arViewReverse);
     Iterator<ARSphericalView> it = arViewReverse.iterator();
     View v;
     while (it.hasNext() && !eventCatch) {
       v = it.next();
       eventCatch = v.dispatchTouchEvent(event);
       if (!poiMove) poiMove = ((MagnitudePOI) v).isShifted();
     }
   }
   if (!eventCatch) {
     if (event.getAction() == MotionEvent.ACTION_DOWN) {
       timeOfStart = time;
       inClick = true;
     } else if (inClick
         && event.getAction() == MotionEvent.ACTION_UP
         && (time - timeOfStart) > 1000) {
       LaunchAction();
       inClick = false;
     }
   }
   return true;
 }
 private static MotionEvent transformEventOld(MotionEvent paramMotionEvent, Matrix paramMatrix) {
   long l1 = paramMotionEvent.getDownTime();
   long l2 = paramMotionEvent.getEventTime();
   int i = paramMotionEvent.getAction();
   int j = paramMotionEvent.getPointerCount();
   int[] arrayOfInt = getPointerIds(paramMotionEvent);
   MotionEvent.PointerCoords[] arrayOfPointerCoords = getPointerCoords(paramMotionEvent);
   int k = paramMotionEvent.getMetaState();
   float f1 = paramMotionEvent.getXPrecision();
   float f2 = paramMotionEvent.getYPrecision();
   int l = paramMotionEvent.getDeviceId();
   int i1 = paramMotionEvent.getEdgeFlags();
   int i2 = paramMotionEvent.getSource();
   int i3 = paramMotionEvent.getFlags();
   float[] arrayOfFloat = new float[2 * arrayOfPointerCoords.length];
   for (int i4 = 0; i4 < j; ++i4) {
     arrayOfFloat[(i4 * 2)] = arrayOfPointerCoords[i4].x;
     arrayOfFloat[(1 + i4 * 2)] = arrayOfPointerCoords[i4].y;
   }
   paramMatrix.mapPoints(arrayOfFloat);
   for (int i5 = 0; i5 < j; ++i5) {
     arrayOfPointerCoords[i5].x = arrayOfFloat[(i5 * 2)];
     arrayOfPointerCoords[i5].y = arrayOfFloat[(1 + i5 * 2)];
     arrayOfPointerCoords[i5].orientation =
         transformAngle(paramMatrix, arrayOfPointerCoords[i5].orientation);
   }
   return MotionEvent.obtain(
       l1, l2, i, j, arrayOfInt, arrayOfPointerCoords, k, f1, f2, l, i1, i2, i3);
 }
Beispiel #17
0
  @Override
  protected boolean onTouchImpl(View view, MotionEvent event) {
    boolean result = false;

    if (mJoystickLeft != null && mJoystickLeft.processTouch(view, event)) result = true;

    if (mJoystickRight != null && mJoystickRight.processTouch(view, event)) result = true;

    // check for double tap
    if (mSettings.isFlipEnabled() && event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
      long currTimestamp = event.getEventTime();

      if (event.getPointerCount() > 1) {
        if (currTimestamp - timestampLast < DOUBLE_TAP_TIMESTAMP_DELTA
            && Math.abs(event.getX(1) - xLast) < COORDINATE_DELTA
            && Math.abs(event.getY(1) - yLast) < COORDINATE_DELTA) {
          // Double tap detected.
          mDroneControl.doLeftFlip();
          result = true;
        }
      }
    }

    return result;
  }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   final int action = event.getActionMasked();
   switch (action) {
     case MotionEvent.ACTION_DOWN:
       downX = event.getX();
       downY = event.getY();
       break;
     case MotionEvent.ACTION_UP:
       // 先判断是否是点击事件
       if ((isClickable() || isLongClickable())
           && ((event.getX() - downX) < mTouchSlop || (event.getY() - downY) < mTouchSlop)) {
         // 这里我们得到了一个点击事件
         if (isFocusable() && isFocusableInTouchMode() && !isFocused()) requestFocus();
         if (event.getEventTime() - event.getDownTime() >= ViewConfiguration.getLongPressTimeout()
             && isLongClickable()) {
           // 是一个长按事件
           //                        performLongClick();
           Log.i("actiontype", "longClick");
         } else {
           // 点击事件
           performClick(event.getX());
         }
       }
       break;
   }
   return true;
 }
 private boolean isClickCandidateLocked(MotionEvent event) {
   if (event == null || event.getActionMasked() != MotionEvent.ACTION_UP || !mIsTapCandidate) {
     return false;
   }
   long downDuration = event.getEventTime() - event.getDownTime();
   return downDuration < LONG_PRESS_TIMEOUT;
 }
Beispiel #20
0
  public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

    // Ignore onScroll for a small time period after a double finger gesture has occured
    // Depending on how fingers are picked up after a double finger gesture, there could be a
    // residual "single"
    // finger pan which could also result in a fling. This check will ignore that.
    long time = e2.getEventTime();
    if (((time - mLastDoubleGestureTime) < SCROLL_TIME_THRESHOLD) && e2.getPointerCount() == 1) {
      return false;
    }

    if (mShoveHandled) {
      return false;
    }

    float x = 0, y = 0;
    int n = e2.getPointerCount();
    for (int i = 0; i < n; i++) {
      x += e2.getX(i) / n;
      y += e2.getY(i) / n;
    }

    handlePanGesture(x + distanceX, y + distanceY, x, y);

    return true;
  }
 @Override
 public boolean onSingleTapUp(MotionEvent event) {
   if (mTapHandler == null) return true;
   mTapHandler.handleTapContextualSearchBar(
       event.getEventTime(),
       event.getX() * mPxToDp,
       mPanelManager.getActivePanel().getFullscreenY(event.getY()) * mPxToDp);
   return true;
 }
 /**
  * Test if a MotionEvent with the given start and end offsets can be considered as a "click".
  *
  * @param upEvent The final finger-up event.
  * @param xDown The x-offset of the down event.
  * @param yDown The y-offset of the down event.
  * @param xUp The x-offset of the up event.
  * @param yUp The y-offset of the up event.
  * @return true if it's a click, false otherwise
  */
 private boolean isClick(MotionEvent upEvent, float xDown, float yDown, float xUp, float yUp) {
   if (upEvent == null) return false;
   long time = upEvent.getEventTime() - upEvent.getDownTime();
   float distance =
       PointF.length( //
           xDown - xUp, //
           yDown - yUp);
   return time < MAX_CLICK_TIME && distance < MAX_CLICK_DISTANCE;
 }
 /**
  * Clone given motion event and set specified action. This method is useful, when we want to
  * cancel event propagation in child views by sending event with {@link MotionEvent#ACTION_CANCEL}
  * action.
  *
  * @param event event to clone
  * @param action new action
  * @return cloned motion event
  */
 private MotionEvent cloneMotionEventWithAction(MotionEvent event, int action) {
   return MotionEvent.obtain(
       event.getDownTime(),
       event.getEventTime(),
       action,
       event.getX(),
       event.getY(),
       event.getMetaState());
 }
    @Override
    public boolean onTouchEvent(MotionEvent event) {
      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          handleMouseDown(event.getX(), event.getY(), event.getEventTime());
          return true;
        case MotionEvent.ACTION_MOVE:
          handleMouseDrag(event.getX(), event.getY(), event.getEventTime());
          return true;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
          handleMouseUp(event.getX(), event.getY(), event.getEventTime());
          return true;
        default:
          break;
      }

      return false;
    }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   return nativeTouchEvent(
       mNativeMojoViewport,
       event.getPointerId(0),
       event.getAction(),
       event.getX(),
       event.getY(),
       event.getEventTime());
 }
 @Override
 public boolean onDown(MotionEvent event, MapView mapView) {
   if (event.getPointerCount() > 0) {
     this.clickDownCoords[0] = event.getX();
     this.clickDownCoords[1] = event.getY();
     this.clickDownTime = event.getEventTime();
     this.isAClick = true;
     return false;
   }
   return super.onDown(event, mapView);
 }
 private void sendUpEvent() {
   final MotionEvent last = mLastMoveEvent;
   MotionEvent e =
       MotionEvent.obtain(
           last.getDownTime(),
           last.getEventTime(),
           MotionEvent.ACTION_UP,
           last.getX(),
           last.getY(),
           last.getMetaState());
   dispatchTouchEvent(e);
 }
Beispiel #28
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (mRunner == null || mUptimeToMillis == 0) {
      Log.d(TAG, "Exiting onTouch: " + mUptimeToMillis);
      return false;
    }
    int pid;
    int action = event.getAction();
    float x;
    float y;

    for (int i = 0; i < event.getPointerCount(); i++) {
      pid = event.getPointerId(i);
      action = event.getAction();
      x = event.getX(i);
      y = event.getY(i);
      if (pid == 0) {
        mEventTime = event.getEventTime() + mUptimeToMillis;
        switch (action) {
          case MotionEvent.ACTION_DOWN:
          case MotionEvent.ACTION_POINTER_DOWN:
            mHandledLongPress = false;
            mTouchDownTime = mEventTime;
            mTouchDown[0] = x;
            mTouchDown[1] = y;
            mRunner.touchDown(x, y, mTouchDownTime);
            break;
          case MotionEvent.ACTION_UP: // Check for tap.
            mRunner.touchUp(x, y, mEventTime);
            if (mEventTime - mTouchDownTime < mTapTimeout
                && Math.abs(mTouchDown[0] - x) < mTouchSlop
                && Math.abs(mTouchDown[1] - y) < mTouchSlop) {
              mRunner.touchTap(x, y, mEventTime);
            } else {
              if (!mHandledLongPress && mEventTime - mTouchDownTime > mLongPressThreshold) {
                mRunner.longPress(x, y, mEventTime);
              }
            }
            break;
          case MotionEvent.ACTION_MOVE:
            mRunner.touchMove(x, y, mEventTime);
            if (Math.abs(mTouchDown[0] - x) > mTouchSlop
                || Math.abs(mTouchDown[1] - y) > mTouchSlop) {
              mHandledLongPress = true;
            }
            break;
        }
      }
    }
    return true;
  }
 private void captureDown(MotionEvent event, int pointerIndex) {
   final int pointerId = event.getPointerId(pointerIndex);
   final int i = findIndex(pointerId);
   if (DEBUG)
     Slog.d(
         TAG,
         "pointer " + pointerId + " down pointerIndex=" + pointerIndex + " trackingIndex=" + i);
   if (i != UNTRACKED_POINTER) {
     mDownX[i] = event.getX(pointerIndex);
     mDownY[i] = event.getY(pointerIndex);
     mDownTime[i] = event.getEventTime();
     if (DEBUG) Slog.d(TAG, "pointer " + pointerId + " down x=" + mDownX[i] + " y=" + mDownY[i]);
   }
 }
Beispiel #30
0
 private void sendDownEvent() {
   if (DEBUG) {
     PtrCLog.d(LOG_TAG, "send down event");
   }
   final MotionEvent last = mLastMoveEvent;
   MotionEvent e =
       MotionEvent.obtain(
           last.getDownTime(),
           last.getEventTime(),
           MotionEvent.ACTION_DOWN,
           last.getX(),
           last.getY(),
           last.getMetaState());
   dispatchTouchEventSupper(e);
 }