Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Data Binding - Building Apps Faster

Android Data Binding - Building Apps Faster

We discuss about the most widely used view and resource binding library called Butter Knife. Also, we go through the MVVM pattern in conjunction with the pre package data binding library available in Android. We check how this libraries help reduce boiler plate code, minimize developer time and write unit tests faster. We will walk through the code to see the usage of the libraries and finally what care should be taken to select one over the other.

Pratyush Kshirsagar

June 23, 2016
Tweet

More Decks by Pratyush Kshirsagar

Other Decks in Programming

Transcript

  1. Why Data Binding? • Binding Views • Binding Resources •

    Enable/Disable Views • View Listeners
  2. Butter Knife • View Binding - It eliminates findViewById calls

    by using @BindView on fields. • View Lists - Can group multiple views in list of array and operate on all of them once with actions, setters or properties. • Listener Binding - Replace listeners by @OnClick. • Resource binding - Bind pre-defined resources with @BindBool, @BindColor, @BindDimen, @BindDrawable,@BindInt, @BindString
  3. Summary • Less boilerplate code to write and maintain. •

    MVVM can help us separate the business logic to some extent. • Writing unit tests is much easier. • Android Studio sometimes shows valid expressions as errors.
  4. GitHub Link and References • Please find the code on

    Github MVP using ButterKnife and MVVM using Android Data Binding. • http://jakewharton.github.io/butterknife/ • https://developer.android.com/topic/libraries/data-binding/index.html • https://youtu.be/NBbeQMOcnZ0 • https://stfalcon.com/en/blog/post/faster-android-apps-with-databinding • https://labs.ribot.co.uk/approaching-android-with-mvvm-8ceec02d5442#.o0hrhzeag • https://msdn.microsoft.com/en-us/library/hh848246.aspx