All Projects → wada811 → ViewBinding-ktx

wada811 / ViewBinding-ktx

Licence: Apache-2.0 License
ViewBinding-ktx make easy to use ViewBinding.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to ViewBinding-ktx

GuildWars2 APIViewer
Guild Wars 2 API Viewer: An Android application used for viewing various Guild Wars 2 API endpoint responses. Developed utilizing MVVM architecture, in conjunction with Databinding, Dagger 2, Retrofit 2, and RxJava 2.
Stars: ✭ 53 (+65.63%)
Mutual labels:  android-databinding
DataBinding-ktx
DataBinding-ktx make easy to use DataBinding.
Stars: ✭ 113 (+253.13%)
Mutual labels:  android-databinding
ContactsApp
Go-Jek Engineering Task Used MVP and Unit Testing Espresso, Mock Webserver and Activity Instrumentation Tests ,RxJava + RxAndroid + Retrofit 2 + OkHttp 3 + Dagger2 + ButterKnife+ Glide + Active Android ORM
Stars: ✭ 21 (-34.37%)
Mutual labels:  android-databinding

ViewBinding-ktx

ViewBinding-ktx make easy to use ViewBinding.

DataBinding-ktx is here.

Overview

  • ViewBinding-ktx provides withBinding method accessing the binding variable by lambda.
  • ViewBinding-ktx provides viewBinding method accessing the binding variable by delegated property.

Usage

Lambda

// no reflection
withBinding(ViewBindingActivityBinding::bind) { binding ->

}
// reflection
withBinding<ViewBindingActivityBinding> { binding ->

}

Delegated Property

private val binding by viewBinding(ViewBindingActivityBinding::bind) // no reflection
private val binding: ViewBindingActivityBinding by viewBinding() // reflection

Note: In Fragment, When fragment's view is destroyed, an IllegalStateException is thrown on accessing the binding property.
If you access the binding property when fragment's view may be destroyed, you must use the Lambda way above.

Gradle

android {
    buildFeatures {
        viewBinding true
    }
}

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

dependencies {
    implementation 'com.github.wada811:ViewBinding-ktx:x.y.z'
}

License

Copyright (C) 2020 wada811

Licensed under the Apache License, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].