Example usage for android.support.v4.view ViewCompat canScrollHorizontally

List of usage examples for android.support.v4.view ViewCompat canScrollHorizontally

Introduction

In this page you can find the example usage for android.support.v4.view ViewCompat canScrollHorizontally.

Prototype

public static boolean canScrollHorizontally(View v, int direction) 

Source Link

Document

Check if this view can be scrolled horizontally in a certain direction.

Usage

From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 * or just its children (false).//from  w  ww.j  a v  a2s . c  o m
 * @param dx Delta scrolled in pixels
 * @param x X coordinate of the active touch point
 * @param y Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:com.base.view.slidemenu.SlideMenu.java

/**
 * Detect whether the views inside content are slidable
 *//*  ww w  . j  av a2s  .  c o  m*/
protected final boolean canScrollHorizontally(View v, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();

        final int childCount = viewGroup.getChildCount();
        for (int index = 0; index < childCount; index++) {
            View child = viewGroup.getChildAt(index);
            final int left = child.getLeft();
            final int top = child.getTop();
            if (x + scrollX >= left && x + scrollX < child.getRight() && y + scrollY >= top
                    && y + scrollY < child.getBottom() && View.VISIBLE == child.getVisibility()
                    && (ScrollDetectors.canScrollHorizontal(child, dx)
                            || canScrollHorizontally(child, dx, x + scrollX - left, y + scrollY - top))) {
                return true;
            }
        }
    }

    return ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:com.chauthai.swipereveallayout.ViewDragHelper.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx     Delta scrolled in pixels along the X axis
 * @param dy     Delta scrolled in pixels along the Y axis
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 *///  w ww . j  a va  2s  .  c o m
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}

From source file:com.yangc.swipebacklayout.helper.ViewDragHelper.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true), or just its children (false).
 * @param dx Delta scrolled in pixels along the X axis
 * @param dy Delta scrolled in pixels along the Y axis
 * @param x X coordinate of the active touch point
 * @param y Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 *///www  .  jav  a 2s  .  com
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}

From source file:com.lansun.qmyo.view.ViewDragHelper.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 * //from  w  w  w .  j a  v a2s . c  o  m
 * @param v
 *            View to test for horizontal scrollability
 * @param checkV
 *            Whether the view v passed should itself be checked for scrollability (true), or just its children (false).
 * @param dx
 *            Delta scrolled in pixels along the X axis
 * @param dy
 *            Delta scrolled in pixels along the Y axis
 * @param x
 *            X coordinate of the active touch point
 * @param y
 *            Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}

From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx Delta scrolled in pixels// ww w.j  a v  a  2 s  . co m
 * @param x X coordinate of the active touch point
 * @param y Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v/*  www .  j  av  a2 s .co m*/
 *            View to test for horizontal scrollability
 * @param checkV
 *            Whether the view v passed should itself be checked for
 *            scrollability (true), or just its children (false).
 * @param dx
 *            Delta scrolled in pixels
 * @param x
 *            X coordinate of the active touch point
 * @param y
 *            Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:com.along.practice.widget.swipbacklayout.ViewDragHelper.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for
 *               scrollability (true), or just its children (false).
 * @param dx     Delta scrolled in pixels along the X axis
 * @param dy     Delta scrolled in pixels along the Y axis
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 *//*from   www  . j a  v  a 2s  .c o m*/
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            //  Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}

From source file:cn.xm.xmvideoplayer.widget.swipebacklayout.ViewDragHelper.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for
 *               scrollability (true), or just its children (false).
 * @param dx     Delta scrolled in pixels along the X axis
 * @param dy     Delta scrolled in pixels along the Y axis
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 *///from  w  w w .  j  a  v  a2  s .  co m
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            // Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}

From source file:com.baidayi.swipback.ViewDragHelper.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 * //from w w w. ja va2  s  . c o  m
 * @param v
 *            View to test for horizontal scrollability
 * @param checkV
 *            Whether the view v passed should itself be checked for
 *            scrollability (true), or just its children (false).
 * @param dx
 *            Delta scrolled in pixels along the X axis
 * @param dy
 *            Delta scrolled in pixels along the Y axis
 * @param x
 *            X coordinate of the active touch point
 * @param y
 *            Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
}