List of usage examples for android.support.v4.view ViewCompat canScrollVertically
public static boolean canScrollVertically(View v, int direction)
From source file:xyz.openhh.compat.widget.CompatSwipeRefreshLayout.java
/** * ? * * @return */ private boolean canChildScrollUp() { return ViewCompat.canScrollVertically(mTargetView, -1); }
From source file:xyz.openhh.compat.widget.CompatSwipeRefreshLayout.java
/** * ? * * @return */ private boolean canChildScrollDown() { return ViewCompat.canScrollVertically(mTargetView, 1); }
From source file:android.support.design.widget.BottomSheetBehavior.java
@Override public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) { View scrollingChild = mNestedScrollingChildRef.get(); if (target != scrollingChild) { return;/*from ww w .j a v a 2 s . c o m*/ } int currentTop = child.getTop(); int newTop = currentTop - dy; if (dy > 0) { // Upward if (newTop < mMinOffset) { consumed[1] = currentTop - mMinOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_EXPANDED); } else { consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } } else if (dy < 0) { // Downward if (!ViewCompat.canScrollVertically(target, -1)) { if (newTop <= mMaxOffset || mHideable) { consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } else { consumed[1] = currentTop - mMaxOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_COLLAPSED); } } } dispatchOnSlide(child.getTop()); mLastNestedScrollDy = dy; mNestedScrolled = true; }
From source file:com.kuloud.android.unity.ui.widget.steprefresh.PullToRefreshView.java
private boolean canChildScrollUp() { return ViewCompat.canScrollVertically(mTarget, -1); }
From source file:com.linsq.androiddemo.refresh2.SwipeRefreshLayout.java
public boolean canChildScrollUp() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; Logger.e("absListView.getChildAt(0).getTop()=" + absListView.getChildAt(0).getTop()); return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else {//from w w w . j ava 2 s.co m return mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
From source file:com.hayukleung.app.view.refresh.SwipeRefreshLayout.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 .jav a 2 s .co m*/ 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 if (mTarget instanceof RecyclerView) { final RecyclerView recyclerView = (RecyclerView) mTarget; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager) { int position = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition(); return position != 0; } else if (layoutManager instanceof StaggeredGridLayoutManager) { int[] positions = ((StaggeredGridLayoutManager) layoutManager) .findFirstCompletelyVisibleItemPositions(null); for (int i = 0; i < positions.length; i++) { if (positions[i] == 0) { return false; } } } return true; } else { return mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
From source file:org.mozilla.gecko.widget.GeckoSwipeRefreshLayout.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. *//*from w w w .jav a2 s. co m*/ public boolean canChildScrollUp() { if (Versions.preICS) { 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.klinker.android.launcher.info_page.widgets.swipe_refresh_layout.OffsetSwipeRefreshLayout.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 va 2s .c om*/ public boolean canChildScrollUp() { if (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.google.samples.apps.iosched.myschedule.MyScheduleActivity.java
@Override public boolean canSwipeRefreshChildScrollUp() { if (mWideMode) { return ViewCompat.canScrollVertically(mScrollViewWide, -1); }//from www . j a v a2 s .c om // Prevent the swipe refresh by returning true here if (mViewPagerScrollState == ViewPager.SCROLL_STATE_DRAGGING) { return true; } for (MyScheduleFragment fragment : mMyScheduleFragments) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { if (!fragment.getUserVisibleHint()) { continue; } } return ViewCompat.canScrollVertically(fragment.getListView(), -1); } return false; }
From source file:com.matcontrol.control.BottomSheetBehavior_v25.java
@Override public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) { if (!isOneOfChild(target)) { return;//from w w w . ja v a2 s. c o m } // View scrollingChild = mNestedScrollingChildRef.get(); // if (target != scrollingChild) { // return; // } int currentTop = child.getTop(); int newTop = currentTop - dy; if (dy > 0) { // Upward if (newTop < mMinOffset) { consumed[1] = currentTop - mMinOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_EXPANDED); } else { consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } } else if (dy < 0) { // Downward if (!ViewCompat.canScrollVertically(target, -1)) { if (newTop <= mMaxOffset || mHideable) { consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } else { consumed[1] = currentTop - mMaxOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_COLLAPSED); } } } dispatchOnSlide(child.getTop()); mLastNestedScrollDy = dy; mNestedScrolled = true; }