Skip to content

Instantly share code, notes, and snippets.

@plnice
Last active November 6, 2015 10:28
Show Gist options
  • Save plnice/ac9051c7bb0b2c0b57b4 to your computer and use it in GitHub Desktop.
Save plnice/ac9051c7bb0b2c0b57b4 to your computer and use it in GitHub Desktop.
Data binding & MVP
1. (IMHO lepszy, brak odniesienia do View.VISIBLE/GONE w presenterze)
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="android.view.View"/>
<variable name="user" type="com.example.UserModel"/>
<variable name="presenter" type="com.example.UserPresenter"/>
</data>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/user_name"
android:visibility="@{presenter.shouldShowUserName(user) ? View.VISIBLE : View.GONE}"/>
</layout>
2.
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="user" type="com.example.UserModel"/>
<variable name="presenter" type="com.example.UserPresenter"/>
</data>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/user_name"
android:visibility="@{presenter.getUserNameVisibility(user)}"/>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment