Skip to content

Instantly share code, notes, and snippets.

@chrisbanes
Last active July 20, 2020 11:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisbanes/4a248905c5fcbdf9d5f5b4fcb33a9142 to your computer and use it in GitHub Desktop.
Save chrisbanes/4a248905c5fcbdf9d5f5b4fcb33a9142 to your computer and use it in GitHub Desktop.
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