codeerow / Databinding

Flexible data binding library implemented with Java. Contains Android bindings and Kotlin extensions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Databinding

Data binding interfaces with implementations for Android Java and Kotlin. No code generation. You can easily extend it but your own!

Latest version:

Now available:

View

  • visibility
  • enabled
  • click

TextView

  • text

Recycler view

  • items

Seekbar

  • progress (int)

Toolbar

  • nav button click

Installation

Gradle is the only supported build configuration.

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

dependencies {
        implementation "com.github.codeerow.databinding:core:2.0.1-beta"
        implementation "com.github.codeerow.databinding:androidx-core:2.0.1-beta" // androidx-core-ktx for Kotlin
        implementation "com.github.codeerow.databinding:androidx-recyclerview:2.0.1-beta" // androidx-recyclerview-ktx for Kotlin
}

Usage

ViewModel:

    val name = MutableLiveData<String>()
    val email = MutableLiveData<String>()
    val title = MutableLiveData<String>()
    val description = MutableLiveData<String>()

LifecycleOwner (e.g. Fragment):

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        dataBinding {
            with(inputName) {
                text(viewModel.name, twoWay = true)
            }
            with(inputEmail) {
                text(viewModel.email, twoWay = true)
            }
            with(inputTitle) {
                text(viewModel.title, twoWay = true)
            }
            with(inputDescription) {
                text(viewModel.description, twoWay = true)
            }
        }
    }

About

Flexible data binding library implemented with Java. Contains Android bindings and Kotlin extensions.


Languages

Language:Java 76.6%Language:Kotlin 23.4%