@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (hasNoCallbacks()) { return super.onInterceptTouchEvent(ev); } switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: // Whether or not motion events are consumed by children, // flag initializations which are related to ACTION_DOWN events should be executed. // Because if the ACTION_DOWN is consumed by children and only ACTION_MOVEs are // passed to parent (this view), the flags will be invalid. // Also, applications might implement initialization codes to onDownMotionEvent, // so call it here. mFirstScroll = mDragging = true; dispatchOnDownMotionEvent(); break; } return super.onInterceptTouchEvent(ev); }
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { downX = ev.getRawX(); downY = ev.getRawY(); isAtTop = isAtTop(); scrollMode = MODE_IDLE; getParent().requestDisallowInterceptTouchEvent(true); } else if (ev.getAction() == MotionEvent.ACTION_MOVE) { if (scrollMode == MODE_IDLE) { float xDistance = Math.abs(downX - ev.getRawX()); float yDistance = Math.abs(downY - ev.getRawY()); if (xDistance > yDistance && xDistance > mTouchSlop) { scrollMode = MODE_HORIZONTAL; } else if (yDistance > xDistance && yDistance > mTouchSlop) { scrollMode = MODE_VERTICAL; if (downY < ev.getRawY() && isAtTop) { getParent().requestDisallowInterceptTouchEvent(false); } } } } return super.onInterceptTouchEvent(ev); }
/** */ @Override public boolean onInterceptTouchEvent(@NonNull MotionEvent event) { this.ensureDecorator(); return mDecorator.onInterceptTouchEvent(event) || super.onInterceptTouchEvent(event); }
@Override public boolean onInterceptTouchEvent(MotionEvent event) { final int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN) { mCurrX = event.getX(); mCurrY = event.getY(); getParent().requestDisallowInterceptTouchEvent(true); } else if (action == MotionEvent.ACTION_MOVE) { // Shouldn't need to do anything } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { getParent().requestDisallowInterceptTouchEvent(false); } else { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(event); }