Example usage for android.support.v4.view InputDeviceCompat SOURCE_CLASS_POINTER

List of usage examples for android.support.v4.view InputDeviceCompat SOURCE_CLASS_POINTER

Introduction

In this page you can find the example usage for android.support.v4.view InputDeviceCompat SOURCE_CLASS_POINTER.

Prototype

int SOURCE_CLASS_POINTER

To view the source code for android.support.v4.view InputDeviceCompat SOURCE_CLASS_POINTER.

Click Source Link

Document

The input source is a pointing device associated with a display.

Usage

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;/* ww w.ja va  2s .  c  o  m*/
                    } 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;//  ww  w .j  a  va2  s . c om
                    } 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;
    }//from   ww  w . j av  a 2  s. co m
    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 ww  w . j a va  2 s . c  om
    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  w ww  . ja va  2s.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;
}