Android view data binding made simple!

Overview

DataBinding

Android view data binding made simple!

A more user friendly docu is coming! This library doesn't use any external library, so it's light weight and dependencies free.

Example usages:

Example model classes:

data class User {

    val name: String

    val photo: Photo
    
    val action: IViewAction

}

data class Photo {

    val url: String

}

View class: annotate the subviews in order to specify, for each model you want to bind, a path to find the parameter to bind.

@BindableView
@BindAction(["User.action"])
class UserView: ConstraintLayout {

    @BindWith(paths = ["User.text:String"])
    val text: TextView
    @BindAction(["User.action])
    @BindWith(paths = ["User.photo.url:String"])
    val image: ImageView

    // Constructors...
    init(@NonNull Context context) {
        ...
    }

}

Everywhere you want, define a static method to bind a custom view - data model pair. You can annotate parameters with @Inject in order to provide dependency to your components, it will be injected in the DataBinding constructor.

@BindingMethod
@JvmStatic
fun bindUser(@View userView: UserView?, @Data user: User?, @Inject sharedPreferences: SharedPreferences?) {
    // do whatever you want
}

@BindingMethod
public static void bindText(@View view: TextView?, @Data text: String?) {
    // do whatever you want, for example view.setText(text);
}

To bind all yopu view tree now you only have to get a DataBinding instance and call bind(..) with your parameters, using the overloading. The library also enables to display different objects in RecyclerViews. Annotate your custom views with @BindableView, the objects to display with @BindableObject(CustomView.class), and in both implement respectively IView and IData interfaces, returning the simple class name of each. Then use GenericRecyclerViewAdapter with the AdapterDatabinding and ViewFactory generated classes. To enable compatibility with Kotlin, if you use this library with Java you must implement getter methods for all yur views and data model. In Kotlin these are by default availables.

You might also like...
A simple project used for converting currencies

MyCurrencyConverter A simple project used for converting currencies. This project is divided into 2 parts (branches): master - without Dagger Hilt dev

A simple list-detail application using the Github API

GitHub Users Search Android application to search users via GitHub API Project demonstrates how to use Kotlin, Android Architecture Components, Dagger

A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.

Android Architecture Blueprints v2 Android Architecture Blueprints is a project to showcase different architectural approaches to developing Android a

Android Viper template with Kotlin, Dagger 2, Retrofit & RxJava
Android Viper template with Kotlin, Dagger 2, Retrofit & RxJava

Android VIPER Architecture Example This repository contains a detailed sample client-server app that implements VIPER(View-Interactor-Presenter-Entity

Learn How to use Google Map API for Android from Basic to Advance with complete examples.

Complete-Google-Map-API-Tutorial Learn How to use Google Map API for Android from Basic to Advance. Satellite View 3D Building Map and StreetView Lear

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Saga of Star wars - An Android sample repo showcasing Clean Arch with MVVM and Epoxy models
Saga of Star wars - An Android sample repo showcasing Clean Arch with MVVM and Epoxy models

Star Wars Universe This is a showcase android application written in Kotlin and follows Clean Code architecture to showcase Characters from the StarWa

This is an example implementation of android accessibility services with 5 Sample Actions
This is an example implementation of android accessibility services with 5 Sample Actions

Android Accessibility Services Example This is an example implementation of android accessibility services with 5 Sample Actions such as: Simulate Pow

📌This repo contains the kotlin implementation of TensorflowLite Example Android Apps🚀

TensorflowLite Examples Kotlin This repo contains the kotlin implementation of TensorflowLite Example Apps here, which are mostly implemented in java

Releases(1.2.1)
Owner
Giovanni Corte
Giovanni Corte
This application features - Modern Minimalistic Design, MVVM, Pagination, Hilt, Retrofit, Room, Data Store, Flow, Live Data, Navigation Component (Clean Architecture)

NewsFly NewsFly is a modern news android application which features virtually ALL recent and recommended android development tech stack and tools used

Ibrahim 121 Nov 4, 2022
Starter code for Android Basics codelab - Store the data in a ViewModel

Unscramble App Starter code for Android Basics codelab - Store the data in a ViewModel Unscramble is a single player game app that displays scrambled

null 0 Nov 1, 2021
This is An Android Project. in which we use SqLite Database. We perform Insert,delete,update and Show The existing data. operations using SqLite.

SqLite Database Keywords : SqLite, Android, Database This is An Android Project. in which we use SqLite Database. We perform Insert,delete,update and

Rudra_deep 1 Nov 7, 2021
Starter code for Android Kotlin Fundamentals Codelab 8.1 Getting data from the internet

MarsRealEstate - Starter Code Starter code for Android Kotlin Fundamentals Codelab 8.1 Getting data from the internet Introduction MarsRealEstate is a

null 0 Dec 14, 2021
This example was built for lecturing proposes, it shows how to consume data from an API.

Android Kotlin NewsMobEDJDCM2122 Example - EDJD 2021/2022 This example was wirten during the Mobile Computing lectures in the course 'Lincentura em En

null 0 Nov 8, 2021
MVVM(Model View ViewModel) sample in Kotlin using the components ViewModel, LiveData and Retrofit library

kotlin-mvvm Languages: English, Spanish MVVM(Model View ViewModel) sample in Kotlin using the components ViewModel, LiveData, the libraries Retrofit,

Eduardo José Medina Alfaro 466 Jan 5, 2023
simple projet for implementation detekt for android

Simple DETEKT implementation others KTLint DeteKT Spotless gradle-code-quality-tools-plugin Tutorials medium Config detekt config.yml Gradle Build Scr

John Alves 0 Jun 10, 2022
A simple android sound recorder which let's users record audio and listen to it

Android-Sound-Recorder A simple android sound recorder which let's users record audio and listen to it. Getting started To get started just clone or f

Nisa Jamalia Nurhayati 0 Nov 4, 2021
The simple app is to demonstrate how the modern Enterprise Android App Architecture should be

Weather Forecast App The simple app is to demonstrate how the modern Enterprise Android App Architecture should be. Clean Architecture (Mr Uncle Bob)

null 2 Nov 12, 2021
This is a simple application through which I connected Students, Courses and Teachers in an a beautiful way. The main purpose of this project is the connection between the Objects.

UniversityApp This is a simple application through which I connected Students, Courses and Teachers in an a beautiful way. The main purpose of this pr

Anas Khalil 3 Aug 21, 2021