diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 3110274..d9ac398 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -16,6 +16,8 @@
+
diff --git a/sample/src/main/java/android/auto/value/sample/DetailActivity.java b/sample/src/main/java/android/auto/value/sample/DetailActivity.java
new file mode 100644
index 0000000..725da87
--- /dev/null
+++ b/sample/src/main/java/android/auto/value/sample/DetailActivity.java
@@ -0,0 +1,24 @@
+package android.auto.value.sample;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+import model3.Person;
+
+public class DetailActivity extends Activity {
+
+ @Override protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_detail);
+ Person person = getIntent().getParcelableExtra("Person");
+ textView(R.id.name).setText("Name:" + person.name());
+ textView(R.id.id).setText("Id:" + person.id());
+ textView(R.id.height).setText("Height:" + person.heightType());
+ textView(R.id.addresses).setText("Addresses:" + person.addresses());
+ textView(R.id.friends).setText("Friends:" + person.friends());
+ }
+
+ private TextView textView(int id) {
+ return (TextView) findViewById(id);
+ }
+}
diff --git a/sample/src/main/java/android/auto/value/sample/MainActivity.java b/sample/src/main/java/android/auto/value/sample/MainActivity.java
index 3a8430f..9502c24 100644
--- a/sample/src/main/java/android/auto/value/sample/MainActivity.java
+++ b/sample/src/main/java/android/auto/value/sample/MainActivity.java
@@ -1,8 +1,9 @@
package android.auto.value.sample;
import android.app.Activity;
+import android.content.Intent;
import android.os.Bundle;
-import android.widget.Toast;
+import android.view.View;
public class MainActivity extends Activity {
@@ -10,7 +11,12 @@ public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- Person person = Person.create("Frankie", 123);
- Toast.makeText(this, person.name(), Toast.LENGTH_SHORT).show();
+ findViewById(R.id.click_me).setOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v) {
+ Intent detailIntent = new Intent(MainActivity.this, DetailActivity.class);
+ detailIntent.putExtra("Person", SampleData.BOB);
+ startActivity(detailIntent);
+ }
+ });
}
}
diff --git a/sample/src/main/java/android/auto/value/sample/Person.java b/sample/src/main/java/android/auto/value/sample/Person.java
deleted file mode 100644
index 8528996..0000000
--- a/sample/src/main/java/android/auto/value/sample/Person.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package android.auto.value.sample;
-
-import android.auto.value.AutoValue;
-
-@AutoValue
-public abstract class Person {
- public static Person create(String name, int id) {
- return new AutoValue_Person(name, id);
- }
-
- public abstract String name();
- public abstract int id();
-}
diff --git a/sample/src/main/java/android/auto/value/sample/SampleData.java b/sample/src/main/java/android/auto/value/sample/SampleData.java
new file mode 100644
index 0000000..5f0a714
--- /dev/null
+++ b/sample/src/main/java/android/auto/value/sample/SampleData.java
@@ -0,0 +1,22 @@
+package android.auto.value.sample;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import model1.HeightBucket;
+import model2.Address;
+import model3.Person;
+
+public interface SampleData {
+
+ static final Person ALICE = Person.create("Alice", 1L, HeightBucket.AVERAGE,
+ new HashMap() {{
+ put("home", Address.create(new double[] { 0.3, 0.7 }, "Rome"));
+ }}, Collections.emptyList());
+
+ static final Person BOB = Person.create("Bob", 2L, HeightBucket.TALL,
+ new HashMap() {{
+ put("home", Address.create(new double[] { 3.2, 143.2 }, "Turin"));
+ put("work", Address.create(new double[] { 5.9, 156.1 }, "Genoa"));
+ }}, Arrays.asList(ALICE));
+}
diff --git a/sample/src/main/java/model1/HeightBucket.java b/sample/src/main/java/model1/HeightBucket.java
new file mode 100644
index 0000000..9ebac30
--- /dev/null
+++ b/sample/src/main/java/model1/HeightBucket.java
@@ -0,0 +1,5 @@
+package model1;
+
+public enum HeightBucket {
+ SHORT, AVERAGE, TALL
+}
diff --git a/sample/src/main/java/model2/Address.java b/sample/src/main/java/model2/Address.java
new file mode 100644
index 0000000..77e24c1
--- /dev/null
+++ b/sample/src/main/java/model2/Address.java
@@ -0,0 +1,14 @@
+package model2;
+
+import android.auto.value.AutoValue;
+import android.os.Parcelable;
+
+@AutoValue
+public abstract class Address implements Parcelable {
+ public abstract double[] coordinates();
+ public abstract String cityName();
+
+ public static Address create(double[] coordinates, String cityName) {
+ return new AutoValue_Address(coordinates, cityName);
+ }
+}
diff --git a/sample/src/main/java/model3/Person.java b/sample/src/main/java/model3/Person.java
new file mode 100644
index 0000000..ed3b99e
--- /dev/null
+++ b/sample/src/main/java/model3/Person.java
@@ -0,0 +1,22 @@
+package model3;
+
+import android.auto.value.AutoValue;
+import android.os.Parcelable;
+import java.util.List;
+import java.util.Map;
+import model1.HeightBucket;
+import model2.Address;
+
+@AutoValue
+public abstract class Person implements Parcelable {
+ public static Person create(String name, long id, HeightBucket heightType, Map addresses,
+ List friends) {
+ return new AutoValue_Person(name, id, heightType, addresses, friends);
+ }
+
+ public abstract String name();
+ public abstract long id();
+ public abstract HeightBucket heightType();
+ public abstract Map addresses();
+ public abstract List friends();
+}
diff --git a/sample/src/main/res/layout/activity_detail.xml b/sample/src/main/res/layout/activity_detail.xml
new file mode 100644
index 0000000..65aff3e
--- /dev/null
+++ b/sample/src/main/res/layout/activity_detail.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index 90f8dbf..19ba9bb 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -8,9 +8,10 @@
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="android.auto.value.sample.MainActivity">
-
+
diff --git a/sample/src/main/res/menu/main.xml b/sample/src/main/res/menu/main.xml
deleted file mode 100644
index d0b4120..0000000
--- a/sample/src/main/res/menu/main.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 6edfe27..dbb3784 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -1,8 +1,4 @@
-
- android-auto-value
- Hello world!
- Settings
-
+ android-auto-value