car/src/main/java/androidx/car/widget/PagedListView.java
private void updatePaginationButtons(boolean animate) {
        if (!mScrollBarEnabled) {
            // Don't change the visibility of the ScrollBar unless it's enabled.
            return;
        }

        boolean isAtStart = isAtStart();
        boolean isAtEnd = isAtEnd();
        RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();

        if ((isAtStart && isAtEnd) || layoutManager == null || layoutManager.getItemCount() == 0) {
            mScrollBarView.setVisibility(View.INVISIBLE);
        } else {
            mScrollBarView.setVisibility(View.VISIBLE);
        }
        mScrollBarView.setUpEnabled(!isAtStart);
        mScrollBarView.setDownEnabled(!isAtEnd);

        if (layoutManager == null) {
            return;
        }

        if (mRecyclerView.getLayoutManager().canScrollVertically()) {
            mScrollBarView.setParameters(
                    mRecyclerView.computeVerticalScrollRange(),
                    mRecyclerView.computeVerticalScrollOffset(),
                    mRecyclerView.computeVerticalScrollExtent(), animate);
        } else {
            mScrollBarView.setParameters(
                    mRecyclerView.computeHorizontalScrollRange(),
                    mRecyclerView.computeHorizontalScrollOffset(),
                    mRecyclerView.computeHorizontalScrollExtent(), animate);
        }

        invalidate();
    }
/**
     * Determines if scrollbar should be visible or not and shows/hides it accordingly. If this is
     * being called as a result of adapter changes, it should be called after the new layout has
     * been calculated because the method of determining scrollbar visibility uses the current
     * layout. If this is called after an adapter change but before the new layout, the visibility
     * determination may not be correct.
     *
     * @param animate {@code true} if the scrollbar should animate to its new position.
     *                {@code false} if no animation is used
     */
Determines if scrollbar should be visible or not and shows/hides it accordingly. If this is
being called as a result of adapter changes, it should be called after the new layout has
been calculated because the method of determining scrollbar visibility uses the current
layout. If this is called after an adapter change but before the new layout, the visibility
determination may not be correct.

@param animate  true if the scrollbar should animate to its new position.
false if no animation is used
Determines if scrollbar should be visible or not and shows / hides it accordingly . If this is being called as a result of adapter changes it should be called after the new layout has been calculated because the method of determining scrollbar visibility uses the current layout . If this is called after an adapter change but before the new layout the visibility determination may not be correct . @param animate true if the scrollbar should animate to its new position . false if no animation is used
private void updatePaginationButtons(boolean animate) {
        if (!mScrollBarEnabled) {
            return;
        }
        boolean isAtStart = isAtStart();
        boolean isAtEnd = isAtEnd();
        RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
        if ((isAtStart && isAtEnd) || layoutManager == null || layoutManager.getItemCount() == 0) {
            mScrollBarView.setVisibility(View.INVISIBLE);
        } else {
            mScrollBarView.setVisibility(View.VISIBLE);
        }
        mScrollBarView.setUpEnabled(!isAtStart);
        mScrollBarView.setDownEnabled(!isAtEnd);
        if (layoutManager == null) {
            return;
        }
        if (mRecyclerView.getLayoutManager().canScrollVertically()) {
            mScrollBarView.setParameters(
                    mRecyclerView.computeVerticalScrollRange(),
                    mRecyclerView.computeVerticalScrollOffset(),
                    mRecyclerView.computeVerticalScrollExtent(), animate);
        } else {
            mScrollBarView.setParameters(
                    mRecyclerView.computeHorizontalScrollRange(),
                    mRecyclerView.computeHorizontalScrollOffset(),
                    mRecyclerView.computeHorizontalScrollExtent(), animate);
        }
        invalidate();
    }
private void updatePaginationButtons ( boolean animate ) { if ( ! mScrollBarEnabled ) { return ; } boolean isAtStart = isAtStart ( ) ; boolean isAtEnd = isAtEnd ( ) ; RecyclerView . LayoutManager layoutManager = mRecyclerView . getLayoutManager ( ) ; if ( ( isAtStart && isAtEnd ) || layoutManager == null || layoutManager . getItemCount ( ) == 0 ) { mScrollBarView . setVisibility ( View . INVISIBLE ) ; } else { mScrollBarView . setVisibility ( View . VISIBLE ) ; } mScrollBarView . setUpEnabled ( ! isAtStart ) ; mScrollBarView . setDownEnabled ( ! isAtEnd ) ; if ( layoutManager == null ) { return ; } if ( mRecyclerView . getLayoutManager ( ) . canScrollVertically ( ) ) { mScrollBarView . setParameters ( mRecyclerView . computeVerticalScrollRange ( ) , mRecyclerView . computeVerticalScrollOffset ( ) , mRecyclerView . computeVerticalScrollExtent ( ) , animate ) ; } else { mScrollBarView . setParameters ( mRecyclerView . computeHorizontalScrollRange ( ) , mRecyclerView . computeHorizontalScrollOffset ( ) , mRecyclerView . computeHorizontalScrollExtent ( ) , animate ) ; } invalidate ( ) ; }
Determines if scrollbar should be visible or not and shows/hides it accordingly.
Determines if scrollbar should be visible or not and shows / hides it accordingly .
// Don't change the visibility of the ScrollBar unless it's enabled.