public RecyclerViewLayoutManagerAssert hasHeight(int height) { isNotNull(); int actualHeight = actual.getHeight(); assertThat(actualHeight) // .overridingErrorMessage("Expected height <%s> but was <%s>.", height, actualHeight) // .isEqualTo(height); return this; }
public RecyclerViewLayoutManagerAssert hasHeight(int height) { isNotNull(); int actualHeight = actual.getHeight(); assertThat(actualHeight) // .overridingErrorMessage("Expected height <%s> but was <%s>.", height, actualHeight) // .isEqualTo(height); return this; }
@Override public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = view.getTop() - params.topMargin; final int bottom = view.getBottom() + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); } @Override
/** * Calculates the vertical scroll amount necessary to make the given view fully visible * inside the RecyclerView. * * @param view The view which we want to make fully visible * @param snapPreference The edge which the view should snap to when entering the visible * area. One of {@link #SNAP_TO_START}, {@link #SNAP_TO_END} or * {@link #SNAP_TO_ANY}. * @return The vertical scroll amount necessary to make the view visible with the given * snap preference. */ public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = layoutManager.getDecoratedTop(view) - params.topMargin; final int bottom = layoutManager.getDecoratedBottom(view) + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); }
/** * Calculates the vertical scroll amount necessary to make the given view in center of the RecycleView * * @param view The view which we want to make in center of the RecycleView * @return The vertical scroll amount necessary to make the view in center of the RecycleView */ public int calculateDyToMakeCentral(View view) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int top = layoutManager.getDecoratedTop(view) - params.topMargin; final int bottom = layoutManager.getDecoratedBottom(view) + params.bottomMargin; final int start = layoutManager.getPaddingTop(); final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); final int childCenter = top + (int) ((bottom - top) / 2.0f); final int containerCenter = (int) ((end - start) / 2.f); return containerCenter - childCenter; }
private int adjustDyForUp(int dy) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final View lastChild = layoutManager.getChildAt(layoutManager.getChildCount() - 1); final int position = layoutManager.getPosition(lastChild); if (position == layoutManager.getItemCount() - 1) { final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) lastChild.getLayoutParams(); final int maxDy = layoutManager.getHeight() - layoutManager.getPaddingBottom() - (layoutManager.getDecoratedBottom(lastChild) + params.bottomMargin); if (dy < maxDy) { return maxDy; } } return dy; }
@Override public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final int adapterPosition = getPosition(view); final int topOffset = getPositionSectionHeaderHeight(adapterPosition); final int top = layoutManager.getDecoratedTop(view); final int bottom = layoutManager.getDecoratedBottom(view); final int start = layoutManager.getPaddingTop() + topOffset; final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); } };
public int getHeight() { return layoutManager.getHeight(); }
@Override public int getEnd() { return mLayoutManager.getHeight(); }
@Override public int getEndAfterPadding() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingBottom(); }
@Override public int getEnd() { return mLayoutManager.getHeight(); }
@Override public int getTotalSpace() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingTop() - mLayoutManager.getPaddingBottom(); }
@Override public int calculateDyToMakeVisible(View view, int snapPreference) { final RecyclerView.LayoutManager layoutManager = getLayoutManager(); if (layoutManager == null || !layoutManager.canScrollVertically()) { return 0; } final int adapterPosition = getPosition(view); final int topOffset = getPositionSectionHeaderHeight(adapterPosition); final int top = layoutManager.getDecoratedTop(view); final int bottom = layoutManager.getDecoratedBottom(view); final int start = layoutManager.getPaddingTop() + topOffset; final int end = layoutManager.getHeight() - layoutManager.getPaddingBottom(); return calculateDtToFit(top, bottom, start, end, snapPreference); } };
@Override public int getTotalSpaceInOther() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingTop() - mLayoutManager.getPaddingBottom(); }
@Override public int getTotalSpace() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingTop() - mLayoutManager.getPaddingBottom(); }
@Override public int getEnd() { return mLayoutManager.getHeight(); }
@Override public int getEndAfterPadding() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingBottom(); }
@Override public int getEndAfterPadding() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingBottom(); }
@Override public int getTotalSpaceInOther() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingTop() - mLayoutManager.getPaddingBottom(); }
@Override public int getTotalSpace() { return mLayoutManager.getHeight() - mLayoutManager.getPaddingTop() - mLayoutManager.getPaddingBottom(); }