Instantly share code, notes, and snippets.

@chrisbanes chrisbanes/code.kt Secret
Last active Dec 31, 2018

Embed
What would you like to do?
blog_DataBinding_1
/* Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@BindingAdapter("showTitle")
fun showTitle(view: TextView, show: TiviShow) {
view.text = buildSpannedString {
inSpans(...) {
append(show.title)
}
if (show.firstAired != null) {
append(" ")
inSpans(...) {
append("(")
append(show.firstAired.year)
append(")")
}
}
}
}
<!-- Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<TextView
app:showTitle="@{viewState.show}" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment