Skip to content

Instantly share code, notes, and snippets.

View wellingtoncosta's full-sized avatar

Wellington Costa wellingtoncosta

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:id="@+id/hello_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="br.com.wellingtoncosta.databinding.playground.ui.list.ListContactsViewModel" />
<import type="android.view.View" />
<variable
name="myVariable"
type="com.example.MyClass" />
android:onClick="@{() -> viewModel.startNewContactActivity()}"
app:onRefreshListener="@{() -> viewModel.listAll()}"
app:refreshing="@{safeUnbox(viewModel.isLoading)}"
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="contact"
type="br.com.wellingtoncosta.databinding.playground.domain.Contact" />
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="contact"
type="br.com.wellingtoncosta.databinding.playground.domain.Contact" />
class ListContactsAdapter(
var contacts: List<Contact>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return ListContactsViewHolder(LayoutInflater
.from(parent.context)
.inflate(R.layout.list_contact_item, parent, false))
}
class ListContactsViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val binding: ListContactItemBinding? = DataBindingUtil.bind(view)
}
apply plugin: 'kotlin-kapt'