MCPcopy Index your code
hub / github.com/danoz73/RecyclerViewFastScroller

github.com/danoz73/RecyclerViewFastScroller @0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.1.0 ↗ · + Follow
126 symbols 268 edges 24 files 57 documented · 45%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

RecyclerViewFastScroller

The RecyclerViewFastScroller is a widget that can be added to a layout and connected to a RecyclerView for fast scrolling. In the interest of time, I am pushing out some usable code, but I plan on updating this to better support easy customization and inclusion in projects.

This project is a demonstration of using the RecyclerViewFastScroller widget in a simple activity that uses the basic workings of com.example.android.recyclerview from the v21 Android samples.

RecyclerViewFastScroller screenshot RecyclerViewFastScroller with section indicator screenshot

As of b3e2d2f, there is now support for adding a SectionIndicator widget, which connects to the scroller. This adds functionality similar to Google's Lollipop Contacts application.

Usage

Below are some simple steps to using a RecyclerViewFastScroller. Currently, there is only a single implementation (VerticalRecyclerViewFastScroller), so that will be used here.

The best way to check everything out is to peruse the example code and run the example app. See how VerticalRecyclerViewFastScroller is utilized in the recycler_view_frag.xml.

Example Code

1) In the activity or fragment XML where your RecyclerView resides, include a VerticalRecyclerViewFastScroller object. The following example would be in a relative layout:

...
  <android.support.v7.widget.RecyclerView
      android:id="@+id/recyclerView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      />

  <your.package.name.scroller.vertical.VerticalRecyclerViewFastScroller
      android:id="@+id/fast_scroller"
      android:layout_width="@dimen/however_wide_you_want_this"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      />
...

2) In your fragment or activity where you setup layout programmatically, simply hook up the fast scroller to the recycler as follows:

...
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.recycler_view_frag, container, false);
      ...

      // Grab your RecyclerView and the RecyclerViewFastScroller from the layout
      RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
      VerticalRecyclerViewFastScroller fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fast_scroller);

      // Connect the recycler to the scroller (to let the scroller scroll the list)
      fastScroller.setRecyclerView(recyclerView);

      // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
      recyclerView.setOnScrollListener(fastScroller.getOnScrollListener());

      ...
      return rootView;
  }
...
Optional usage

There are currently a few attributes that can be used to customize the vertical fast scroller:

  <attr name="barColor" format="color|reference" />
  <attr name="barBackground" format="reference" />
  <attr name="handleColor" format="color|reference" />
  <attr name="handleBackground" format="reference" />

You can see usage of some of these in the example recycler_view_with_fast_scroller_fragment.xml which is the layout for the example app's single fragment.

SectionIndicators

Refer to RecyclerViewWithSectionIndicatorFragment and the corresponding recycler_view_with_fast_scroller_section_title_indicator_fragment.xml in order to find an implementation that adds the Lollipop-Contacts-like section indicator. In addition to the above, you will need to include the indicator in your layout (example here from recycler_view_with_fast_scroller_section_title_indicator_fragment.xml):

...
    <com.example.recyclerviewfastscroller.ui.example.ColorGroupSectionTitleIndicator
      android:id="@+id/fast_scroller_section_title_indicator"
      android:layout_width="wrap_content"
      android:layout_height="@dimen/list_item_height"
      android:layout_toLeftOf="@id/fast_scroller"
      android:layout_toStartOf="@id/fast_scroller"

      custom:backgroundColor="@android:color/white"
      custom:textColor="@android:color/black"
       />
...

and then connect it to the scroller in the fragment:

...
    // Connect the section indicator to the scroller
    fastScroller.setSectionIndicator(sectionTitleIndicator);
...

Setup

(Apologies for the current state of affairs. I'll hopefully make this into a library when I think it is complete enough for my liking)

For now, you will need to dive into the code yourself and copy/repurpose any of the code you need to use. Most of the code you can reuse should be in the Application/src/main/java/com/example/recyclerviewfastscroller/ui/scroller package. You will likely need some of the layout and drawable files as well.

Contribution

Feel free to submit pull requests and create issues. I haven't necessarily implemented this as well as possible, and am always open to suggestions for improvement.

Extension points exported contracts — how you extend this code

RecyclerViewScroller (Interface)
To be implemented by any object that scrolls a RecyclerView [3 implementers]
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/RecyclerViewScroller.java
TouchableScrollProgressCalculator (Interface)
Assists in calculating the amount of scroll progress for a RecyclerView based on a MotionEvent [3 implementers]
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/calculation/progress/TouchableScrollProgressCalculator.java
ScrollProgressCalculator (Interface)
Assists in calculating the amount of scroll progress for a RecyclerView [2 implementers]
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/calculation/progress/ScrollProgressCalculator.java
SectionIndicator (Interface)
An indicator for which section a RecyclerView is currently in. This is for RecyclerViews whose adapters implemen [1 implementers]
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/sectionindicator/SectionIndicator.java

Core symbols most depended-on inside this repo

getScrollProgressCalculator
called by 4
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java
getMaximumScrollY
called by 4
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/calculation/VerticalScrollBoundsProvider.java
replaceCurrentFragment
called by 3
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/MainActivity.java
getSize
called by 3
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/data/ColorDataSet.java
get
called by 3
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/data/ColorDataSet.java
setViewBackground
called by 3
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java
moveHandleToPosition
called by 3
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java
calculateScrollProgress
called by 3
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/calculation/progress/ScrollProgressCalculator.java

Shape

Method 101
Class 20
Interface 4
Enum 1

Languages

Java100%

Modules by API surface

recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/AbsRecyclerViewFastScroller.java22 symbols
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/recyclerview/ColorfulAdapter.java12 symbols
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/sectionindicator/title/SectionTitleIndicator.java10 symbols
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/sectionindicator/AbsSectionIndicator.java9 symbols
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/vertical/VerticalRecyclerViewFastScroller.java6 symbols
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/data/ColorGroup.java5 symbols
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/data/ColorDataSet.java5 symbols
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/data/ColorData.java5 symbols
Application/src/main/java/xyz/danoz/recyclerviewfastscroller/sample/MainActivity.java5 symbols
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/sectionindicator/SectionIndicator.java4 symbols
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/calculation/VerticalScrollBoundsProvider.java4 symbols
recyclerviewfastscroller/src/main/java/xyz/danoz/recyclerviewfastscroller/RecyclerViewScroller.java4 symbols

For agents

$ claude mcp add RecyclerViewFastScroller \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact