androidx.recyclerview.widget.RecyclerView#getHeight ( )源码实例Demo

下面列出了androidx.recyclerview.widget.RecyclerView#getHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
protected Rect getDividerBound(int position, RecyclerView parent, View child) {
    Rect bounds = new Rect(0, 0, 0, 0);
    int transitionX = (int) ViewCompat.getTranslationX(child);
    int transitionY = (int) ViewCompat.getTranslationY(child);
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
    bounds.top = parent.getPaddingTop() +
            mMarginProvider.dividerTopMargin(position, parent) + transitionY;
    bounds.bottom = parent.getHeight() - parent.getPaddingBottom() -
            mMarginProvider.dividerBottomMargin(position, parent) + transitionY;

    int dividerSize = getDividerSize(position, parent);
    if (mDividerType == DividerType.DRAWABLE) {
        bounds.left = child.getRight() + params.leftMargin + transitionX;
        bounds.right = bounds.left + dividerSize;
    } else {
        bounds.left = child.getRight() + params.leftMargin + dividerSize / 2 + transitionX;
        bounds.right = bounds.left;
    }

    return bounds;
}
 
@Override
public void onLayoutFinished(View child, RecyclerView parent) {

    // Figure out % progress from top to bottom.
    float centerOffset = ((float) child.getHeight() / 2.0f) /  (float) parent.getHeight();
    float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;

    // Normalizes for center.
    mProgressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);

    // Adjusts to the maximum scale.
    mProgressToCenter = Math.min(mProgressToCenter, MAX_CHILD_SCALE);

    child.setScaleX(1 - mProgressToCenter);
    child.setScaleY(1 - mProgressToCenter);
}
 
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    canvas.save();
    int top;
    int bottom;
    if (parent.getClipToPadding()) {
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
        canvas.clipRect(parent.getPaddingLeft(), top, parent.getWidth() - parent.getPaddingRight(), bottom);
    } else {
        top = 0;
        bottom = parent.getHeight();
    }

    int childCount = parent.getChildCount();

    for (int i = 0; i < childCount; ++i) {
        View child = parent.getChildAt(i);
        parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
        int right = mBounds.right + Math.round(child.getTranslationX());
        int left = right - mDivider.getIntrinsicWidth();
        this.mDivider.setBounds(left, top, right, bottom);
        this.mDivider.draw(canvas);
    }

    canvas.restore();
}
 
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    canvas.save();
    final int top;
    final int bottom;
    if (parent.getClipToPadding()) {
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
        canvas.clipRect(parent.getPaddingLeft(), top,
                parent.getWidth() - parent.getPaddingRight(), bottom);
    } else {
        top = 0;
        bottom = parent.getHeight();
    }

    final int childCount = parent.getChildCount() - (doNotDrawForLastItem ? 1 : 0);
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
        final int right = mBounds.right + Math.round(child.getTranslationX());
        final int left = right - mDivider.getIntrinsicWidth();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
public void drawHorizontal(Canvas canvas, RecyclerView parent) {
    int top = parent.getPaddingTop();
    int bottom = parent.getHeight() - parent.getPaddingBottom();

    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        if (!hasDivider(parent, child)) {
            continue;
        }

        if (mDrawable.isStateful()) {
            mDrawable.setState(child.getDrawableState());
        }

        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int left = child.getRight() + params.rightMargin + Math.round(child.getTranslationX());
        int right = left + mDrawable.getIntrinsicWidth();
        drawDivider(canvas, left, top, right, bottom, child.getAlpha());
    }
}
 
@SuppressLint("NewApi")
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    canvas.save();
    final int top;
    final int bottom;
    if (parent.getClipToPadding()) {
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
        canvas.clipRect(parent.getPaddingLeft(), top,
                parent.getWidth() - parent.getPaddingRight(), bottom);
    } else {
        top = 0;
        bottom = parent.getHeight();
    }

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
        final int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child));
        final int left = right - mDivider.getIntrinsicWidth();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(canvas);
    }
    canvas.restore();
}
 
源代码7 项目: libcommon   文件: DividerItemDecoration.java
protected void drawHorizontal(final Canvas canvas, final RecyclerView parent) {
	final RecyclerView.LayoutManager manager = parent.getLayoutManager();

	final int top = parent.getPaddingTop();
	final int bottom = parent.getHeight() - parent.getPaddingBottom();

	final int childCount = parent.getChildCount() - 1;
	for (int i = 0; i < childCount; i++) {
		final View child = parent.getChildAt(i);
		if (hasDivider(child)) {
			final int left = child.getLeft();
			final int right = left + mDivider.getIntrinsicWidth();
			mDivider.setBounds(left, top, right, bottom);
			mDivider.draw(canvas);
		}
	}
}
 
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + divider.getIntrinsicHeight();
        divider.setBounds(left, top, right, bottom);
        divider.draw(c);
    }
}
 
