Skip to content

Adapter with single ViewHolder for Android RecyclerView

License

Notifications You must be signed in to change notification settings

carousell/SoloAdapter

Repository files navigation

SoloAdapter

CircleCI jitpack

Adapter with single ViewHolder for Android RecyclerView.

Install

With setup of Jitpack first, than add dependency in your build.gradle

implementation 'com.github.carousell:SoloAdapter:0.3'

Concept

Most use case is used with ConcatAdapter adapter but it's not required. If you only want to add single View to Adapter it's too verbose to keep writing boilerplate code. For example you want to add new header to existing Adapter, you can compose by ConcatAdapter but the new Adapter will be awkward to have single View. Instead of manually add everything again and again, this library help you to provide a nice interface for it.

Usage & Example

  1. Pass static View xml
val adapter = SoloAdapter(R.layout.some_layout)
  1. Pass View directly
val view = TextView(this)

val adapter = SoloAdapter(view)
  1. Setup bind function
val adapter = SoloAdapter(R.layout.some_layout)

adapter.bind { view ->
    view.findViewById<TextView>(R.id.textView).text = "some_string"
}

Go to ./app module for more information.

Contributing

Thank you for being interested in contributing to this project. Check out the CONTRIBUTING document for more info.

About

Carousell

SoloAdapter is created and maintained by Carousell. Help us improve this project! We'd love the feedback from you.

We're hiring! Find out more at http://careers.carousell.com/

License

SoloAdapter is released under Apache License 2.0. See LICENSE for more details.