Support extension to use Android ViewBinding quickly and smooth transform from kotlin-synthetic-extension.

Overview

ViewBinding Delegate Extension

License Maven Central

Support extension to use Android ViewBinding quickly and smooth transform from kotlin-synthetic-extension. Binding instance auto wipe belong to Android UI view life cycle.

Usage

Initial binding instance

// Binding as root binding, support main view to setContentView in Activity
private val binding by viewBinding(ActivityMainBinding::inflate)

// Binding as merge tag and include in main binding
private val mergeBinding by viewBindingInclude(
    LayoutIncludeActionMergeBinding::bind,
    ::binding
)

// Binding as include an other ViewGroup
private val nonMergeBinding get() = binding.includeNonMerge

// Lazy binding by using ViewStub
private val stubBinding by viewBindingStub(
    LayoutStubActionBinding::bind,
    ::binding.select { stubAction }
)

Interacting

// Set content view and init binding
setContentView(inflate(::binding, layoutInflater, null))

// Instead of this, can using rootDelegate() to direct create view.
val rootView = rootDelegate()?.onCreateView(inflater, container)

// Same with using of normal ViewBinding
binding.txtHelloWorld.text = "It's work!"

mergeBinding.btnHitMe.setOnClickListener {
    Toast.makeText(this, "Clicked from merge binding", Toast.LENGTH_SHORT).show()
}

nonMergeBinding.btnTouchMe.setOnClickListener {
    Toast.makeText(this, "Clicked from non-merge binding", Toast.LENGTH_SHORT).show()
}

ViewStub

// ViewStubBinding will lazy bind view.
Log.d(TAG, "Stub binding initialized? = ${stubBinding.opt() != null}") // null binding instance.
stubBinding.inflate {
    // Run once on view inflated.
    btnClickMe.setOnClickListener {
        Toast.makeText(this@MainActivity, "Clicked from stub binding", Toast.LENGTH_SHORT)
            .show()
    }
}
Log.d(TAG, "Stub binding initialized? = ${stubBinding.opt() != null}") // binding initialized.

Dependency

Maven

<dependency>
  <groupId>org.cuongnv.viewbindingdelegate</groupId>
  <artifactId>viewbindingdelegate</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
</dependency>

Gradle Kotlin DSL

implementation("org.cuongnv.viewbindingdelegate:viewbindingdelegate:1.0.0")

Gradle Groovy

implementation 'org.cuongnv.viewbindingdelegate:viewbindingdelegate:1.0.0'

License

Copyright 2021 Cuong V. Nguyen (github.com/cuongnv126).

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
A library support circular imageview with rotation animation
A library support circular imageview with rotation animation

Circular Imageview with Rotate Animation This is a fast and efficient open source custom imageview for Android that allow to easy implement disc anima

AppIntroAnimation is a set of code snippets to make cool intro screen for your app with special Image Translation and Transformation animation effects. It is very easy to use and customize without adding third party library integrations.
Continuous speech recognition library for Android with options to use GoogleVoiceIme dialog and offline mode.

Android Speech Recognition This library lets you perform continuous voice recognition in your android app with options to either use Google Voice Ime

Examples of the use of animations in jetpack compose and view, as well as measurements of perfomance
Examples of the use of animations in jetpack compose and view, as well as measurements of perfomance

AndroidAnimationWorld Примеры использования анимаций в jetpack compose и view, а также замеры perfomance для

Introduction your app to the user , Easy to use and set Items as you want

Introduction App This lib helps to introduce the App-by view page based on Kotlin. Features Easy Set up Items: Title, Describe, Background, Buttons Ap

The lib can make the ActivityOptions animations use in Android api3.1+
The lib can make the ActivityOptions animations use in Android api3.1+

ActivityOptionsICS 本项目停止维护 =========== f you are thinking on customizing the animation of Activity transition then probably you would look for Activit

An android project presenting some transitions you can use between activities

ActivityTransition An android project presenting some transitions you can use between activities #Integration Add the anim folder to your Android proj

Android - Annotate methods to use as listeners for a sensor.
Android - Annotate methods to use as listeners for a sensor.

SensorAnnotations Annotate methods to use as listeners for sensor events. public class MyActivity extends Activity { /** * Perform actions as

It's a cool animation which can use in splash or somewhere else.

What's Particle ? It's a cool animation which can use in splash or anywhere else. Demo Article 手摸手教你用Canvas实现简单粒子动画 Attributes name format description

Releases(v1.0.0)
Owner
Cuong V. Nguyen
Cuong V. Nguyen
Beautiful and smooth custom loading views

mkloader Beautiful and smooth custom loading views Usage <com.tuyenmonkey.mkloader.MKLoader android:layout_width="wrap_content" an

Tuyen Nguyen 1.4k Nov 22, 2022
User onboarding library with smooth animation of objects and background colors

SlidingTutorial Cleveroad introduces Sliding Tutorial Library for Flutter Hey guys, hope you haven’t started developing a tutorial for your Flutter ap

Cleveroad 127 Dec 31, 2022
A custom smooth graph with animation

SmoothGraph A custom smooth graph with animation. Intall in progress... Sample of using in activity_main.xml <app.vazovsky.smoothgraph.SmoothGraphV

vazovsky 0 Dec 12, 2021
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures

Stfalcon ImageViewer A simple and customizable full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" g

Stfalcon LLC 1.9k Jan 5, 2023
A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.

PhotoEditor A Photo Editor library with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories. Features D

Burhanuddin Rashid 3.6k Jan 9, 2023
A Flutter plugin thats support share files to social media like TikTok, Instagram, Facebook, WhatsApp, Telegram and more others...

Social Share Kit A Flutter plugin that's support share files to social media like Tiktok, Instagram, Facebook, WhatsApp, Telegram and more. This plugi

Kaique Gazola 2 Sep 2, 2022
Deprecated in favour of https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html

Deprecated: use https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html instead. android-cubic-bezier-in

Codesoup 161 Jan 1, 2023
Support Floating Action Button transformation for Android

Fab Transformation This library supports Floating Action Button transformation in Material Design Guideline. Screenshot Sample App Installation Add th

Yusuke Konishi 772 Dec 4, 2022
Image-search - An Image search android app with offline support

image-search Image search app built using bing image search API via paging 3. Fe

Suraj Vaishnav 3 Feb 17, 2022
3D animation examples for support-v4 Fragment transition.

FragmentAnimations Animation examples for support.v4.Fragment transition. These animations do not depends on any external libraries. Usage Example In

Keita Kajiwara 1.1k Dec 14, 2022