源代码9 项目: a   文件: DividerItemDecoration.java
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDrawable.getIntrinsicHeight();
        mDrawable.setBounds(left, top, right, bottom);
        mDrawable.draw(c);
    }
}
 
源代码10 项目: monero-wallet-android-app   文件: WeSwipeHelper.java
/**
 * Called when {@link #onMove(RecyclerView, RecyclerView.ViewHolder, RecyclerView.ViewHolder)} returns true.
 * <p>
 * WeSwipeHelper does not create an extra Bitmap or View while dragging, instead, it
 * modifies the existing View. Because of this reason, it is important that the View is
 * still part of the layout after it is moved. This may not work as intended when swapped
 * Views are close to RecyclerView bounds or there are gaps between them (e.g. other Views
 * which were not eligible for dropping over).
 * <p>
 * This method is responsible to give necessary hint to the LayoutManager so that it will
 * keep the View in visible area. For example, for LinearLayoutManager, this is as simple
 * as calling {@link LinearLayoutManager#scrollToPositionWithOffset(int, int)}.
 * <p>
 * Default implementation calls {@link RecyclerView#scrollToPosition(int)} if the View's
 * new position is likely to be out of bounds.
 * <p>
 * It is important to ensure the ViewHolder will stay visible as otherwise, it might be
 * removed by the LayoutManager if the move causes the View to go out of bounds. In that
 * case, drag will end prematurely.
 *
 * @param recyclerView The RecyclerView controlled by the WeSwipeHelper.
 * @param viewHolder   The ViewHolder under user's control.
 * @param fromPos      The previous adapter position of the dragged item (before it was
 *                     moved).
 * @param target       The ViewHolder on which the currently active item has been dropped.
 * @param toPos        The new adapter position of the dragged item.
 * @param x            The updated left value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by
 *                     {@link RecyclerView.ItemDecoration}s.
 * @param y            The updated top value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by
 *                     {@link RecyclerView.ItemDecoration}s.
 */
