RecyclerViewFastScroller


Source link: https://github.com/danoz73/RecyclerViewFastScroller

RecyclerViewFastScroller

The RecyclerViewFastScroller is a widget that can be added to a layout and connected to a RecyclerView for fast scrolling.

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.

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.

Download

You can grab the current version of the library from maven central

compile 'xyz.danoz:recyclerviewfastscroller:0.1.3'

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 sample Application. 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"

 />
 <xyz.danoz.recyclerviewfastscroller.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"

 /> ...
  1. 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="rfs_barColor" format="color|reference" />
<attr name="rfs_barBackground" format="reference" />
<attr name="rfs_handleColor" format="color|reference" />
<attr name="rfs_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):

...
  <xyz.danoz.recyclerviewfastscroller.sample.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"

  recyclerviewfastscroller:rfs_backgroundColor="@android:color/white"

 recyclerviewfastscroller:rfs_textColor="@android:color/black"

  /> ...

and then connect it to the scroller in the fragment:

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

Contribution

Feel free to submit pull requests and create issues! I will try to be vigilant about maintaining this library, but may not always be as fast as you would like ;)

Resources

Utility library of concurrent execution strategies for JVM and Android.

  • Inspired by async for JavaScript and Node.js.
  • Execute collection iterators and control flow strategies concurrently in the background.
  • Callbacks are notified when strategies are complete, cancelled, or error out.
  • Android extensions execute final callbacks on the UI thread.

This library extends RecyclerView + Recycler Adapter.

Epoxy is an Android library for building complex screens in a RecyclerView. It abstracts the boilerplate of view holders, item types, item ids, span counts, and more, in order to simplify building screens with multiple view types. Additionally, Epoxy adds support for saving view state and automatic diffing of item changes.

Tiger - the fastest java dependency injection framework.

A SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore. You can also use the EncryptionManager to encrypt/decrypt data out of the box.

An example project which imitates Liulishuo guide view.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes