Making use of the Data Binding Library is a great way to increase code readability and decrease the amount of code you need to write. You will learn to use custom binding adapters, event handling, and observables to make code more clear and concise.
At the core of every great Android application is a clean and legible code base. In this course, Android Data Binding: Getting Started, you will master the core concepts of the data binding library. First, you will take a close look at how to perform data binding by inflating views, passing variables to views, and using imports. Then, you will see how to use ternary operators, build custom binding adapters, and handle gesture events. Finally, you will build custom data models that extend BaseObservable, so updates to variables are automatic. When you’re finished with this course, you will have a foundational knowledge of Data Binding that will help you as you move forward to develop mobile applications.
Course Overview Hi. My name is Mitch Tabian, and welcome to my course, Android Data Binding: Getting Started. I'm a self-employed Android developer, and I'm here to teach you about data binding with Android. Making use of the Data Binding Library is a great way to increase code readability and decrease the amount of code you need to write. As you'll see in the course, we use data binding to pass variables directly to layout files. You'll never have to write findViewById, and updates to those variables will happen automatically. Some of the major topics we'll cover include covering the basics of data binding. This will include how to install the Library, how to inflate a data-bound view, how to pass variables to views. Custom binding adapters are like custom methods for specific variables or widgets. We're going to stay very practical and build custom binding adapters for things you'll use in every application. We'll build them for things like initializing RecyclerView, setting images to ImageViews using the Glide library, and setting widget visibilities event handling. In the course, we'll implement gestures like onClickListener, onTouchListener, and a custom interface. One of the major goals of the Data Binding Library is to decrease the amount of code you write. We'll build custom data models that extend BaseObservable so updates to variables are automatic. By the end of the course, you'll have an excellent understanding of the most important concepts when it comes to data binding. Your code will be much more clear, concise, and have an overall elegant feel to it. The course is meant for beginners when it comes to data binding, but targets an intermediate developer overall. You should be very familiar with RecyclerViews, ListViews, onClick events, fragments, and setting images to ImageViews. I hope you'll join me on this journey to learn about data binding with the Android Data Binding course at Pluralsight.
Data Binding Basics In this module, we'll be exploring the Data Binding Library for Android. For the duration of the module, we'll be working with the source code files in the directory, Module_2/start/TabianGifts. You can download the source code files by navigating to the course on Pluralsight and clicking on the tab labeled Exercise Files. We're going to start off slow since the course is targeting developers with absolutely no experience with data binding. We'll start with the absolute first step, adding the Data Binding Library to your Android project. Next, we'll bind our first view to MainActivity and walk through the similarities and the differences as compared to using the mediator pattern. Right off the bat, I'm sure you'll be pleasantly surprised at how simple it is. After we've bound the first view to MainActivity, we'll work on binding a fragment. The entire application will only have a single activity, MainActivity, so we'll be using fragments extensively. If you ever feel like you need more information about fragments and how they work, I encourage you to check out my course on Pluralsight called Android Fundamentals: Implementing Effective Navigation. In the course, I talk about various types of navigation like activities, fragments, navigation views, navigation drawers, and designing a custom back-stack navigation system. In the Tabian Gifts app, we're only going to use a single activity because it makes communication between views very simple. We'll use an interface for facilitating communication, as you'll see later in the course. I don't want to talk too much about the theory before actually going into some examples, so without further ado, let's get started.
Updating Views Simultaneously with Observables The last piece of our application is the shopping cart. For the duration of the module, we'll be working with the source code files in the directory Module_6/start/TabianGifts. You can download the source code files by navigating to the course on Pluralsight and clicking on the tab labeled Exercise Files. Let's take a look at the demo application so we can clearly define what needs to be done. We already have the toolbar done. Activity_main has our CartViewModel bound to the view. It's displaying the total number of items in the cart and the total cost of the cart. Now we need to display the individual cart items in a list and then display their respective quantities. But that's not quite it. The quantities also need to be adjustable. That's what these arrows are for. When the quantities are adjusted, the TextView in the list item needs to change, the total number of items in the cart needs to be adjusted, and the total cost. So essentially, we need to update two separate views simultaneously. The update needs to be triggered by clicking on these arrows. Next, we'll implement functionality that simulates a checkout process. When a user clicks on the Checkout button in ViewCartFragment, a progress bar will start spinning in the middle of the screen, and after a designated time limit it will disappear, and the cart will be emptied.