public void onMoved(final RecyclerView recyclerView,
                    final RecyclerView.ViewHolder viewHolder, int fromPos, final RecyclerView.ViewHolder target, int toPos, int x,
                    int y) {
    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof WeSwipeHelper.ViewDropHandler) {
        ((WeSwipeHelper.ViewDropHandler) layoutManager).prepareForDrop(viewHolder.itemView,
                target.itemView, x, y);
        return;
    }

    // if layout manager cannot handle it, do some guesswork
    if (layoutManager.canScrollHorizontally()) {
        final int minLeft = layoutManager.getDecoratedLeft(target.itemView);
        if (minLeft <= recyclerView.getPaddingLeft()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxRight = layoutManager.getDecoratedRight(target.itemView);
        if (maxRight >= recyclerView.getWidth() - recyclerView.getPaddingRight()) {
            recyclerView.scrollToPosition(toPos);
        }
    }

    if (layoutManager.canScrollVertically()) {
        final int minTop = layoutManager.getDecoratedTop(target.itemView);
        if (minTop <= recyclerView.getPaddingTop()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxBottom = layoutManager.getDecoratedBottom(target.itemView);
        if (maxBottom >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
}
 
源代码11 项目: Jockey   文件: InsetDecoration.java
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int top = 0;
    int left = 0;
    int right = parent.getWidth();
    int bottom = parent.getHeight();

    if (mGravity == Gravity.TOP) {
        mInset.setBounds(left, top, right, mHeight);
    } else if (mGravity == Gravity.BOTTOM) {
        mInset.setBounds(left, bottom - mHeight, right, bottom);
    }

    mInset.draw(c);
}
 
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码13 项目: android-test   文件: DividerItemDecoration.java
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码14 项目: sa-sdk-android   文件: HorizonRecyclerDivider.java
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码15 项目: litho   文件: RecyclerCollectionEventsController.java
private int getSmoothScrollTarget(boolean forward, int defaultTarget) {
  switch (mSnapMode) {
    case SNAP_NONE:
      return defaultTarget;
    case SNAP_TO_START:
      return Math.max(
          0,
          forward
              ? mFirstCompletelyVisibleItemPosition + 1
              : mFirstCompletelyVisibleItemPosition - 1);
    case SNAP_TO_END: // SNAP_TO_END not yet implemented
      return Math.max(
          0,
          forward
              ? mLastCompletelyVisibleItemPosition + 1
              : mLastCompletelyVisibleItemPosition - 1);
    case SNAP_TO_CENTER:
    case SNAP_TO_CENTER_CHILD:
      final RecyclerView recyclerView = getRecyclerView();
      if (recyclerView == null) {
        return defaultTarget;
      }
      final int centerPositionX = recyclerView.getWidth() / 2;
      final int centerPositionY = recyclerView.getHeight() / 2;
      final View centerView = recyclerView.findChildViewUnder(centerPositionX, centerPositionY);
      if (centerView == null) {
        return defaultTarget;
      }
      final int centerViewPosition = recyclerView.getChildAdapterPosition(centerView);
      return Math.max(0, forward ? centerViewPosition + 1 : centerViewPosition - 1);
    default:
      return defaultTarget;
  }
}
 
源代码16 项目: CrazyDaily   文件: ItemTouchHelperExtension.java
/**
 * Called when {@link #onMove(RecyclerView, ViewHolder, ViewHolder)} returns true.
 * <p>
 * ItemTouchHelper does not create an extra Bitmap or View while dragging, instead, it
 * modifies the existing View. Because of this reason, it is important that the View is
 * still part of the layout after it is moved. This may not work as intended when swapped
 * Views are close to RecyclerView bounds or there are gaps between them (e.g. other Views
 * which were not eligible for dropping over).
 * <p>
 * This method is responsible to give necessary hint to the LayoutManager so that it will
 * keep the View in visible area. For example, for LinearLayoutManager, this is as simple
 * <p>
 * <p>
 * Default implementation calls {@link RecyclerView#scrollToPosition(int)} if the View's
 * new position is likely to be out of bounds.
 * <p>
 * It is important to ensure the ViewHolder will stay visible as otherwise, it might be
 * removed by the LayoutManager if the move causes the View to go out of bounds. In that
 * case, drag will end prematurely.
 *
 * @param recyclerView The RecyclerView controlled by the ItemTouchHelper.
 * @param viewHolder   The ViewHolder under user's control.
 * @param fromPos      The previous adapter position of the dragged item (before it was
 *                     moved).
 * @param target       The ViewHolder on which the currently active item has been dropped.
 * @param toPos        The new adapter position of the dragged item.
 * @param x            The updated left value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by
 *                     {@link RecyclerView.ItemDecoration}s.
 * @param y            The updated top value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by
 *                     {@link RecyclerView.ItemDecoration}s.
 */
public void onMoved(final RecyclerView recyclerView,
                    final ViewHolder viewHolder, int fromPos, final ViewHolder target, int toPos, int x,
                    int y) {
    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof ViewDropHandler) {
        ((ViewDropHandler) layoutManager).prepareForDrop(viewHolder.itemView,
                target.itemView, x, y);
        return;
    }

    // if layout manager cannot handle it, do some guesswork
    if (layoutManager.canScrollHorizontally()) {
        final int minLeft = layoutManager.getDecoratedLeft(target.itemView);
        if (minLeft <= recyclerView.getPaddingLeft()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxRight = layoutManager.getDecoratedRight(target.itemView);
        if (maxRight >= recyclerView.getWidth() - recyclerView.getPaddingRight()) {
            recyclerView.scrollToPosition(toPos);
        }
    }

    if (layoutManager.canScrollVertically()) {
        final int minTop = layoutManager.getDecoratedTop(target.itemView);
        if (minTop <= recyclerView.getPaddingTop()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxBottom = layoutManager.getDecoratedBottom(target.itemView);
        if (maxBottom >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
}
 
源代码17 项目: FChat   文件: DividerItemDecoration.java
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
 
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
源代码18 项目: GetApk   文件: StickyHeaderDecoration.java
protected void createPinnedHeader(RecyclerView parent) {
    updateStickyHeader(parent);

    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager == null || layoutManager.getChildCount() <= 0) {
        return;
    }
    int firstVisiblePosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
    int firstCompletelyVisiblePosition = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
    int headerPosition = findStickyHeaderPosition(parent, firstVisiblePosition);
    if (headerPosition == -1 || (headerPosition == firstCompletelyVisiblePosition)) {
        resetPinnedHeader();
        return;
    }
    if (headerPosition >= 0 && mHeaderPosition != headerPosition) {
        mHeaderPosition = headerPosition;
        int viewType = mAdapter.getItemViewType(headerPosition);
        mCurrentItemType = viewType;

        RecyclerView.ViewHolder stickyViewHolder = mAdapter.createViewHolder(parent, viewType);
        if (mAdapter instanceof SwipeStickyAdapter) {
            ((SwipeStickyAdapter) mAdapter).onBindSwipeViewHolder(stickyViewHolder, headerPosition);
        } else {
            mAdapter.onBindViewHolder(stickyViewHolder, headerPosition);
        }

        mStickyView = stickyViewHolder.itemView;


        // read layout parameters
        ViewGroup.LayoutParams layoutParams = mStickyView.getLayoutParams();
        if (layoutParams == null) {
            layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            mStickyView.setLayoutParams(layoutParams);
        }

        int heightMode = View.MeasureSpec.getMode(layoutParams.height);
        int heightSize = View.MeasureSpec.getSize(layoutParams.height);

        if (heightMode == View.MeasureSpec.UNSPECIFIED) {
            heightMode = View.MeasureSpec.EXACTLY;
        }

        int maxHeight = parent.getHeight() - parent.getPaddingTop() - parent.getPaddingBottom();
        if (heightSize > maxHeight) {
            heightSize = maxHeight;
        }

        // measure & layout
        int ws = View.MeasureSpec.makeMeasureSpec(parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight(), View.MeasureSpec.EXACTLY);
        int hs = View.MeasureSpec.makeMeasureSpec(heightSize, heightMode);
        mStickyView.measure(ws, hs);
        mStickyView.layout(0, 0, mStickyView.getMeasuredWidth(), mStickyView.getMeasuredHeight());
    }
}
 
源代码19 项目: LoopBar   文件: OrientationStateVerticalLeft.java
@Override
public boolean isItemsFitOnScreen(RecyclerView container, int itemsSize) {
    calcItemHeight(container);
    return container.getHeight() >= itemHeight * (itemsSize);
}
 
源代码20 项目: Carbon   文件: ItemTouchHelper.java
/**
 * Called when {@link #onMove(RecyclerView, ViewHolder, ViewHolder)} returns true.
 * <p>
 * ItemTouchHelper does not create an extra Bitmap or View while dragging, instead, it
 * modifies the existing View. Because of this reason, it is important that the View is
 * still part of the layout after it is moved. This may not work as intended when swapped
 * Views are close to RecyclerView bounds or there are gaps between them (e.g. other Views
 * which were not eligible for dropping over).
 * <p>
 * This method is responsible to give necessary hint to the LayoutManager so that it will
 * keep the View in visible area. For example, for LinearLayoutManager, this is as simple as
 * calling {@link LinearLayoutManager#scrollToPositionWithOffset(int, int)}.
 * <p>
 * Default implementation calls {@link RecyclerView#scrollToPosition(int)} if the View's new
 * position is likely to be out of bounds.
 * <p>
 * It is important to ensure the ViewHolder will stay visible as otherwise, it might be
 * removed by the LayoutManager if the move causes the View to go out of bounds. In that
 * case, drag will end prematurely.
 *
 * @param recyclerView The RecyclerView controlled by the ItemTouchHelper.
 * @param viewHolder   The ViewHolder under user's control.
 * @param fromPos      The previous adapter position of the dragged item (before it was
 *                     moved).
 * @param target       The ViewHolder on which the currently active item has been dropped.
 * @param toPos        The new adapter position of the dragged item.
 * @param x            The updated left value of the dragged View after drag translations
 *                     are applied. This value does not include margins added by {@link
 *                     RecyclerView.ItemDecoration}s.
 * @param y            The updated top value of the dragged View after drag translations are
 *                     applied. This value does not include margins added by {@link
 *                     RecyclerView.ItemDecoration}s.
 */
public void onMoved(final RecyclerView recyclerView,
                    final ViewHolder viewHolder, int fromPos, final ViewHolder target, int toPos, int x,
                    int y) {
    final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof ViewDropHandler) {
        ((ViewDropHandler) layoutManager).prepareForDrop(viewHolder.itemView,
                target.itemView, x, y);
        return;
    }
    // if layout manager cannot handle it, do some guesswork
    if (layoutManager.canScrollHorizontally()) {
        final int minLeft = layoutManager.getDecoratedLeft(target.itemView);
        if (minLeft <= recyclerView.getPaddingLeft()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxRight = layoutManager.getDecoratedRight(target.itemView);
        if (maxRight >= recyclerView.getWidth() - recyclerView.getPaddingRight()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
    if (layoutManager.canScrollVertically()) {
        final int minTop = layoutManager.getDecoratedTop(target.itemView);
        if (minTop <= recyclerView.getPaddingTop()) {
            recyclerView.scrollToPosition(toPos);
        }
        final int maxBottom = layoutManager.getDecoratedBottom(target.itemView);
        if (maxBottom >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) {
            recyclerView.scrollToPosition(toPos);
        }
    }
}