List of usage examples for android.view MotionEvent getX
public final float getX()
From source file:cn.ismartv.tvrecyclerview.widget.RecyclerView.java
/** * Does not perform bounds checking. Used by internal methods that have already validated input. * <p>//from w w w . ja v a 2 s. c o m * It also reports any unused scroll request to the related EdgeEffect. * * @param x The amount of horizontal scroll request * @param y The amount of vertical scroll request * @param ev The originating MotionEvent, or null if not from a touch event. * * @return Whether any scroll was consumed in either direction. */ boolean scrollByInternal(int x, int y, MotionEvent ev) { int unconsumedX = 0, unconsumedY = 0; int consumedX = 0, consumedY = 0; consumePendingUpdateOperations(); if (mAdapter != null) { eatRequestLayout(); onEnterLayoutOrScroll(); TraceCompat.beginSection(TRACE_SCROLL_TAG); if (x != 0) { consumedX = mLayout.scrollHorizontallyBy(x, mRecycler, mState); unconsumedX = x - consumedX; } if (y != 0) { consumedY = mLayout.scrollVerticallyBy(y, mRecycler, mState); unconsumedY = y - consumedY; } TraceCompat.endSection(); repositionShadowingViews(); onExitLayoutOrScroll(); resumeRequestLayout(false); } if (!mItemDecorations.isEmpty()) { invalidate(); } if (dispatchNestedScroll(consumedX, consumedY, unconsumedX, unconsumedY, mScrollOffset)) { // Update the last touch co-ords, taking any scroll offset into account mLastTouchX -= mScrollOffset[0]; mLastTouchY -= mScrollOffset[1]; if (ev != null) { ev.offsetLocation(mScrollOffset[0], mScrollOffset[1]); } mNestedOffsets[0] += mScrollOffset[0]; mNestedOffsets[1] += mScrollOffset[1]; } else if (getOverScrollMode() != View.OVER_SCROLL_NEVER) { if (ev != null) { pullGlows(ev.getX(), unconsumedX, ev.getY(), unconsumedY); } considerReleasingGlowsOnScroll(x, y); } if (consumedX != 0 || consumedY != 0) { dispatchOnScrolled(consumedX, consumedY); } if (!awakenScrollBars()) { invalidate(); } return consumedX != 0 || consumedY != 0; }