PrimeAdapter makes working with RecyclerView easier.
Alternatives To Primeadapter
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
a year ago2March 30, 202213mitKotlin
The Android maps adapter
Kotshi72543a day ago35November 19, 20214apache-2.0Kotlin
An annotation processor that generates Moshi adapters from immutable Kotlin data classes.
a year ago3April 19, 20222apache-2.0Java
AndLinker is a IPC library for Android, which combines the features of AIDL and Retrofit. Allows IPC call seamlessly compose with RxJava and RxJava2 call adapters.
Dart Json Mapper366285 days ago150October 30, 20229otherDart
Serialize / Deserialize Dart Objects to / from JSON
4 years agoapache-2.0Kotlin
Generate data-view-binding adapters of android recycler view.
6 years ago10apache-2.0Java
Android library for streamlining SharedPreferences
6 years ago12Kotlin
Android framework for building UI quickly in Kotlin, inspired by React.js
5 years ago1apache-2.0Java
This Repository simplifies working with RecyclerView Adapter
Moshi Lazy Adapters149214 years ago7May 02, 20186apache-2.0Java
A collection of simple JsonAdapters for Moshi.
Auto Parcel76
7 years ago1apache-2.0Java
A fast annotation processor to make your objects `Parcelable` without writing any of the boilerplate.
Alternatives To Primeadapter
Select To Compare

Alternative Project Comparisons

PrimeAdapter ⚡️

Android Arsenal API Download

PrimeAdapter makes working with RecyclerView easier by separating required code in a few simple and well-structured classes. It brings simplicity when you have multiple view types in a RecyclerView. By using annotation processing, it generates unique view types automatically to make the code more clear. You can use PrimeAdapter in both Kotlin and Java Android projects as the sample apps are written.

Custom Divider Draggability Expandability
Example Example Example


Add the following lines to your build.gradle file:

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
repositories {
dependencies {
    implementation 'com.aminography:primeadapter:1.0.14'
    compileOnly 'com.aminography:primeadapter-annotation:1.0.14'
    kapt 'com.aminography:primeadapter-processor:1.0.14'
  • If you write code in Java, you should also add kotlin dependency too:
dependencies {
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50'

How to use PrimeAdapter?

You should create both data holder and view holder classes for each type of view that you want to show in RecyclerView.

1. It's necessary to add @DataHolder annotation above all data holder classes which inherits from PrimeDataHolder:

data class ActorDataHolder(
        val name: String
) : PrimeDataHolder()

2. Each view holder class should inherit from PrimeViewHolder and specify related data holder as a type parameter like following:

class ActorViewHolder(
        delegate: PrimeDelegate
) : PrimeViewHolder<ActorDataHolder>(delegate, R.layout.list_item) {
    override fun bindDataToView(dataHolder: ActorDataHolder) {
        with(itemView) {
            nameTextView.text =

3. Your custom adapter class must inherit from PrimeAdapter that decides to make view holder instance based on data holder type. Follow this pattern:

class ActorAdapter : PrimeAdapter() {
    override fun makeViewHolder(dataHolderClass: Class<*>?): PrimeViewHolder<*>? {
        return when (dataHolderClass) {
   -> ActorViewHolder(this)
            else -> null

4. Finally, you can instantiate your custom adapter using PrimeAdapter builder mechanism.

override fun onCreate(savedInstanceState: Bundle?) {
    val adapter = PrimeAdapter.with(recyclerView)
    val dataList = mutableListOf<PrimeDataHolder>()
    dataList.add(ActorDataHolder("Tom Hanks"))
    dataList.add(ActorDataHolder("Morgan Freeman"))
    dataList.add(ActorDataHolder("Robert De Niro"))

Extra Features

Handling Item Clicks

PrimeAdapter helps you handle RecyclerView items click events, simply by setItemClickListener() with an OnRecyclerViewItemClickListener argument when you're building an adapter instance or later:

val onRecyclerViewItemClickListener = object: OnRecyclerViewItemClickListener{
    override fun onItemClick(primeDataHolder: PrimeDataHolder) {
        // do something
    override fun onItemLongClick(primeDataHolder: PrimeDataHolder) {
        // do something

// In builder pattern:
val adapter = PrimeAdapter.with(recyclerView)
// or after adapter instantiation:


PrimeAdapter helps you make the RecyclerView items draggable. It would be activated/deactivated by calling setDraggable(true)/setDraggable(false) on a builder or an adapter instance. Optionally, you can get notified about item movements by calling setItemDragListener() and passing an OnRecyclerViewItemDragListener instance to it.

adapter.setItemDragListener(object: OnRecyclerViewItemDragListener{
    override fun onItemMoved(fromPosition: Int, toPosition: Int) {
        // do something

It is necessary to introduce a view as handle of dragging in view holders which are going to be draggable:

class ActorViewHolder(
        delegate: PrimeDelegate
) : PrimeViewHolder<ActorDataHolder>(delegate, R.layout.list_item) {
    init {


Another feature of PrimeAdapter is making the implementation of RecyclerView items expansion easier. Calling the setExpandable(true)/setExpandable(false) on a builder or on adapter instance changes its activation.


To see how to implement it, please check the related example code.

Custom Skippable Divider

Showing custom divider lines is a good feature that PrimeAdapter provides. Calling the setDivider() on a builder or on adapter instance leads to show default divider line between items. It's possible to pass it a custom Drawable instance or simply a color to change the divider looking. Also we can set inset for divider drawables in pixels.

//----- default divider:
//----- divider with custom drawable:
adapter.setDivider(ContextCompat.getDrawable(context, R.drawable.divider))
//----- divider with custom color:
//----- divider with custom color and custom inset:
adapter.setDivider(Color.RED, insetLeft = 16, insetRight = 16)
//----- deactivate dividers:

By default dividers are shown for all items except the last one. It's easy to skip some items divider by setting hasDivider property to false on their data holder instances.

adapter.getItem(position).hasDivider = false


If you want to create a release version of your app, you need to include the following lines in the app level proguard file:

-keep class com.aminography.primeadapter.ViewTypeManager { *; }
-keepclassmembers class ** {
    @com.aminography.primeadapter.annotation.DataHolder *;


Copyright 2018 Mohammad Amin Hassani.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
Popular Adapter Projects
Popular Annotation Projects
Popular Libraries Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.