Referencing IDs in Data Binding

13 Oct 2018 | Comments | tags: android data binding

Last week, I was talking to someone on my team and it became apparent that they weren’t aware of one super useful feature of data binding. If you know me at all, you know that I like love this library, and I would take every opportunity to spread the love around.

Let’s take a very simple example – say we have a CheckBox and a TextView in a layout file, and we want the TextView to display if the CheckBox is checked or not. I made this adorable gif to illustrate:


Cheeky!

The corresponding layout file is pretty straightforward:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <data>

    </data>
    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <CheckBox
            android:id="@+id/cheeky_checkbox"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="@string/cheeky_checkbox"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"/>
        <TextView
            android:id="@+id/textview"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:paddingTop="8dp"
            android:paddingStart="8dp"
            app:layout_constraintTop_toBottomOf="@id/cheeky_checkbox"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"/>
    </android.support.constraint.ConstraintLayout>
</layout>

Let us first define our string resource:

<string name="is_it_checked">Is it checked? %1$s</string>

where %1$s would be the checked state of the CheckBox.

All that is left is to use this string in our layout file! We can use two data binding features: String formatting, and ID referencing.

android:text="@{@string/is_it_checked(cheekyCheckbox.checked)}"

Yes, my friend – we can reference other views in our data binding expressions via their ID! Note that data binding converts IdsToCamelCase, so be sure to follow the convention.

Happy binding!


Time Check: 10 Minutes

12 Sep 2018 | Comments | tags: speaking conference

Last year, I wrote about my talk preparation process. I mentioned that I try to practice my talk verbatim a bunch of times, especially the night prior.

I have been trialling out a new strategy for my talks recently and I think it works really well.

During one of my practice runs, I keep a notepad beside me and jot down a few key slides in my talk. The more evenly-spaced out they are, the better. I then set a stopwatch (I use Timely), and start practicing.

Once I hit those slides I have written down, I put that down as a lap and jot the time down across the slide number. I keep on going until I finish the whole talk.


Keeping time (and please pardon my handwriting)

I try to do this at least twice – the more data points the better! I found out that my lap times tend to diverge +/- a minute or so on each iteration. Once I am happy with the general timing, it’s time to make the times official!

I then add the times to my speaker notes, making sure I use a BIG FONT so that it’s easy to read.


Time for a time check!

I find that having those time checks in there help make sure that I pace myself well during the actual talk. I tend to speak fast when I am nervous, so knowing that I am going at the right speed helps calm me down a bit.

I cannot rely on just the number of slides remaining, as some take longer or shorter than others (I had a slide during my talk at Mobile Refresh Wellington that took me two minutes to get through 😝). Having the time written down means I can concentrate on what I have to say without worrying about timekeeping in my head!

Bonus tip: Taking a sip of water helps calm down the nerves! Highly recommend to add “WATER BREAK! 🥛” notes as well.


Next Move

16 Mar 2018 | Comments | tags: bye

Today is my last day at Domain. After three years, seven months, and three days, it is time to move out.

I will forever be grateful to Domain for bringing me to Australia. Everyone has welcomed this tiny Filipina with open arms, helping me adjust to a new country (there were a lot of trips to the pub).


They also made me jump out of a plane

Our scrappy little app has grown so much over the years. I could never be prouder of what we have accomplished over the years.


We finally get 4.0 🌟!

We were able to share our Developer Story to the world, got a bunch of awards, get recognised as one of the best apps of the year, and launched a lot of features.


I spy with my little eye the Domain logo at Google I/O!

Since joining Domain, I have become a Google Developer Expert, vastly expanded my speaking portfolio, learnt how to bake, and most importantly, met some pretty great people. 😊

What a rollercoaster it has been!