/ViewboundController

Small Android library for the usage of ViewBindings in your Activities and Fragments without the usual boilerplate code

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

ViewboundController

GitHub release (latest by date including pre-releases) Build GitHub

Small Android library for the usage of ViewBindings in your Activities and Fragments without the usual boilerplate code

Usage

Simply pass the respective ViewBinding subclass both as type and constructor argument during the initialization of your UI controller class. The boilerplaty stuff will subsequently be taken care of and you can just use the binding in your code.

The retrieval of the respectively required inflate method is carried out by means of reflection.

  • Activity

    class YourActivity: ViewBoundActivity<YourActivityBinding>(YourActivityBinding::class.java)

    YourActivityBinding will be inflated in the onCreate lifecycle method and is thereupon accessible via the binding property

  • Fragment

    class YourFragment: ViewBoundFragment<YourFragmentBinding>(YourFragmentBinding::class.java)

    Same goes for Fragments, only that here the binding inflation happens in onCreateView. Also, the binding will be nulled in onDestroyedView to prevent memory leaks.

Installation with gradle & jitpack

implementation 'com.github.w2sv:viewboundcontroller:x.y.z'

or get the latest snapshot from a certain branch:

implementation 'com.github.w2sv:viewboundcontroller:<BRANCH-NAME>-SNAPSHOT'

License

GPL-3.0