RxRecyclerViewAdapter


Source link: https://github.com/exallium/RxRecyclerView

NOTE

This library is DEPRECATED and not recommended for utilization, as it uses very old versions of Rx and Gradle. However, I am leaving it here so that you might be able to draw on some of the concepts if you're implementing your own version, or for you to freely fork and modify / update.

Known issues:

The gradle version / bintray version are super duper old. Please remove any references to bintray if you clone this yourself, or update them as necessary.

RxRecyclerViewAdapter Library 2.0

Crazy easy to use RecyclerView Adapter for Reactive Applications

Interface

  • RxRecyclerViewAdapter::onCreateViewHolder is the same as RecyclerView.Adapter
  • RxRecyclerViewAdapter::onBindViewHolder gives you the Element you are binding to
  • RxRecyclerViewAdapter::preProcessElement gives you the chance to work with elements before they enter the underlying tree set.
  • RxRecyclerViewAdapter::postProcessElement gives you the chance to work with elements after the RecyclerView has been notified of the element.
  • Event<K,V> is Immutable and takes an Event.TYPE, Key, and Value.
  • Event<K,V> also contains an UNKNOWN type and is overridable for custom processing.
  • EventElement<K,V> and it's subclasses wrap Events and contain a view type for easy addition of headers, footers, and "list is empty" view.

Creating an Adapter

You need to have an Observable that you've merged all of your event emitters into. You then need to either map those into EventElements or utilize GroupComparator and it's corresponding Operator via Observable::lift to do the conversion for you.

Sorting and Grouping your stuff

There is an interface called GroupComparator that lets you sort and group your Events. These are passed to an instance of ElementGenerationOperator which will then add in Header and Footer items, as well as handle Empty items per your provided Options. The Adapter uses a TreeSet internally, which allows for automatic sorting by natural keys (Elements subclass Comparator).

View Types

You can create your own new view types by extending the appropriate EventElement subclass, or EventElement itself. Each View type has a corresponding bit mask that are placed in the 11th and 12th bits of the View type integer. This means that when you want to know what kind of view you are looking at, you can simply shift it's view type like so: element.getViewType() >> EventElement.MASK_SHIFT and compare it to the defined static integer masks within EventElement. This allows you to do things like create your own Header elements and whatnot, with unique viewtypes, and rest assured that they'll work properly.

This system allows us to avoid using instanceof calls everywhere, and stick to switch cases.

Examples

Are available in the app module!

Licensing

This work is (C) under the MIT License.

Gradle

This has been released on Bintray

repositories {

  maven {

url  "http://dl.bintray.com/exallium/maven"

}
 
}
  dependencies {

  compile 'com.exallium.rxrecyclerview:lib:2.1.2' 
}

Resources

Android library handling flashlight for camera and camera2 api. Added support for handling display/screen light.

Yet Another Android animated Seekbar inspired from Philips Hue app.

Great sound quality, audio cleanliness and very smooth interface. Playing the folder structure, artist or album or create your own playlists with local or online tracks.

  • 10-band equalizer
  • Themes
  • mp3, flac, aac, ogg, oga, m4a, m4b, m4p, wma and other audio formats

Shape Ripple is a library that emulates a ripple like animations with cool tweaks on the go. It runs on API level 11 and upwards.

As addition you can even create your own shape renderer through the canvas to create a custom shape ripple.

An unofficial Unsplash API library.

MapDrawingTools is an android library to Drawing manually polygon, polyline and points in the Google Map and return coordinates from library to your App. this library useful for application that pick multiple point or drawing border of land to get data from users.

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