public static RecyclerViewPositionHelper createHelper(RecyclerView recyclerView) { if (recyclerView == null) { throw new NullPointerException("Recycler View is null"); } return new RecyclerViewPositionHelper(recyclerView); }
public RecyclerViewAttacher(final RecyclerView recyclerView, final MugenCallbacks callbacks) { super(recyclerView, callbacks); mRecyclerViewHelper = RecyclerViewPositionHelper.createHelper(recyclerView); }
mPrevFirstVisibleItem = mRecyclerViewHelper.findFirstVisibleItemPosition(); } else { final int firstVisibleItem = mRecyclerViewHelper.findFirstVisibleItemPosition(); if (firstVisibleItem > mPrevFirstVisibleItem) { final int totalItemCount = mRecyclerViewHelper.getItemCount(); final int firstVisibleItem = mRecyclerViewHelper.findFirstVisibleItemPosition(); final int visibleItemCount = Math.abs(mRecyclerViewHelper.findLastVisibleItemPosition() - firstVisibleItem); final int lastAdapterPosition = totalItemCount - 1; final int lastVisiblePosition = (firstVisibleItem + visibleItemCount) - 1;
/** * Returns the adapter position of the first visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the first visible item or {@link RecyclerView#NO_POSITION} if * there aren't any visible items. */ public int findFirstVisibleItemPosition() { final View child = findOneVisibleChild(0, layoutManager.getChildCount(), false, true); return child == null ? NO_POSITION : recyclerView.getChildAdapterPosition(child); }
/** * Returns the adapter position of the first fully visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the first fully visible item or * {@link RecyclerView#NO_POSITION} if there aren't any visible items. */ public int findFirstCompletelyVisibleItemPosition() { final View child = findOneVisibleChild(0, layoutManager.getChildCount(), true, false); return child == null ? NO_POSITION : recyclerView.getChildAdapterPosition(child); }
/** * Returns the adapter position of the last visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the last visible view or {@link RecyclerView#NO_POSITION} if * there aren't any visible items */ public int findLastVisibleItemPosition() { final View child = findOneVisibleChild(layoutManager.getChildCount() - 1, -1, false, true); return child == null ? NO_POSITION : recyclerView.getChildAdapterPosition(child); }
/** * Returns the adapter position of the last fully visible view. This position does not include * adapter changes that were dispatched after the last layout pass. * * @return The adapter position of the last fully visible view or * {@link RecyclerView#NO_POSITION} if there aren't any visible items. */ public int findLastCompletelyVisibleItemPosition() { final View child = findOneVisibleChild(layoutManager.getChildCount() - 1, -1, true, false); return child == null ? NO_POSITION : recyclerView.getChildAdapterPosition(child); }