private MotionEvent obtainMotionEvent(MotionEvent base, int action) { MotionEvent ev = MotionEvent.obtainNoHistory(base); ev.setAction(action); return ev; }
case MotionEvent.ACTION_DOWN: mInitialPoint = new PointF(ev.getX(), ev.getY()); mPendingDownMotionEvent = MotionEvent.obtainNoHistory(ev); mDownMotionEventPended = true; mIntercepting = mTouchInterceptionListener.shouldInterceptTouchEvent(ev, false, 0, 0);
Rect childRect = new Rect(); childView.getHitRect(childRect); MotionEvent event = MotionEvent.obtainNoHistory(ev); if (!childRect.contains((int) event.getX(), (int) event.getY())) { continue; for (MotionEvent pe : pendingEvents) { if (pe != null) { MotionEvent peAdjusted = MotionEvent.obtainNoHistory(pe); peAdjusted.offsetLocation(offsetX, offsetY); consumed |= childView.dispatchTouchEvent(peAdjusted);
mBeganFromDownMotionEvent = true; MotionEvent event = MotionEvent.obtainNoHistory(mPendingDownMotionEvent); event.setLocation(ev.getX(), ev.getY()); mTouchInterceptionListener.onDownMotionEvent(event); if (mDownMotionEventPended) { mDownMotionEventPended = false; MotionEvent event = MotionEvent.obtainNoHistory(mPendingDownMotionEvent); event.setLocation(ev.getX(), ev.getY()); duplicateTouchEventForChildren(ev, event); if (mDownMotionEventPended) { mDownMotionEventPended = false; MotionEvent event = MotionEvent.obtainNoHistory(mPendingDownMotionEvent); event.setLocation(ev.getX(), ev.getY()); duplicateTouchEventForChildren(ev, event);
mPrevMoveEvent = MotionEvent.obtainNoHistory(ev); if (getCurrentScrollY() - diffY <= 0) { offsetY += v.getTop() - v.getScrollY(); final MotionEvent event = MotionEvent.obtainNoHistory(ev); event.offsetLocation(offsetX, offsetY);
mPrevMoveEvent = MotionEvent.obtainNoHistory(ev); if (getCurrentScrollY() - diffY <= 0) { offsetY += v.getTop() - v.getScrollY(); final MotionEvent event = MotionEvent.obtainNoHistory(ev); event.offsetLocation(offsetX, offsetY);
mPrevMoveEvent = MotionEvent.obtainNoHistory(ev); if (getCurrentScrollY() - diffY <= 0) { offsetY += v.getTop() - v.getScrollY(); final MotionEvent event = MotionEvent.obtainNoHistory(ev); event.offsetLocation(offsetX, offsetY);
mPrevMoveEvent = MotionEvent.obtainNoHistory(ev); if (getCurrentScrollY() - diffY <= 0) { offsetY += v.getTop() - v.getScrollY(); final MotionEvent event = MotionEvent.obtainNoHistory(ev); event.offsetLocation(offsetX, offsetY);
mPrevMoveEvent = MotionEvent.obtainNoHistory(ev); if (getCurrentScrollY() - diffY <= 0) { final MotionEvent event = MotionEvent.obtainNoHistory(ev); event.offsetLocation(offsetX, offsetY);
/** * Handled forwarded motion events and determines when to stop forwarding. * * @param srcEvent motion event in source view coordinates * @return true to continue forwarding motion events, false to cancel */ private boolean onTouchForwarded(MotionEvent srcEvent) { final View src = mSrc; final ListPopupWindow popup = getPopup(); if (popup == null || !popup.isShowing()) { return false; } final DropDownListView dst = popup.mDropDownList; if (dst == null || !dst.isShown()) { return false; } // Convert event to destination-local coordinates. final MotionEvent dstEvent = MotionEvent.obtainNoHistory(srcEvent); toGlobalMotionEvent(src, dstEvent); toLocalMotionEvent(dst, dstEvent); // Forward converted event to destination view, then recycle it. final boolean handled = dst.onForwardedEvent(dstEvent, mActivePointerId); dstEvent.recycle(); // Always cancel forwarding when the touch stream ends. final int action = MotionEventCompat.getActionMasked(srcEvent); final boolean keepForwarding = action != MotionEvent.ACTION_UP && action != MotionEvent.ACTION_CANCEL; return handled && keepForwarding; }
assertThat(motionEvent2).historicalEventTime(0).isEqualTo(eventTime); motionEventDynamic = MotionEvent.obtainNoHistory(motionEvent2);
private MotionEvent rotateEvent(final MotionEvent event, float degrees, float px, float py) { if (degrees == 0) return event; matrix.setRotate(degrees, px, py); final MotionEvent rotatedEvent; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { rotatedEvent = MotionEvent.obtain(event); rotatedEvent.transform(matrix); } else { rotatedEvent = MotionEvent.obtainNoHistory(event); points[0] = event.getX(); points[1] = event.getY(); matrix.mapPoints(points); rotatedEvent.setLocation(points[0], points[1]); } return rotatedEvent; }