List of usage examples for android.support.v4.view ViewCompat canScrollHorizontally
public static boolean canScrollHorizontally(View v, int direction)
From source file:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.java
/** * @param direction Negative to check scrolling left, positive to check scrolling right. * @return Whether it is possible for the child view of this layout to * scroll left or right. Override this if the child view is a custom view. *///from w ww . j a va2 s . c om private boolean canViewScrollHorizontally(View view, MotionEvent event, int direction) { boolean ret; event.offsetLocation(view.getScrollX() - view.getLeft(), view.getScrollY() - view.getTop()); if (mScrollLeftOrRightHandler != null) { boolean canViewScrollLeftOrRight = mScrollLeftOrRightHandler.canScrollLeftOrRight(view, direction); if (canViewScrollLeftOrRight) return true; } if (android.os.Build.VERSION.SDK_INT < 14) { if (view instanceof ViewPager) { ret = ((ViewPager) view).canScrollHorizontally(direction); } else { ret = view.getScrollX() * direction > 0; } } else { ret = ViewCompat.canScrollHorizontally(view, direction); } ret = ret || canChildrenScrollHorizontally(view, event, direction); if (DEBUG) Log.d(TAG, "canViewScrollHorizontally " + view.getClass().getName() + " " + ret); return ret; }
From source file:com.kayac.slidingmenu.ui.views.DraggableLayout.java
/** * Detect at a specific position of view, its child can scrollHoziontally or not * Also support Viewpager as its child//from w w w . j a va 2 s . co m * @param v view to check * @param checkV check it or not * @param dx Direction * @param x pos X * @param y pos Y * @return */ 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(); for (int i = count - 1; i >= 0; i--) { final View child = group.getChildAt(i); if (child.getVisibility() == View.VISIBLE && 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) || (v instanceof ViewPager))); }
From source file:uk.ac.kent.jb509.shopper.utils.SlidingUpPanelLayout.java
/** * Tests scrollability within child views of v given a delta of dx. * //from www . j a va 2 s.c om * @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 * @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(final View v, final boolean checkV, final int dx, final int x, final 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.netease.hearttouch.htrefreshrecyclerview.base.HTBaseRecyclerView.java
/** * ??,???//ww w . ja va 2 s. c om */ public boolean checkChildScroll() { switch (mHTOrientation) { case VERTICAL_UP: return ViewCompat.canScrollVertically(mRecyclerView, 1); case VERTICAL_DOWN: return ViewCompat.canScrollVertically(mRecyclerView, -1); case HTOrientation.HORIZONTAL_LEFT: return ViewCompat.canScrollHorizontally(mRecyclerView, 1); case HTOrientation.HORIZONTAL_RIGHT: return ViewCompat.canScrollHorizontally(mRecyclerView, -1); default: return false; } }
From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java
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; }//from ww w . j av a2 s. c om } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java
private boolean getCanScroll(View v, int dx) { if (this.orientation == LinearLayout.HORIZONTAL) { return ViewCompat.canScrollHorizontally(v, -dx); }/*from w w w . ja v a 2 s. co m*/ return ViewCompat.canScrollVertically(v, -dx); }
From source file:com.telerik.examples.primitives.ExampleViewPagerBase.java
private boolean getInvertedCanScroll(View v, int dx) { if (this.orientation == LinearLayout.VERTICAL) { return ViewCompat.canScrollHorizontally(v, -dx); }/*from www . ja v a 2s . c o m*/ return ViewCompat.canScrollVertically(v, -dx); }
From source file:com.aretha.slidemenu.SlideMenu.java
protected final boolean canScroll(View v, int dx, int x, int y) { if (null == mScrollDetector) { return false; }/*from www .ja v a2 s . c o m*/ 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() && (mScrollDetector.isScrollable(child, dx, x + scrollX - left, y + scrollY - top) || canScroll(child, dx, x + scrollX - left, y + scrollY - top))) { return true; } } } return ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.wunderlist.slidinglayer.SlidingLayer.java
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; }/*from w w w . j a v a 2 s .co m*/ } } return checkV && ((allowedDirection() == HORIZONTAL && ViewCompat.canScrollHorizontally(v, -dx) || allowedDirection() == VERTICAL && ViewCompat.canScrollVertically(v, -dy))); }
From source file:com.gdgl.util.SlideMenu.java
/** * Detect whether the views inside content are slidable *///from w w w . j a va 2 s . c o m protected final boolean canScroll(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) || canScroll(child, dx, x + scrollX - left, y + scrollY - top))) { return true; } } } return ViewCompat.canScrollHorizontally(v, -dx); }