List of usage examples for android.support.v4.view ViewCompat canScrollVertically
public static boolean canScrollVertically(View v, int direction)
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(); }// w ww .ja v a2 s . c o m } } catch (Exception e) { e.printStackTrace(); } return true; } else { return true; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Whether child view can scroll up/*w w w .ja va2 s .co m*/ * @return */ public boolean canChildScrollUp() { if (mTargetView == null) { return false; } if (Build.VERSION.SDK_INT < 14) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, -1); } }
From source file:com.canyinghao.canrefresh.CanRefreshLayout.java
/** * ?/*from w w w. j a v a2 s. c om*/ * * @return */ protected boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mContentView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mContentView; return absListView.getChildCount() > 0 && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView .getPaddingBottom()); } else { return ViewCompat.canScrollVertically(mContentView, 1) || mContentView.getScrollY() < 0; } } else { return ViewCompat.canScrollVertically(mContentView, 1); } }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Whether child view can scroll down//w ww. j a va 2 s .com * @return */ public boolean canChildScrollDown() { if (mTargetView == null) { return false; } if (Build.VERSION.SDK_INT < 14) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; if (absListView.getChildCount() > 0) { int lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1).getBottom(); return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1 && lastChildBottom <= absListView.getMeasuredHeight(); } else { return false; } } else { return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, 1); } }
From source file:org.alex.refreshlayout.RefreshLayout.java
/** * SwipeRefreshLayout ????/*from w w w. jav a2 s . co m*/ * RecyclerView.canScrollVertically(-1); //true??false? * * @return true ? ? */ public boolean canChildScrollUp() { if (childScrollUpCallback != null) { return childScrollUpCallback.canChildScrollUp(this, targetView); } if (android.os.Build.VERSION.SDK_INT < 14) { if (targetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) targetView; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(targetView, -1) || targetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(targetView, -1); } }
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 ww w. j av a 2 s .c o m*/ } } return checkV && ((allowedDirection() == HORIZONTAL && ViewCompat.canScrollHorizontally(v, -dx) || allowedDirection() == VERTICAL && ViewCompat.canScrollVertically(v, -dy))); }
From source file:com.gu.swiperefresh.SwipeRefreshPlush.java
/** * targrt view ??/* w w w . j a va2s .com*/ * * @return target view ?? */ private 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 ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0; } } else { return mTarget.canScrollVertically(-1); } }
From source file:org.alex.refreshlayout.RefreshLayout.java
/** * SwipeRefreshLayout ?? ?//w w w. j a va2 s . com * RecyclerView.canScrollVertically(1); //true??false? */ public boolean canChildScrollDown() { if (childScrollDownCallback != null) { return childScrollDownCallback.canChildScrollDown(this, targetView); } if (android.os.Build.VERSION.SDK_INT < 14) { if (targetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) targetView; if (absListView.getChildCount() > 0) { int lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1).getBottom(); return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1 && lastChildBottom <= absListView.getMeasuredHeight(); } else { return false; } } else { return ViewCompat.canScrollVertically(targetView, 1) || targetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(targetView, 1); } }
From source file:com.gu.swiperefresh.SwipeRefreshPlush.java
/** * target view ??/*www . j av a 2s. c o m*/ * * @return */ private boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; int count = absListView.getChildCount(); //return absListView.canScrollList(-1); int position = absListView.getLastVisiblePosition(); return (count > position + 1) || absListView.getChildAt(position).getBottom() <= absListView.getPaddingBottom(); } else { return ViewCompat.canScrollVertically(mTarget, 1); } } else { return mTarget.canScrollVertically(1); } }
From source file:com.usabusi.swiperefreshlayoutupdown.view.SwipeRefreshLayoutUpDown.java
public boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; View lastChild = absListView.getChildAt(absListView.getChildCount() - 1); if (lastChild != null) { return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1)) && lastChild.getBottom() > absListView.getPaddingBottom(); } else { return false; }/*from w w w . j ava 2 s. c om*/ } else { //return mTarget.getHeight() - mTarget.getScrollY() > 0; return mTarget.getScrollY() < 0; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }