List of usage examples for android.support.v4.view MotionEventCompat ACTION_SCROLL
int ACTION_SCROLL
To view the source code for android.support.v4.view MotionEventCompat ACTION_SCROLL.
Click Source Link
From source file:org.mariotaku.twidere.view.RecyclerViewBackport.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { final LayoutManager lm = getLayoutManager(); if (lm == null) { return false; }/*www . j a v a 2s .c o m*/ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (lm.canScrollVertically()) { vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (!mMouseScrollDirectionDecider.isVerticalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { vScroll = 0f; } if (lm.canScrollHorizontally()) { hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); if (!mMouseScrollDirectionDecider.isHorizontalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { hScroll = 0f; } if ((vScroll != 0 || hScroll != 0)) { final float scrollFactor = getScrollFactorBackport(); float horizontalDirection = mMouseScrollDirectionDecider.getHorizontalDirection(); float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection(); final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1); final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1); smoothScrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor)); } } } return false; }
From source file:org.mariotaku.twidere.view.ExtendedRecyclerView.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { final LayoutManager lm = getLayoutManager(); if (lm == null) { return false; }/*from w w w. j ava 2 s. c o m*/ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (lm.canScrollVertically()) { vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (!mMouseScrollDirectionDecider.isVerticalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { vScroll = 0f; } if (lm.canScrollHorizontally()) { hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); if (!mMouseScrollDirectionDecider.isHorizontalAvailable()) { mMouseScrollDirectionDecider.guessDirection(event); } } else { hScroll = 0f; } if ((vScroll != 0 || hScroll != 0)) { final float scrollFactor = getScrollFactorBackport(); float horizontalDirection = mMouseScrollDirectionDecider.getHorizontalDirection(); float verticalDirection = mMouseScrollDirectionDecider.getVerticalDirection(); final float hFactor = scrollFactor * (horizontalDirection != 0 ? horizontalDirection : -1); final float vFactor = scrollFactor * (verticalDirection != 0 ? verticalDirection : -1); scrollBy((int) (hScroll * hFactor), (int) (vScroll * vFactor)); } } } return false; }
From source file:org.mariotaku.twidere.util.MouseScrollDirectionDecider.java
public boolean guessDirection(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) { return false; }//from w w w .j a va 2 s . com if (event.getAction() != MotionEventCompat.ACTION_SCROLL) return false; verticalScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); horizontalScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); verticalView.onGenericMotionEvent(event); horizontalView.onGenericMotionEvent(event); return verticalScroll != 0 || horizontalScroll != 0; }
From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java
public boolean onGenericMotionEvent(MotionEvent event) { if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEventCompat.ACTION_SCROLL: { if (!mIsBeingDragged) { final float vscroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL); if (vscroll != 0) { final int delta = (int) (vscroll * getVerticalScrollFactorCompat()); final int range = getScrollRange(); int oldScrollY = getScrollY(); int newScrollY = oldScrollY - delta; if (newScrollY < 0) { newScrollY = 0;//from w ww . j av a 2 s.c om } else if (newScrollY > range) { newScrollY = range; } if (newScrollY != oldScrollY) { super.scrollTo(getScrollX(), newScrollY); return true; } } } } } } return false; }
From source file:com.peerless2012.twowaynestedscrollview.TwoWayNestedScrollView.java
public boolean onGenericMotionEvent(MotionEvent event) { if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEventCompat.ACTION_SCROLL: { if (!mIsBeingDragged) { final float vscroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL); if (vscroll != 0) { final int delta = (int) (vscroll * getVerticalScrollFactorCompat()); final int range = getVerticalScrollRange(); int oldScrollY = getScrollY(); int newScrollY = oldScrollY - delta; if (newScrollY < 0) { newScrollY = 0;//from ww w .j a v a 2 s .co m } else if (newScrollY > range) { newScrollY = range; } if (newScrollY != oldScrollY) { super.scrollTo(getScrollX(), newScrollY); return true; } } } } } } return false; }
From source file:org.nekC.android.support.widget.RecyclerView.java
public boolean onGenericMotionEvent(MotionEvent event) { if (mLayout == null) { return false; }//w w w .j av a 2 s . c om if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (mLayout.canScrollVertically()) { vScroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL); } else { vScroll = 0f; } if (mLayout.canScrollHorizontally()) { hScroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_HSCROLL); } else { hScroll = 0f; } if (vScroll != 0 || hScroll != 0) { final float scrollFactor = getScrollFactor(); scrollBy((int) (hScroll * scrollFactor), (int) (vScroll * scrollFactor)); } } } return false; }
From source file:android.support.v71.widget.RecyclerView.java
public boolean onGenericMotionEvent(MotionEvent event) { if (mLayout == null) { return false; }//from w ww.j a v a2s. c o m if (mLayoutFrozen) { return false; } if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (mLayout.canScrollVertically()) { // Inverse the sign of the vertical scroll to align the scroll orientation // with AbsListView. vScroll = -MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL); } else { vScroll = 0f; } if (mLayout.canScrollHorizontally()) { hScroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_HSCROLL); } else { hScroll = 0f; } if (vScroll != 0 || hScroll != 0) { final float scrollFactor = getScrollFactor(); scrollByInternal((int) (hScroll * scrollFactor), (int) (vScroll * scrollFactor), event); } } } return false; }
From source file:cn.ismartv.tvrecyclerview.widget.RecyclerView.java
public boolean onGenericMotionEvent(MotionEvent event) { if (mLayout == null) { return false; }//from ww w.j a v a2 s . c om if (mLayoutFrozen) { return false; } if ((event.getSource() & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) { if (event.getAction() == MotionEventCompat.ACTION_SCROLL) { final float vScroll, hScroll; if (mLayout.canScrollVertically()) { // Inverse the sign of the vertical scroll to align the scroll orientation // with AbsListView. vScroll = -MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL); } else { vScroll = 0f; } if (mLayout.canScrollHorizontally()) { hScroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_HSCROLL); } else { hScroll = 0f; } if (vScroll != 0 || hScroll != 0) { final float scrollFactor = getScrollFactor(); scrollByInternal((int) (hScroll * scrollFactor), (int) (vScroll * scrollFactor), event); } } } return false; }