KRecyclerDsl

Additional

Language
Kotlin
Version
v0.3.0 (Dec 30, 2017)
Created
Aug 7, 2017
Updated
Jan 3, 2018
Owner
Thomas Girard (tgirard12)
Contributor
Thomas Girard (tgirard12)
1
Activity
Badge
Generate
Download
Source code

Advertising

KRecyclerDsl

Kotlin Dsl for Android RecyclerView

Exemple

recyclerView.adapter = dataClassAdapter<MyView, MyDataClass>(R.layout.my_view, myItems) {
    onBindViewHolder { view, dataClass ->
        view.name.text = dataClass.name
        view.description.text = dataClass.description
    }
    onItemClickListener { view, dataClass ->
        startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(dataClass.html_url)))
    }
}

Extensions functions

This library provide some useful (or not) extensions functions :

// Call the function when scroll down on the last visible item
recyclerView.addInfiniteScrollListener { search() }

// Add separation between each line.
recyclerView.addDividerItemDecorationVertical()

// Add separation between each column.
recyclerView.addDividerItemDecorationHorizontal()

Dependency

KRecyclerDsl has no dependency, you must add your RecyclerView library version.
This library generate a JAR, not an AAR, so you can use it with any compile version option.

compile "com.tgirard12.krecyclerdsl:krecyclerdsl:0.3.0"

// Required
compile "com.android.support:recyclerview-v7:$your_version"