Skip to content
Make displaying RecyclerViews easier by generating it's adapter with simple annotations.
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea Initial code commit Nov 5, 2019
annotations Initial code commit Nov 5, 2019
codegen Initial code commit Nov 5, 2019
gradle/wrapper Initial code commit Nov 5, 2019
.gitignore Initial code commit Nov 5, 2019
LICENSE Initial commit Nov 5, 2019
README.md
build.gradle.kts Initial code commit Nov 5, 2019
gradlew Initial code commit Nov 5, 2019
gradlew.bat Initial code commit Nov 5, 2019
settings.gradle

README.md

What is RecyclerAdapter Generator (RAG)?

Many Android Developers have to write the same boilerplate code for displaying a simple RecyclerView. This library tries to be a solution to minimize the written code which is required to write adapters for simple RecyclerViews.

Setup

RAG is currently only available on Jitpack.

Gradle

Check if jitpack is added as a repository.

// Project level build.gradle
allprojects {
    repositories {
        // your other repositories
        maven { url 'https://jitpack.io' }
    }
}

Dependencies

RAG consist of two separate artifacts: annotations which will be used to mark your classes for processing, and codegen which will generate the final code for you.

implementation "com.github.pshegger.recycleradapter-generator:annotations:0.1.0"

kapt "com.github.pshegger.recycleradapter-generator:codegen:0.1.0"

Add these 2 lines to your module dependencies and you can start using RAG.

Quick Start

Use @ModelBinding to annotate a class to be used for adapter generation.

@ModelBinding(
    R.layout.foo,           // layout id
    clickListener = false,  // if true an item click listener is generated for your adapter, default: false 
    namePrefix = ""         // default: empty -> generate name from the name of the data class
)
class UserBinding(private val user: User) {
    // binding methods
}

To create a method which binds the values of your data class to a View create a method annotated with @BindView inside your class.

@BindView(R.id.name)
fun setName(nameLabel: TextView) {
    nameLabel.text = user.name
}

If everything is ready press build and after it finishes your adapter will be generated (in the above example it will be called UserAdapter). From this point you can use at as it was written by you.

Features

  • Basic adapter generation
  • Item click listener support
  • Custom adapter name (only prefix)
  • Update Dispatching (using DiffUtil)
  • Click listener for specific Views
  • Artifacts for Maven Central

Feel free to suggest new features.

You can’t perform that action at this time.