List of usage examples for android.support.v4.view ViewCompat canScrollVertically
public static boolean canScrollVertically(View v, int direction)
From source file:com.lanma.customviewproject.utils.ScrollingUtil.java
/** * RecyclerView?//from ww w . j a v a 2s . c o m */ public static boolean isRecyclerViewToBottom(RecyclerView recyclerView) { if (recyclerView != null) { RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager == null || manager.getItemCount() == 0) { return false; } if (manager instanceof LinearLayoutManager) { // ?item? View lastVisibleChild = recyclerView.getChildAt(recyclerView.getChildCount() - 1); if (lastVisibleChild != null && lastVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) { if (Build.VERSION.SDK_INT < 14) { return !(ViewCompat.canScrollVertically(recyclerView, 1) || recyclerView.getScrollY() < 0); } else { return !ViewCompat.canScrollVertically(recyclerView, 1); } } LinearLayoutManager layoutManager = (LinearLayoutManager) manager; if (layoutManager.findLastCompletelyVisibleItemPosition() == layoutManager.getItemCount() - 1) { return true; } } else if (manager instanceof StaggeredGridLayoutManager) { StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager; int[] out = layoutManager.findLastCompletelyVisibleItemPositions(null); int lastPosition = layoutManager.getItemCount() - 1; for (int position : out) { if (position == lastPosition) { return true; } } } } return false; }
From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java
public boolean canChildScrollUp() { return ViewCompat.canScrollVertically(scrollChild, -1); }
From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java
public boolean canChildScrollDown() { return ViewCompat.canScrollVertically(scrollChild, 1); }
From source file:xyz.hanks.nestedwebview.SSScrollView.java
@Override public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow) { Log.e("......", "........." + ViewCompat.canScrollVertically(getChildAt(0), -1)); Log.e("......", ".........webview" + ViewCompat.canScrollVertically(((ViewGroup) getChildAt(0)).getChildAt(0), -1)); return mChildHelper.dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, offsetInWindow);// www . ja va 2 s . co m }
From source file:com.ouyangzn.view.DragLayout.java
private boolean isVerticalScrollView(View view) { if (view instanceof RecyclerView) { RecyclerView recyclerView = (RecyclerView) view; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager) { LinearLayoutManager manager = (LinearLayoutManager) layoutManager; if (manager.getOrientation() == LinearLayoutManager.VERTICAL) { return true; }//from ww w . j av a 2s . co m } } return view instanceof ScrollView || ViewCompat.canScrollVertically(view, -1) || ViewCompat.canScrollVertically(view, 1); }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java
ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, View fromView) { // Bookkeeping this.id = id; this.parentId = (parent != null) ? parent.getId() : null; // API 16+ properties this.scrollable = AT_16 ? fromView.isScrollContainer() : null; // API 11+ properties this.backgroundDrawableColor = (AT_11 && (fromView != null) && (fromView.getBackground() instanceof ColorDrawable)) ? ((ColorDrawable) fromView.getBackground()).getColor() : null;// w w w.j av a 2s. c o m // Base properties this.visibleToUser = ViewAccessibilityUtils.isVisibleToUser(fromView); this.className = fromView.getClass().getName(); this.accessibilityClassName = null; this.packageName = fromView.getContext().getPackageName(); this.resourceName = (fromView.getId() != View.NO_ID) ? ViewAccessibilityUtils.getResourceNameForView(fromView) : null; this.contentDescription = SpannableString.valueOf(fromView.getContentDescription()); this.enabled = fromView.isEnabled(); if (fromView instanceof TextView) { TextView textView = (TextView) fromView; // Hint text takes precedence if no text is present. CharSequence text = textView.getText(); if (TextUtils.isEmpty(text)) { text = textView.getHint(); } this.text = SpannableString.valueOf(text); this.textSize = textView.getTextSize(); this.textColor = textView.getCurrentTextColor(); this.typefaceStyle = (textView.getTypeface() != null) ? textView.getTypeface().getStyle() : null; } else { this.text = null; this.textSize = null; this.textColor = null; this.typefaceStyle = null; } this.importantForAccessibility = ViewAccessibilityUtils.isImportantForAccessibility(fromView); this.clickable = fromView.isClickable(); this.longClickable = fromView.isLongClickable(); this.focusable = fromView.isFocusable(); this.editable = ViewAccessibilityUtils.isViewEditable(fromView); this.canScrollForward = (ViewCompat.canScrollVertically(fromView, 1) || ViewCompat.canScrollHorizontally(fromView, 1)); this.canScrollBackward = (ViewCompat.canScrollVertically(fromView, -1) || ViewCompat.canScrollHorizontally(fromView, -1)); this.checkable = (fromView instanceof Checkable); this.checked = (fromView instanceof Checkable) ? ((Checkable) fromView).isChecked() : null; this.hasTouchDelegate = (fromView.getTouchDelegate() != null); // There may be subtle differences between the bounds from a View instance compared to that of // its AccessibilityNodeInfo. The latter uses a @hide getBoundsOnScreen method, which clips to // parent bounds. android.graphics.Rect tempRect = new android.graphics.Rect(); if (fromView.getGlobalVisibleRect(tempRect)) { this.boundsInScreen = new Rect(tempRect); } else { this.boundsInScreen = null; } this.nonclippedHeight = fromView.getHeight(); this.nonclippedWidth = fromView.getWidth(); }
From source file:com.google.android.apps.santatracker.map.BottomSheetBehavior.java
@Override public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) { int currentTop = child.getTop(); int newTop = currentTop - dy; if (dy > 0) { // Upward if (newTop < mMinOffset) { consumed[1] = currentTop - mMinOffset; child.offsetTopAndBottom(-consumed[1]); if (NEEDS_INVALIDATING && mState != STATE_EXPANDED) { child.invalidate();//w ww. jav a 2s . c om } setStateInternal(STATE_EXPANDED); } else { consumed[1] = dy; child.offsetTopAndBottom(-dy); setStateInternal(STATE_DRAGGING); if (NEEDS_INVALIDATING) { child.invalidate(); } } } else if (dy < 0) { // Downward if (!ViewCompat.canScrollVertically(target, -1)) { if (newTop <= mMaxOffset) { consumed[1] = dy; child.offsetTopAndBottom(-dy); setStateInternal(STATE_DRAGGING); if (NEEDS_INVALIDATING) { coordinatorLayout.invalidate(child.getLeft(), currentTop, child.getRight(), coordinatorLayout.getHeight()); } } else if (mHideable) { if (newTop <= mParentHeight - mHiddenPeekHeight) { consumed[1] = dy; child.offsetTopAndBottom(-dy); setStateInternal(STATE_DRAGGING); } else { consumed[1] = currentTop - (mParentHeight - mHiddenPeekHeight); child.offsetTopAndBottom(-consumed[1]); setStateInternal(STATE_HIDDEN); } if (NEEDS_INVALIDATING) { coordinatorLayout.invalidate(child.getLeft(), currentTop, child.getRight(), coordinatorLayout.getHeight()); } } else { consumed[1] = currentTop - mMaxOffset; child.offsetTopAndBottom(-consumed[1]); setStateInternal(STATE_COLLAPSED); } } } dispatchOnSlide(child.getTop()); mLastNestedScrollDy = dy; }
From source file:ca.zadrox.dota2esportticker.ui.MatchActivity.java
/** * This method overrides the default behaviour of the swipe refresh layout, letting the * list in the listfragment scroll first *//*w w w . j a va2 s . c om*/ @Override public boolean canSwipeRefreshChildScrollUp() { for (MatchListFragment fragment : mMatchListFragments) { 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:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.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 .j a v a2s . com private boolean canViewScrollUp(View view, MotionEvent event) { boolean ret; event.offsetLocation(view.getScrollX() - view.getLeft(), view.getScrollY() - view.getTop()); if (mScrollUpHandler != null) { boolean canViewScrollUp = mScrollUpHandler.canScrollUp(view); if (canViewScrollUp) return true; } if (android.os.Build.VERSION.SDK_INT < 14) { if (view instanceof AbsListView) { final AbsListView absListView = (AbsListView) view; ret = absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else { ret = view.getScrollY() > 0 || canChildrenScrollUp(view, event); } } else { ret = ViewCompat.canScrollVertically(view, -1) || canChildrenScrollUp(view, event); } if (DEBUG) Log.d(TAG, "canViewScrollUp " + view.getClass().getName() + " " + ret); return ret; }
From source file:pl.edu.agh.schedule.myschedule.MyScheduleActivity.java
@Override public boolean canSwipeRefreshChildScrollUp() { for (MyScheduleFragment fragment : mMyScheduleFragments) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { if (!fragment.getUserVisibleHint()) { continue; }/*from w w w . j ava2s .c o m*/ } return ViewCompat.canScrollVertically(fragment.getListView(), -1); } return false; }