SupportLeanbackDemo: Add test case of ArrayObjectAdapter.replace()

b/17893479

Change-Id: Iaf91ba1ebca1237fc0d2d5629e0c2e83e15d54a0
diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseAnimationFragment.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseAnimationFragment.java
index e6b92c4..8166e6e 100644
--- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseAnimationFragment.java
+++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/BrowseAnimationFragment.java
@@ -82,7 +82,7 @@
     }
 
     Item createRandomItem() {
-        switch (sRand.nextInt(13)) {
+        switch (sRand.nextInt(14)) {
         default:
         case 0:
             return new Item("Remove Item before", new OnItemClickedListener() {
@@ -242,6 +242,20 @@
                     }
                 }
             });
+        case 13:
+            return new Item("Replace Item before", new OnItemClickedListener() {
+                    @Override
+                public void onItemClicked(Object item, Row row) {
+                    ArrayObjectAdapter adapter = ((ArrayObjectAdapter) ((ListRow) row)
+                            .getAdapter());
+                    int index = adapter.indexOf(item);
+                    if (index >= 0) {
+                        if (index > 0)
+                            index--;
+                        adapter.replace(index, createRandomItem());
+                    }
+                }
+            });
         }
     }