• Stars
    star
    328
  • Rank 128,352 (Top 3 %)
  • Language
    Java
  • Created over 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reactive RecyclerView Adapter [DEPRECATED]

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

Data Flow Visualization

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'
}

More Repositories

1

AndroidForms

MVC Forms for Android
Java
36
star
2

pyvm

8-bit RISC Assembler and VM
Python
7
star
3

TestingLayers

Sample Project showing Testing by Layer Integration
Kotlin
4
star
4

todoapp

ReactiveX, Kotlin, MVP, Android
Kotlin
4
star
5

CompositionExample

Android Databindings / Android ViewModel Composition Example
Kotlin
3
star
6

h5api

Halo 5 Retrofit API
Java
3
star
7

mvvmexample2

Focused Functional MVVM Example App
Kotlin
3
star
8

vimfiles

My ~/.vim folder
Vim Script
2
star
9

StockTickerApp

Stock Ticker / Watchlist App being used as an excuse to learn Compose and other Jetpack libs.
Kotlin
2
star
10

RxCachingStrategies

Based off a talk I gave
Kotlin
2
star
11

ExpressFiles

File taging / file searching via regular expressions for android
Java
2
star
12

supybot-last-title

LastTitle plugin for supybot
Python
2
star
13

NyxEngine

Nyx game engine.
C
1
star
14

stem

Swiss Tournament Runner for Android
Java
1
star
15

swiss-runner

Swiss Style Tournament Runner for Desktop
Kotlin
1
star
16

MVVMExampleApp

MVVM Example App
Java
1
star
17

touchpad

Android Touchpad for PyCTL
Java
1
star
18

TodoApp2

Rx / Firebase / MvvM Sample app
Kotlin
1
star
19

chatjs

Simple broadcast chat with node.js
JavaScript
1
star
20

TDDPost

Github repo for "TDD for 5 year olds"
Kotlin
1
star
21

notifier

Android Notification Server for 4.3+ Devices
Java
1
star
22

TradeTracker

Kotlin
1
star
23

MockShell

Small fast Shell command mocking
Haskell
1
star
24

pyctl

Mouse (and eventually keyboard) Control via TCP (and eventually Bluetooth)
Python
1
star
25

StashClient

Android Stash Client
Kotlin
1
star
26

CleanHaskell

Brain Dump @ Clean Haskell App
Haskell
1
star
27

NyxEngineSandbox

1
star
28

DJForms

DJForms are Clean Forms for Android!
Java
1
star
29

KViewBinding

Simple Android Resource binding utilizing Kotlin delegation
Kotlin
1
star
30

HTTP

HTTP API for C
C
1
star
31

gitIssues2

Complete Rewrite of GitIssues, including new UI and utilizing Github's V3 API Java Library
Java
1
star
32

JavaMonads

Playing with the concept of Monads in Java
Java
1
star