List of usage examples for android.support.v4.view ViewCompat canScrollVertically
public static boolean canScrollVertically(View v, int direction)
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { boolean bCanScrollUp; if (android.os.Build.VERSION.SDK_INT < 14) { bCanScrollUp = view.getChildCount() > 0 && (view.getFirstVisiblePosition() > 0 || view.getChildAt(0).getTop() < view.getPaddingTop()); } else {/* w ww . j a v a 2 s .c o m*/ bCanScrollUp = ViewCompat.canScrollVertically(view, -1); } showToolbarElevation(bCanScrollUp); }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { boolean bCanScrollUp; if (android.os.Build.VERSION.SDK_INT < 14) { bCanScrollUp = view.getChildCount() > 0 && (view.getFirstVisiblePosition() > 0 || view.getChildAt(0).getTop() < view.getPaddingTop()); } else {/*from w w w . j a v a 2 s . c om*/ bCanScrollUp = ViewCompat.canScrollVertically(view, -1); } if (bCanScrollUp) { if (android.os.Build.VERSION.SDK_INT > 20) { messageCenterHeader.setElevation(8); } else { headerDivider.setVisibility(View.VISIBLE); } } else { if (android.os.Build.VERSION.SDK_INT > 20) { messageCenterHeader.setElevation(0); } else { headerDivider.setVisibility(View.GONE); } } }
From source file:com.example.mvpdemo.widget.NarrowParentViewPager.java
@Override public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) { Log.i(TAG, "onNestedPreScroll dx = " + dx + " dy = " + dy + " consumed = " + consumed[0] + "," + consumed[1]);//from w w w . ja v a 2 s .c om int scrollY = target.getScrollY(); Log.i(TAG, "scrollY = " + scrollY); if (Math.abs(dy) > Math.abs(dx)) { if (dy < 0 && !ViewCompat.canScrollVertically(target, -1)) { childScrollUp(mDragDistance + dy); } else if (dy > 0) { boolean b = childScrollUp(mDragDistance + dy); if (b) { consumed[1] = dy; } } } super.onNestedPreScroll(target, dx, dy, consumed); }
From source file:com.harry.refresh.SwipyRefreshLayout.java
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. *//* w w w. j a v a2 s . com*/ public boolean canChildScrollUp() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else { return mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
From source file:com.harry.refresh.SwipyRefreshLayout.java
public boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; try { if (absListView.getCount() > 0) { if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) { int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition(); return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom(); }//from w w w . j a v a2 s .c om } } catch (Exception e) { e.printStackTrace(); } return true; } else { return true; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }
From source file:administrator.example.com.myscrollview.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dy. * * @param v View to test for vertical scrollability * @param checkV Whether the view v passed should itself be checked for scrollability (true), * or just its children (false). * @param dy Delta scrolled in pixels//from ww w . j ava 2s.com * @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 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, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } /* end of if */ } /* end of for */ } /* end of if */ return checkV && ViewCompat.canScrollVertically(v, -dy); }
From source file:com.example.view.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dy. * //from www.j a v a 2s. com * @param v * View to test for vertical scrollability * @param checkV * Whether the view v passed should itself be checked for * scrollability (true), or just its children (false). * @param dy * 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 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, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } /* end of if */ } /* end of for */ } /* end of if */ return checkV && ViewCompat.canScrollVertically(v, -dy); }
From source file:javalibrary.android.ui.VerticalViewPager.java
protected boolean canScrolls(View v, boolean checkV, 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() && canScrolls(child, true, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; }//from www .jav a 2 s .c o m } } return checkV && ViewCompat.canScrollVertically(v, -dy); // return checkV && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.gome.ecmall.custom.VerticalViewPager.java
/** * Tests scrollability within child views of v given a delta of dx. * //from w w w .j ava2 s. com * @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(View v, boolean checkV, 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, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollVertically(v, -dy); }
From source file:com.jstudio.widget.pager.VerticalViewPager.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 dy Delta scrolled in pixels//w w w . j a va 2s . 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 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, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; } } } return checkV && ViewCompat.canScrollVertically(v, -dy); }