Java Code Examples for androidx.core.view.ViewCompat#TYPE_NON_TOUCH
The following examples show how to use
androidx.core.view.ViewCompat#TYPE_NON_TOUCH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppBarLayout.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public void onStopNestedScroll( CoordinatorLayout coordinatorLayout, @NonNull T abl, View target, int type) { // onStartNestedScroll for a fling will happen before onStopNestedScroll for the scroll. This // isn't necessarily guaranteed yet, but it should be in the future. We use this to our // advantage to check if a fling (ViewCompat.TYPE_NON_TOUCH) will start after the touch scroll // (ViewCompat.TYPE_TOUCH) ends if (lastStartedType == ViewCompat.TYPE_TOUCH || type == ViewCompat.TYPE_NON_TOUCH) { // If we haven't been flung, or a fling is ending snapToChildIfNeeded(coordinatorLayout, abl); if (abl.isLiftOnScroll()) { abl.setLiftedState(abl.shouldLift(target)); } } // Keep a reference to the previous nested scrolling child lastNestedScrollingChildRef = new WeakReference<>(target); }
Example 2
Source File: SmoothRefreshLayout.java From SmoothRefreshLayout with MIT License | 5 votes |
@Override public boolean onStartNestedScroll( @NonNull View child, @NonNull View target, int axes, int type) { if (sDebug) { Log.d(TAG, String.format("onStartNestedScroll(): axes: %d, type: %d", axes, type)); } return isEnabled() && isNestedScrollingEnabled() && mTargetView != null && (axes & getNestedScrollAxes()) != 0 && !(type == ViewCompat.TYPE_NON_TOUCH && !isEnabledOverScroll()); }
Example 3
Source File: BottomSheetBehavior.java From bottomsheetrecycler with Apache License 2.0 | 4 votes |
@Override public void onNestedPreScroll( @NonNull CoordinatorLayout coordinatorLayout, @NonNull V child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) { if (type == ViewCompat.TYPE_NON_TOUCH) { // Ignore fling here. The ViewDragHelper handles it. return; } //View scrollingChild = nestedScrollingChildRef != null ? nestedScrollingChildRef.get() : null; if (!isOneOfChild(target)) { return; } int currentTop = child.getTop(); int newTop = currentTop - dy; if (dy > 0) { // Upward if (newTop < getExpandedOffset()) { consumed[1] = currentTop - getExpandedOffset(); 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 (!target.canScrollVertically(-1)) { if (newTop <= collapsedOffset || hideable) { consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } else { consumed[1] = currentTop - collapsedOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_COLLAPSED); } } } dispatchOnSlide(child.getTop()); lastNestedScrollDy = dy; nestedScrolled = true; }
Example 4
Source File: SmoothRefreshLayout.java From SmoothRefreshLayout with MIT License | 4 votes |
@Override public void onNestedPreScroll( @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) { final boolean isVerticalOrientation = isVerticalOrientation(); if (type == ViewCompat.TYPE_TOUCH) { if (tryToFilterTouchEvent(null)) { if (isVerticalOrientation) { consumed[1] = dy; } else { consumed[0] = dx; } } else { mScrollChecker.stop(); final int distance = isVerticalOrientation ? dy : dx; if (distance > 0 && !isDisabledRefresh() && !(isEnabledPinRefreshViewWhileLoading() && isRefreshing()) && !isNotYetInEdgeCannotMoveHeader()) { if (!mIndicator.isAlreadyHere(IIndicator.START_POS) && isMovingHeader()) { mIndicatorSetter.onFingerMove( mIndicator.getLastMovePoint()[0] - dx, mIndicator.getLastMovePoint()[1] - dy); moveHeaderPos(mIndicator.getOffset()); if (isVerticalOrientation) { consumed[1] = dy; } else { consumed[0] = dx; } } else { if (isVerticalOrientation) { mIndicatorSetter.onFingerMove( mIndicator.getLastMovePoint()[0] - dx, mIndicator.getLastMovePoint()[1]); } else { mIndicatorSetter.onFingerMove( mIndicator.getLastMovePoint()[0], mIndicator.getLastMovePoint()[1] - dy); } } } else if (distance < 0 && !isDisabledLoadMore() && !(isEnabledPinRefreshViewWhileLoading() && isLoadingMore()) && !isNotYetInEdgeCannotMoveFooter()) { if (!mIndicator.isAlreadyHere(IIndicator.START_POS) && isMovingFooter()) { mIndicatorSetter.onFingerMove( mIndicator.getLastMovePoint()[0] - dx, mIndicator.getLastMovePoint()[1] - dy); moveFooterPos(mIndicator.getOffset()); if (isVerticalOrientation) { consumed[1] = dy; } else { consumed[0] = dx; } } else { if (isVerticalOrientation) { mIndicatorSetter.onFingerMove( mIndicator.getLastMovePoint()[0] - dx, mIndicator.getLastMovePoint()[1]); } else { mIndicatorSetter.onFingerMove( mIndicator.getLastMovePoint()[0], mIndicator.getLastMovePoint()[1] - dy); } } } } tryToResetMovingStatus(); } // Now let our nested parent consume the leftovers final int[] parentConsumed = mParentScrollConsumed; parentConsumed[0] = 0; parentConsumed[1] = 0; if (dispatchNestedPreScroll( dx - consumed[0], dy - consumed[1], parentConsumed, null, type)) { consumed[0] += parentConsumed[0]; consumed[1] += parentConsumed[1]; } else if (type == ViewCompat.TYPE_NON_TOUCH) { if (!isMovingContent() && !isEnabledPinContentView()) { if (isVerticalOrientation) { parentConsumed[1] = dy; } else { parentConsumed[0] = dx; } consumed[0] += parentConsumed[0]; consumed[1] += parentConsumed[1]; } } if (sDebug) { Log.d( TAG, String.format( "onNestedPreScroll(): dx: %d, dy: %d, consumed: %s, type: %d", dx, dy, Arrays.toString(consumed), type)); } }
Example 5
Source File: BottomSheetBehavior.java From material-components-android with Apache License 2.0 | 4 votes |
@Override public void onNestedPreScroll( @NonNull CoordinatorLayout coordinatorLayout, @NonNull V child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) { if (type == ViewCompat.TYPE_NON_TOUCH) { // Ignore fling here. The ViewDragHelper handles it. return; } View scrollingChild = nestedScrollingChildRef != null ? nestedScrollingChildRef.get() : null; if (target != scrollingChild) { return; } int currentTop = child.getTop(); int newTop = currentTop - dy; if (dy > 0) { // Upward if (newTop < getExpandedOffset()) { consumed[1] = currentTop - getExpandedOffset(); ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_EXPANDED); } else { if (!draggable) { // Prevent dragging return; } consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } } else if (dy < 0) { // Downward if (!target.canScrollVertically(-1)) { if (newTop <= collapsedOffset || hideable) { if (!draggable) { // Prevent dragging return; } consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } else { consumed[1] = currentTop - collapsedOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_COLLAPSED); } } } dispatchOnSlide(child.getTop()); lastNestedScrollDy = dy; nestedScrolled = true; }
Example 6
Source File: BottomSheetBehavior.java From Mysplash with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onNestedPreScroll( @NonNull CoordinatorLayout coordinatorLayout, @NonNull V child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) { if (type == ViewCompat.TYPE_NON_TOUCH) { // Ignore fling here. The ViewDragHelper handles it. return; } View scrollingChild = nestedScrollingChildRef != null ? nestedScrollingChildRef.get() : null; if (target != scrollingChild) { return; } int currentTop = child.getTop(); int newTop = currentTop - dy; if (dy > 0) { // Upward if (newTop < getExpandedOffset()) { consumed[1] = currentTop - getExpandedOffset(); ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_EXPANDED); } else { if (!draggable) { // Prevent dragging return; } consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } } else if (dy < 0) { // Downward if (!target.canScrollVertically(-1)) { if (newTop <= collapsedOffset || hideable) { if (!draggable) { // Prevent dragging return; } consumed[1] = dy; ViewCompat.offsetTopAndBottom(child, -dy); setStateInternal(STATE_DRAGGING); } else { consumed[1] = currentTop - collapsedOffset; ViewCompat.offsetTopAndBottom(child, -consumed[1]); setStateInternal(STATE_COLLAPSED); } } } dispatchOnSlide(child.getTop()); lastNestedScrollDy = dy; nestedScrolled = true; }