@Override public int clampViewPositionVertical(View child, int top, int dy) { return MathUtils.clamp(top, mMinOffset, mHideable ? mParentHeight : mMaxOffset); }
@Override public int clampViewPositionVertical(View child, int top, int dy) { return MathUtils.clamp(top, mMinOffset, mHideable ? mParentHeight : mMaxOffset); }
/** * Set the value indicating the current scroll value. This decides how much of the * background will be displayed, as well as the title metrics/positioning. * * A value of {@code 0.0} indicates that the layout is fully expanded. * A value of {@code 1.0} indicates that the layout is fully collapsed. */ void setExpansionFraction(float fraction) { fraction = MathUtils.clamp(fraction, 0f, 1f); if (fraction != mExpandedFraction) { mExpandedFraction = fraction; calculateCurrentOffsets(); } }
int calendarOffset = MathUtils.clamp( getTopAndBottomOffset() - dy, calendarMinOffset, 0); setTopAndBottomOffset(calendarOffset); if (behavior instanceof CalendarScrollBehavior) { final CalendarScrollBehavior listBehavior = (CalendarScrollBehavior) behavior; int listOffset = MathUtils.clamp( listBehavior.getTopAndBottomOffset() - dy, -listMaxOffset, 0); listBehavior.setTopAndBottomOffset(listOffset);
@Override public void run() { float translation = (isVertical() ? mRecyclerView.getTranslationY() : mRecyclerView.getTranslationX()); float fraction = MathUtils.clamp(Math.abs((translation / getDragThreshold())), 0f, 1f); int scroll = (int) (0f - translation * Math.pow(fraction, SCROLL_EXPONENT)); if (Math.abs(scroll) > 0 && (isVertical() && mRecyclerView.canScrollVertically(scroll) || !isVertical() && mRecyclerView.canScrollHorizontally(scroll))) { if (mScrollCallbacks != null) mScrollCallbacks.onScrolled((translation > 0 ? 1f : -1) * fraction); mRecyclerView.scrollBy(isVertical() ? 0 : scroll, isVertical() ? scroll : 0); } mRecyclerView.post(mScrollByRunnable); } };
offsetHelper.setTopAndBottomOffset(MathUtils.clamp( -verticalOffset, 0, getMaxOffsetForPinChild(child))); break;