| 1 |
<!-- |
| 2 |
Copyright (C) 2014 The Android Open Source Project |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
--> |
| 16 |
|
| 17 |
<!--DISCLAIMER: This is a demo layout showing various calculations you can make in binding |
| 18 |
expressions. It is usually a good practice to keep these expressions simple and use a ViewModel |
| 19 |
if they are getting complex.--> |
| 20 |
<layout xmlns:android="http://schemas.android.com/apk/res/android" |
| 21 |
xmlns:bind="http://schemas.android.com/apk/res-auto" |
| 22 |
xmlns:tools="http://schemas.android.com/tools"> |
| 23 |
<data> |
| 24 |
<variable name="activity" type="com.android.example.bindingdemo.MainActivity"/> |
| 25 |
<!----> |
| 26 |
<import |
| 27 |
type="android.view.View" |
| 28 |
/> |
| 29 |
<!----> |
| 30 |
<import type="com.android.example.bindingdemo.R.string" alias="Strings"/> |
| 31 |
<import type="com.android.example.bindingdemo.vo.User"/> |
| 32 |
</data> |
| 33 |
<LinearLayout |
| 34 |
android:layout_width="match_parent" |
| 35 |
android:layout_height="match_parent" |
| 36 |
android:orientation="vertical" |
| 37 |
android:paddingBottom="@dimen/activity_vertical_margin" |
| 38 |
android:paddingLeft="@dimen/activity_horizontal_margin" |
| 39 |
android:paddingRight="@dimen/activity_horizontal_margin" |
| 40 |
android:paddingTop="@dimen/activity_vertical_margin" |
| 41 |
android:id="@+id/activityRoot" |
| 42 |
tools:activity=".MainActivity" |
| 43 |
android:clickable="true" |
| 44 |
android:onClick="@{activity.onUnselect}"> |
| 45 |
<TextView |
| 46 |
android:id="@+id/title" |
| 47 |
android:layout_width="wrap_content" |
| 48 |
android:layout_height="wrap_content" |
| 49 |
android:text="@{@plurals/kittens(activity.tkAdapter.itemCount, activity.tkAdapter.itemCount)}"> |
| 50 |
|
| 51 |
</TextView> |
| 52 |
|
| 53 |
<android.support.v7.widget.RecyclerView |
| 54 |
android:id="@+id/toolkittyList" |
| 55 |
android:layout_width="match_parent" |
| 56 |
android:layout_height="@dimen/list_height" |
| 57 |
bind:adapter="@{activity.tkAdapter}" |
| 58 |
></android.support.v7.widget.RecyclerView> |
| 59 |
|
| 60 |
<View |
| 61 |
android:layout_width="match_parent" |
| 62 |
android:layout_height="10dp" /> |
| 63 |
|
| 64 |
<android.support.v7.widget.CardView |
| 65 |
android:id="@+id/selected_card" |
| 66 |
bind:contentPadding="@{activity.selected == null ? 5 : activity.selected.name.length()}" |
| 67 |
android:layout_width="match_parent" |
| 68 |
android:layout_height="wrap_content" |
| 69 |
bind:visibility="@{activity.selected == null ? View.INVISIBLE : View.VISIBLE}"> |
| 70 |
|
| 71 |
<GridLayout |
| 72 |
android:layout_width="match_parent" |
| 73 |
android:layout_height="wrap_content" |
| 74 |
android:columnCount="2" |
| 75 |
android:rowCount="4"> |
| 76 |
|
| 77 |
<ImageView |
| 78 |
android:id="@+id/selected_photo" |
| 79 |
android:layout_width="@dimen/big_user_photo" |
| 80 |
android:layout_height="@dimen/big_user_photo" |
| 81 |
android:layout_column="0" |
| 82 |
android:layout_row="0" |
| 83 |
android:layout_rowSpan="2" |
| 84 |
android:scaleType="fitCenter" |
| 85 |
android:backgroundResource="@{activity.selected.photoResource}" /> |
| 86 |
|
| 87 |
<EditText |
| 88 |
android:id="@+id/selected_name" |
| 89 |
android:layout_width="wrap_content" |
| 90 |
android:layout_height="wrap_content" |
| 91 |
android:layout_column="1" |
| 92 |
android:layout_gravity="fill" |
| 93 |
android:layout_row="0" |
| 94 |
android:background="@android:color/holo_blue_dark" |
| 95 |
android:gravity="center" |
| 96 |
android:text="@={activity.selected.name}" /> |
| 97 |
|
| 98 |
<EditText |
| 99 |
android:id="@+id/selected_lastname" |
| 100 |
android:layout_width="wrap_content" |
| 101 |
android:layout_height="wrap_content" |
| 102 |
android:layout_column="1" |
| 103 |
android:layout_gravity="fill" |
| 104 |
android:layout_row="1" |
| 105 |
android:background="@android:color/holo_blue_bright" |
| 106 |
android:gravity="center" |
| 107 |
android:text="@={activity.selected.lastName}" /> |
| 108 |
|
| 109 |
<Button |
| 110 |
android:id="@+id/delete_button" |
| 111 |
android:onClick="@{activity.onDelete}" |
| 112 |
android:text="@{activity.getString(activity.selected.group == User.KITTEN ? Strings.became_robot : Strings.became_kitten, activity.selected.name)}" |
| 113 |
android:layout_width="wrap_content" |
| 114 |
android:layout_height="wrap_content" |
| 115 |
android:layout_column="1" |
| 116 |
android:layout_gravity="right" |
| 117 |
android:layout_row="3"/> |
| 118 |
|
| 119 |
</GridLayout> |
| 120 |
</android.support.v7.widget.CardView> |
| 121 |
<View |
| 122 |
android:layout_width="match_parent" |
| 123 |
android:layout_height="10dp" /> |
| 124 |
<TextView |
| 125 |
android:layout_width="wrap_content" |
| 126 |
android:layout_height="wrap_content" |
| 127 |
android:text='@{activity.robotAdapter.itemCount + " Robots "}' /> |
| 128 |
<android.support.v7.widget.RecyclerView |
| 129 |
android:id="@+id/robotList" |
| 130 |
android:layout_width="match_parent" bind:adapter="@{activity.robotAdapter}" android:layout_height="@dimen/list_height" |
| 131 |
></android.support.v7.widget.RecyclerView> |
| 132 |
</LinearLayout> |
| 133 |
</layout> |