/kandy

Sweet Android libraries written in Kotlin

Primary LanguageKotlinApache License 2.0Apache-2.0

API 16 Download Apache License 2.0

Kandy

A Kotlin library set dedicated to Android platform which will make programming sweet again!

Repository

All modules are available on the jcenter. In order to import them, make sure your project includes the appropriate repository.

Project build.gradle.kts

repositories {
    // ...
    jcenter()
}

Kandy List Views

Highly flexible list view which will help you to write much less code and spend much less time for such basic thing as list view. Forget about writing copy-pasting another RecyclerView.Adapter. Let Kandy List Views set everything up for you. Basically, all you need to do is write a custom view holder for each model you want to see as a list item.

Flexibility

You can use any number of any types of list items within a single adapter. KandyListAdapter will take care of defining and managing view types.

Convenience

onBind method of a view holder provide you a type-safe getter of a list item. No need to keep an eye on a collection of data you've passed to the list view adapter. Let this method retrieve the appropriate object for you (including the inside of event listeners.)

Minimal working example

Custom view holder definition

class StringViewHolder(itemView: View) : AbstractDefaultKandyViewHolder<String>(itemView) {
    private val textView = itemView as TextView
    override fun onBind(position: Int, adapter: KandyListAdapter, listItemGetter: () -> KandyListItem<String>) {
        textView.text = listItemGetter().item
    }
}

Adapter initialization

val adapter = KandyListAdapter(
    KandyListItem(
        "String item",
        KandyItemView { TextView(this) }
    ) { itemView -> StringViewHolder(itemView) }
)

Full example

For full example, please refer to this file.

Import

Module build.gradle.kts

dependencies {
    // ...
    implementation("com.kwezal.kandy:listviews:${Version.kandy}@aar")
            { isTransitive = true } // Includes RecyclerView dependency
}

Kandy Dialogs

Simple DSL-like wrapper for AlertDialogs. Not only it makes the code shorter and prettier, but also more convenient to use.

The simplest example

show { dialog("Message", "Title") { positiveButton("OK") } }

Full example

For full example, please refer to this file.

Import

Module build.gradle.kts

dependencies {
    // ...
    implementation("com.kwezal.kandy:dialogs:${Version.kandy}@aar")
}

Kandy Logs

Android logs made so super simple you'll KISS them. No installation required. Automatic tag generation. Featherweight. No runtime overhead on production.

The simplest example

logD { "Message" }

Full example

For full example, please refer to this file.

Import

Module build.gradle.kts

debugImplementation("com.kwezal.kandy:logs-debug:${Version.kandy}@aar")
releaseImplementation("com.kwezal.kandy:logs-release:${Version.kandy}@aar")

The rest

Other modules of this set of libraries will be published soon. As for now I'd appreciate any kind of feedback or contribution.