Clean up ItemList-related API
- ItemList.getItemList() returns List<Item> instead of List<Object>
- Pane.getRowList() returns List<Row> instead of List<Object>
- SecionedItemList now takes CharSequence instead of CarText
- ListTemplate.addList is repalced by ListTemplate.addSectionedList(SectionedItemList)
- ItemList.Builder.clearItems is removed to be consistent with other builders.
Relnote: n/a
Bug: 177591128
Test: ./gradlew :car:app:app:test
Change-Id: I525da84b3ca5179e05969354fc86c01da2170145
diff --git a/car/app/app/api/current.txt b/car/app/app/api/current.txt
index 3b3a9a4..24c590f 100644
--- a/car/app/app/api/current.txt
+++ b/car/app/app/api/current.txt
@@ -378,7 +378,8 @@
public final class ItemList {
method public static androidx.car.app.model.ItemList.Builder builder();
- method public java.util.List<java.lang.Object!> getItems();
+ method public java.util.List<androidx.car.app.model.Item!> getItemList();
+ method @Deprecated public java.util.List<java.lang.Object!> getItems();
method public androidx.car.app.model.CarText? getNoItemsMessage();
method public androidx.car.app.model.OnItemVisibilityChangedListenerWrapper? getOnItemsVisibilityChangedListener();
method public androidx.car.app.model.OnSelectedListenerWrapper? getOnSelectedListener();
@@ -389,7 +390,6 @@
ctor public ItemList.Builder();
method public androidx.car.app.model.ItemList.Builder addItem(androidx.car.app.model.Item);
method public androidx.car.app.model.ItemList build();
- method public androidx.car.app.model.ItemList.Builder clearItems();
method public androidx.car.app.model.ItemList.Builder setNoItemsMessage(CharSequence?);
method public androidx.car.app.model.ItemList.Builder setOnItemsVisibilityChangedListener(androidx.car.app.model.ItemList.OnItemVisibilityChangedListener?);
method public androidx.car.app.model.ItemList.Builder setOnSelectedListener(androidx.car.app.model.ItemList.OnSelectedListener?);
@@ -415,14 +415,16 @@
method public static androidx.car.app.model.ListTemplate.Builder builder();
method public androidx.car.app.model.ActionStrip? getActionStrip();
method public androidx.car.app.model.Action? getHeaderAction();
- method public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionLists();
+ method @Deprecated public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionLists();
+ method public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionedLists();
method public androidx.car.app.model.ItemList? getSingleList();
method public androidx.car.app.model.CarText? getTitle();
method public boolean isLoading();
}
public static final class ListTemplate.Builder {
- method public androidx.car.app.model.ListTemplate.Builder addList(androidx.car.app.model.ItemList, CharSequence);
+ method @Deprecated public androidx.car.app.model.ListTemplate.Builder addList(androidx.car.app.model.ItemList, CharSequence);
+ method public androidx.car.app.model.ListTemplate.Builder addSectionedList(androidx.car.app.model.SectionedItemList);
method public androidx.car.app.model.ListTemplate build();
method public androidx.car.app.model.ListTemplate.Builder setActionStrip(androidx.car.app.model.ActionStrip?);
method public androidx.car.app.model.ListTemplate.Builder setHeaderAction(androidx.car.app.model.Action?);
@@ -495,7 +497,8 @@
method public static androidx.car.app.model.Pane.Builder builder();
method public java.util.List<androidx.car.app.model.Action!> getActionList();
method @Deprecated public androidx.car.app.model.ActionList? getActions();
- method public java.util.List<java.lang.Object!> getRows();
+ method public java.util.List<androidx.car.app.model.Row!> getRowList();
+ method @Deprecated public java.util.List<java.lang.Object!> getRows();
method public boolean isLoading();
}
@@ -653,7 +656,8 @@
}
public class SectionedItemList {
- method public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, androidx.car.app.model.CarText);
+ method @Deprecated public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, androidx.car.app.model.CarText);
+ method public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, CharSequence);
method public androidx.car.app.model.CarText getHeader();
method public androidx.car.app.model.ItemList getItemList();
}
diff --git a/car/app/app/api/public_plus_experimental_current.txt b/car/app/app/api/public_plus_experimental_current.txt
index 3b3a9a4..24c590f 100644
--- a/car/app/app/api/public_plus_experimental_current.txt
+++ b/car/app/app/api/public_plus_experimental_current.txt
@@ -378,7 +378,8 @@
public final class ItemList {
method public static androidx.car.app.model.ItemList.Builder builder();
- method public java.util.List<java.lang.Object!> getItems();
+ method public java.util.List<androidx.car.app.model.Item!> getItemList();
+ method @Deprecated public java.util.List<java.lang.Object!> getItems();
method public androidx.car.app.model.CarText? getNoItemsMessage();
method public androidx.car.app.model.OnItemVisibilityChangedListenerWrapper? getOnItemsVisibilityChangedListener();
method public androidx.car.app.model.OnSelectedListenerWrapper? getOnSelectedListener();
@@ -389,7 +390,6 @@
ctor public ItemList.Builder();
method public androidx.car.app.model.ItemList.Builder addItem(androidx.car.app.model.Item);
method public androidx.car.app.model.ItemList build();
- method public androidx.car.app.model.ItemList.Builder clearItems();
method public androidx.car.app.model.ItemList.Builder setNoItemsMessage(CharSequence?);
method public androidx.car.app.model.ItemList.Builder setOnItemsVisibilityChangedListener(androidx.car.app.model.ItemList.OnItemVisibilityChangedListener?);
method public androidx.car.app.model.ItemList.Builder setOnSelectedListener(androidx.car.app.model.ItemList.OnSelectedListener?);
@@ -415,14 +415,16 @@
method public static androidx.car.app.model.ListTemplate.Builder builder();
method public androidx.car.app.model.ActionStrip? getActionStrip();
method public androidx.car.app.model.Action? getHeaderAction();
- method public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionLists();
+ method @Deprecated public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionLists();
+ method public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionedLists();
method public androidx.car.app.model.ItemList? getSingleList();
method public androidx.car.app.model.CarText? getTitle();
method public boolean isLoading();
}
public static final class ListTemplate.Builder {
- method public androidx.car.app.model.ListTemplate.Builder addList(androidx.car.app.model.ItemList, CharSequence);
+ method @Deprecated public androidx.car.app.model.ListTemplate.Builder addList(androidx.car.app.model.ItemList, CharSequence);
+ method public androidx.car.app.model.ListTemplate.Builder addSectionedList(androidx.car.app.model.SectionedItemList);
method public androidx.car.app.model.ListTemplate build();
method public androidx.car.app.model.ListTemplate.Builder setActionStrip(androidx.car.app.model.ActionStrip?);
method public androidx.car.app.model.ListTemplate.Builder setHeaderAction(androidx.car.app.model.Action?);
@@ -495,7 +497,8 @@
method public static androidx.car.app.model.Pane.Builder builder();
method public java.util.List<androidx.car.app.model.Action!> getActionList();
method @Deprecated public androidx.car.app.model.ActionList? getActions();
- method public java.util.List<java.lang.Object!> getRows();
+ method public java.util.List<androidx.car.app.model.Row!> getRowList();
+ method @Deprecated public java.util.List<java.lang.Object!> getRows();
method public boolean isLoading();
}
@@ -653,7 +656,8 @@
}
public class SectionedItemList {
- method public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, androidx.car.app.model.CarText);
+ method @Deprecated public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, androidx.car.app.model.CarText);
+ method public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, CharSequence);
method public androidx.car.app.model.CarText getHeader();
method public androidx.car.app.model.ItemList getItemList();
}
diff --git a/car/app/app/api/restricted_current.txt b/car/app/app/api/restricted_current.txt
index 3b3a9a4..24c590f 100644
--- a/car/app/app/api/restricted_current.txt
+++ b/car/app/app/api/restricted_current.txt
@@ -378,7 +378,8 @@
public final class ItemList {
method public static androidx.car.app.model.ItemList.Builder builder();
- method public java.util.List<java.lang.Object!> getItems();
+ method public java.util.List<androidx.car.app.model.Item!> getItemList();
+ method @Deprecated public java.util.List<java.lang.Object!> getItems();
method public androidx.car.app.model.CarText? getNoItemsMessage();
method public androidx.car.app.model.OnItemVisibilityChangedListenerWrapper? getOnItemsVisibilityChangedListener();
method public androidx.car.app.model.OnSelectedListenerWrapper? getOnSelectedListener();
@@ -389,7 +390,6 @@
ctor public ItemList.Builder();
method public androidx.car.app.model.ItemList.Builder addItem(androidx.car.app.model.Item);
method public androidx.car.app.model.ItemList build();
- method public androidx.car.app.model.ItemList.Builder clearItems();
method public androidx.car.app.model.ItemList.Builder setNoItemsMessage(CharSequence?);
method public androidx.car.app.model.ItemList.Builder setOnItemsVisibilityChangedListener(androidx.car.app.model.ItemList.OnItemVisibilityChangedListener?);
method public androidx.car.app.model.ItemList.Builder setOnSelectedListener(androidx.car.app.model.ItemList.OnSelectedListener?);
@@ -415,14 +415,16 @@
method public static androidx.car.app.model.ListTemplate.Builder builder();
method public androidx.car.app.model.ActionStrip? getActionStrip();
method public androidx.car.app.model.Action? getHeaderAction();
- method public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionLists();
+ method @Deprecated public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionLists();
+ method public java.util.List<androidx.car.app.model.SectionedItemList!> getSectionedLists();
method public androidx.car.app.model.ItemList? getSingleList();
method public androidx.car.app.model.CarText? getTitle();
method public boolean isLoading();
}
public static final class ListTemplate.Builder {
- method public androidx.car.app.model.ListTemplate.Builder addList(androidx.car.app.model.ItemList, CharSequence);
+ method @Deprecated public androidx.car.app.model.ListTemplate.Builder addList(androidx.car.app.model.ItemList, CharSequence);
+ method public androidx.car.app.model.ListTemplate.Builder addSectionedList(androidx.car.app.model.SectionedItemList);
method public androidx.car.app.model.ListTemplate build();
method public androidx.car.app.model.ListTemplate.Builder setActionStrip(androidx.car.app.model.ActionStrip?);
method public androidx.car.app.model.ListTemplate.Builder setHeaderAction(androidx.car.app.model.Action?);
@@ -495,7 +497,8 @@
method public static androidx.car.app.model.Pane.Builder builder();
method public java.util.List<androidx.car.app.model.Action!> getActionList();
method @Deprecated public androidx.car.app.model.ActionList? getActions();
- method public java.util.List<java.lang.Object!> getRows();
+ method public java.util.List<androidx.car.app.model.Row!> getRowList();
+ method @Deprecated public java.util.List<java.lang.Object!> getRows();
method public boolean isLoading();
}
@@ -653,7 +656,8 @@
}
public class SectionedItemList {
- method public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, androidx.car.app.model.CarText);
+ method @Deprecated public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, androidx.car.app.model.CarText);
+ method public static androidx.car.app.model.SectionedItemList create(androidx.car.app.model.ItemList, CharSequence);
method public androidx.car.app.model.CarText getHeader();
method public androidx.car.app.model.ItemList getItemList();
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/GridTemplate.java b/car/app/app/src/main/java/androidx/car/app/model/GridTemplate.java
index e0b81fc..f9f327d 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/GridTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/GridTemplate.java
@@ -168,10 +168,10 @@
* Sets whether the template is in a loading state.
*
* <p>If set to {@code true}, the UI shows a loading indicator where the grid content
- * would be
- * otherwise. The caller is expected to call {@link androidx.car.app.Screen#invalidate()}
- * and send the new template content to the host once the data is ready. If set to {@code
- * false}, the UI shows the {@link ItemList} contents added via {@link #setSingleList}.
+ * would be otherwise. The caller is expected to call
+ * {@link androidx.car.app.Screen#invalidate()} and send the new template content to the
+ * host once the data is ready. If set to {@code false}, the UI shows the
+ * {@link ItemList} contents added via {@link #setSingleList}.
*/
@NonNull
public Builder setLoading(boolean isLoading) {
@@ -181,8 +181,7 @@
/**
* Sets the {@link Action} that will be displayed in the header of the template, or
- * {@code null}
- * to not display an action.
+ * {@code null} to not display an action.
*
* <h4>Requirements</h4>
*
@@ -227,8 +226,7 @@
*
* This template allows up to 2 {@link Action}s in its {@link ActionStrip}. Of the 2 allowed
* {@link Action}s, one of them can contain a title as set via
- * {@link Action.Builder#setTitle}.
- * Otherwise, only {@link Action}s with icons are allowed.
+ * {@link Action.Builder#setTitle}. Otherwise, only {@link Action}s with icons are allowed.
*
* @throws IllegalArgumentException if {@code actionStrip} does not meet the requirements.
*/
@@ -263,14 +261,11 @@
* <p>Either a header {@link Action} or title must be set on the template.
*
* @throws IllegalStateException if the template is in a loading state but there are
- * lists
- * added, or vice versa.
+ * lists added, or vice versa.
* @throws IllegalArgumentException if the added {@link ItemList} does not meet the
- * template's
- * requirements.
+ * template's requirements.
* @throws IllegalStateException if the template does not have either a title or header
- * {@link
- * Action} set.
+ * {@link Action} set.
*/
@NonNull
public GridTemplate build() {
@@ -281,7 +276,7 @@
}
if (mSingleList != null) {
- for (Object gridItemObject : mSingleList.getItems()) {
+ for (Item gridItemObject : mSingleList.getItemList()) {
if (!(gridItemObject instanceof GridItem)) {
throw new IllegalArgumentException(
"All the items in grid template's item list must be grid items");
diff --git a/car/app/app/src/main/java/androidx/car/app/model/ItemList.java b/car/app/app/src/main/java/androidx/car/app/model/ItemList.java
index efb4ea9..9346399 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/ItemList.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/ItemList.java
@@ -74,7 +74,7 @@
@Keep
private final int mSelectedIndex;
@Keep
- private final List<Object> mItems;
+ private final List<Item> mItems;
@Keep
@Nullable
private final OnSelectedListenerWrapper mOnSelectedListener;
@@ -121,9 +121,23 @@
return mOnItemVisibilityChangedListener;
}
- /** Returns the list of items in this {@link ItemList}. */
+ /**
+ * Returns the list of items in this {@link ItemList}.
+ *
+ * @deprecated use {@link #getItemList()} instead.
+ */
+ // TODO(b/177591128): remove after host(s) no longer reference this.
+ @SuppressWarnings("unchecked")
+ @Deprecated
@NonNull
public List<Object> getItems() {
+ return (List<Object>) (List<? extends Object>) mItems;
+ }
+
+ /** Returns the list of items. */
+ // TODO(b/177591128): rename back to getItems after removal of the deprecated API.
+ @NonNull
+ public List<Item> getItemList() {
return mItems;
}
@@ -187,7 +201,7 @@
@Nullable
- static OnClickListenerWrapper getOnClickListener(Object item) {
+ static OnClickListenerWrapper getOnClickListener(Item item) {
if (item instanceof Row) {
return ((Row) item).getOnClickListener();
} else if (item instanceof GridItem) {
@@ -198,7 +212,7 @@
}
@Nullable
- static Toggle getToggle(Object item) {
+ static Toggle getToggle(Item item) {
if (item instanceof Row) {
return ((Row) item).getToggle();
}
@@ -208,7 +222,7 @@
/** A builder of {@link ItemList}. */
public static final class Builder {
- final List<Object> mItems = new ArrayList<>();
+ final List<Item> mItems = new ArrayList<>();
int mSelectedIndex;
@Nullable
OnSelectedListenerWrapper mOnSelectedListener;
@@ -302,13 +316,6 @@
return this;
}
- /** Clears any items that may have been added up to this point. */
- @NonNull
- public Builder clearItems() {
- mItems.clear();
- return this;
- }
-
/**
* Constructs the item list defined by this builder.
*
@@ -334,7 +341,7 @@
}
// Check that no items have disallowed elements if the list is selectable.
- for (Object item : mItems) {
+ for (Item item : mItems) {
if (getOnClickListener(item) != null) {
throw new IllegalStateException(
"Items that belong to selectable lists can't have an "
diff --git a/car/app/app/src/main/java/androidx/car/app/model/ListTemplate.java b/car/app/app/src/main/java/androidx/car/app/model/ListTemplate.java
index e8520f6..21d2dd2 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/ListTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/ListTemplate.java
@@ -67,7 +67,7 @@
@Nullable
private final ItemList mSingleList;
@Keep
- private final List<SectionedItemList> mSectionLists;
+ private final List<SectionedItemList> mSectionedLists;
@Keep
@Nullable
private final ActionStrip mActionStrip;
@@ -98,9 +98,19 @@
return mSingleList;
}
+ /**
+ * @deprecated use {@link #getSectionedLists()} instead.
+ */
+ // TODO(b/177591128): remove after host(s) no longer reference this.
+ @Deprecated
@NonNull
public List<SectionedItemList> getSectionLists() {
- return mSectionLists;
+ return mSectionedLists;
+ }
+
+ @NonNull
+ public List<SectionedItemList> getSectionedLists() {
+ return mSectionedLists;
}
@Nullable
@@ -116,7 +126,7 @@
@Override
public int hashCode() {
- return Objects.hash(mIsLoading, mTitle, mHeaderAction, mSingleList, mSectionLists,
+ return Objects.hash(mIsLoading, mTitle, mHeaderAction, mSingleList, mSectionedLists,
mActionStrip);
}
@@ -134,7 +144,7 @@
&& Objects.equals(mTitle, otherTemplate.mTitle)
&& Objects.equals(mHeaderAction, otherTemplate.mHeaderAction)
&& Objects.equals(mSingleList, otherTemplate.mSingleList)
- && Objects.equals(mSectionLists, otherTemplate.mSectionLists)
+ && Objects.equals(mSectionedLists, otherTemplate.mSectionedLists)
&& Objects.equals(mActionStrip, otherTemplate.mActionStrip);
}
@@ -143,7 +153,7 @@
mTitle = builder.mTitle;
mHeaderAction = builder.mHeaderAction;
mSingleList = builder.mSingleList;
- mSectionLists = CollectionUtils.unmodifiableCopy(builder.mSectionLists);
+ mSectionedLists = CollectionUtils.unmodifiableCopy(builder.mSectionedLists);
mActionStrip = builder.mActionStrip;
}
@@ -153,7 +163,7 @@
mTitle = null;
mHeaderAction = null;
mSingleList = null;
- mSectionLists = Collections.emptyList();
+ mSectionedLists = Collections.emptyList();
mActionStrip = null;
}
@@ -162,7 +172,7 @@
boolean mIsLoading;
@Nullable
ItemList mSingleList;
- final List<SectionedItemList> mSectionLists = new ArrayList<>();
+ final List<SectionedItemList> mSectionedLists = new ArrayList<>();
@Nullable
CarText mTitle;
@Nullable
@@ -231,7 +241,7 @@
@NonNull
public Builder setSingleList(@NonNull ItemList list) {
mSingleList = requireNonNull(list);
- mSectionLists.clear();
+ mSectionedLists.clear();
mHasSelectableList = false;
return this;
}
@@ -254,34 +264,63 @@
* @throws NullPointerException if {@code header} is null.
* @throws IllegalArgumentException if {@code header} is empty.
* @throws IllegalArgumentException if a selectable list is added alongside other lists.
+ *
+ * @deprecated use {@link #addSectionedList} instead.
*/
+ // TODO(b/177591128): remove after host(s) no longer reference this.
+ @Deprecated
@NonNull
// TODO(shiufai): consider rename to match getter's name.
@SuppressLint("MissingGetterMatchingBuilder")
public Builder addList(@NonNull ItemList list, @NonNull CharSequence header) {
- if (requireNonNull(header).length() == 0) {
+ return addSectionedList(SectionedItemList.create(list, header));
+ }
+
+ /**
+ * Adds an {@link SectionedItemList} to display in the template.
+ *
+ * <p>Use this method to add multiple lists to the template. Each
+ * {@link SectionedItemList} will be grouped under its header. These lists cannot be
+ * mixed with an {@link ItemList} added via {@link #setSingleList}. If a single list was
+ * previously added, it will be cleared.
+ *
+ * <p>If the added {@link SectionedItemList} contains a
+ * {@link ItemList.OnSelectedListener}, then it cannot be added alongside other
+ * {@link SectionedItemList}(s).
+ *
+ * @throws NullPointerException if {@code list} is null.
+ * @throws IllegalArgumentException if {@code list} is empty.
+ * @throws IllegalArgumentException if {@code list}'s {@link
+ * ItemList.OnItemVisibilityChangedListener} is set.
+ * @throws NullPointerException if {@code header} is null.
+ * @throws IllegalArgumentException if {@code header} is empty.
+ * @throws IllegalArgumentException if a selectable list is added alongside other lists.
+ */
+ @NonNull
+ public Builder addSectionedList(@NonNull SectionedItemList list) {
+ if (requireNonNull(list).getHeader().getText().length() == 0) {
throw new IllegalArgumentException("Header cannot be empty");
}
- CarText headerText = CarText.create(header);
- boolean isSelectableList = list.getOnSelectedListener() != null;
- if (mHasSelectableList || (isSelectableList && !mSectionLists.isEmpty())) {
+ ItemList itemList = list.getItemList();
+ boolean isSelectableList = itemList.getOnSelectedListener() != null;
+ if (mHasSelectableList || (isSelectableList && !mSectionedLists.isEmpty())) {
throw new IllegalArgumentException(
"A selectable list cannot be added alongside any other lists");
}
mHasSelectableList = isSelectableList;
- if (list.getItems().isEmpty()) {
+ if (itemList.getItemList().isEmpty()) {
throw new IllegalArgumentException("List cannot be empty");
}
- if (list.getOnItemsVisibilityChangedListener() != null) {
+ if (itemList.getOnItemsVisibilityChangedListener() != null) {
throw new IllegalArgumentException(
"OnItemVisibilityChangedListener in the list is disallowed");
}
mSingleList = null;
- mSectionLists.add(SectionedItemList.create(list, headerText));
+ mSectionedLists.add(list);
return this;
}
@@ -325,15 +364,15 @@
*/
@NonNull
public ListTemplate build() {
- boolean hasList = mSingleList != null || !mSectionLists.isEmpty();
+ boolean hasList = mSingleList != null || !mSectionedLists.isEmpty();
if (mIsLoading == hasList) {
throw new IllegalStateException(
"Template is in a loading state but lists are added, or vice versa");
}
if (hasList) {
- if (!mSectionLists.isEmpty()) {
- ROW_LIST_CONSTRAINTS_FULL_LIST.validateOrThrow(mSectionLists);
+ if (!mSectionedLists.isEmpty()) {
+ ROW_LIST_CONSTRAINTS_FULL_LIST.validateOrThrow(mSectionedLists);
} else if (mSingleList != null) {
ROW_LIST_CONSTRAINTS_FULL_LIST.validateOrThrow(mSingleList);
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java b/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java
index 0a5e10c..1d790d3 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/ModelUtils.java
@@ -39,13 +39,17 @@
* Checks whether all non-browsable rows have attached at least one {@link DistanceSpan} in
* either the title or secondary text.
*
+ * @throws IllegalArgumentException if the input list contains any non-Row instances.
* @throws IllegalArgumentException if any non-browsable row does not have a
* {@link DistanceSpan} instance.
*/
- public static void validateAllNonBrowsableRowsHaveDistance(@NonNull List<Object> rows) {
+ public static void validateAllNonBrowsableRowsHaveDistance(@NonNull List<Item> rows) {
int spanSetCount = 0;
int nonBrowsableRowCount = 0;
- for (Object rowObj : rows) {
+ for (Item rowObj : rows) {
+ if (!(rowObj instanceof Row)) {
+ throw new IllegalArgumentException("Item in the list is not a Row.");
+ }
Row row = (Row) rowObj;
if (!row.isBrowsable()) {
@@ -68,11 +72,15 @@
* Checks whether all rows have attached at least one {@link DurationSpan} or
* {@link DistanceSpan }in either the title or secondary text.
*
+ * @throws IllegalArgumentException if the input list contains any non-Row instances.
* @throws IllegalArgumentException if any non-browsable row does not have either a {@link
* DurationSpan} or {@link DistanceSpan} instance.
*/
- public static void validateAllRowsHaveDistanceOrDuration(@NonNull List<Object> rows) {
- for (Object rowObj : rows) {
+ public static void validateAllRowsHaveDistanceOrDuration(@NonNull List<Item> rows) {
+ for (Item rowObj : rows) {
+ if (!(rowObj instanceof Row)) {
+ throw new IllegalArgumentException("Item in the list is not a Row.");
+ }
Row row = (Row) rowObj;
if (!(checkRowHasSpanType(row, DistanceSpan.class)
|| checkRowHasSpanType(row, DurationSpan.class))) {
@@ -87,11 +95,15 @@
/**
* Checks whether all rows have only small-sized images if they are set.
*
+ * @throws IllegalArgumentException if the input list contains any non-Row instances.
* @throws IllegalArgumentException if an image set in any rows is using {@link
* Row#IMAGE_TYPE_LARGE}.
*/
- public static void validateAllRowsHaveOnlySmallImages(@NonNull List<Object> rows) {
- for (Object rowObj : rows) {
+ public static void validateAllRowsHaveOnlySmallImages(@NonNull List<Item> rows) {
+ for (Item rowObj : rows) {
+ if (!(rowObj instanceof Row)) {
+ throw new IllegalArgumentException("Item in the list is not a Row.");
+ }
Row row = (Row) rowObj;
if (row.getImage() != null && row.getRowImageType() == Row.IMAGE_TYPE_LARGE) {
throw new IllegalArgumentException("Rows must only use small-sized images");
@@ -102,10 +114,14 @@
/**
* Checks whether any rows have both a marker and an image.
*
+ * @throws IllegalArgumentException if the input list contains any non-Row instances.
* @throws IllegalArgumentException if both a marker and an image are set in a row.
*/
- public static void validateNoRowsHaveBothMarkersAndImages(@NonNull List<Object> rows) {
- for (Object rowObj : rows) {
+ public static void validateNoRowsHaveBothMarkersAndImages(@NonNull List<Item> rows) {
+ for (Item rowObj : rows) {
+ if (!(rowObj instanceof Row)) {
+ throw new IllegalArgumentException("Item in the list is not a Row.");
+ }
Row row = (Row) rowObj;
boolean hasImage = row.getImage() != null;
diff --git a/car/app/app/src/main/java/androidx/car/app/model/Pane.java b/car/app/app/src/main/java/androidx/car/app/model/Pane.java
index 33eef43..e0e91e3 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/Pane.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/Pane.java
@@ -36,7 +36,7 @@
@Keep
private final List<Action> mActionList;
@Keep
- private final List<Object> mRows;
+ private final List<Row> mRows;
@Keep
private final boolean mIsLoading;
@@ -69,9 +69,23 @@
/**
* Returns the list of {@link Row} objects that make up the {@link Pane}.
+ *
+ * @deprecated use {@link #getRowList()} ()} instead.
*/
+ // TODO(b/177591128): remove after host(s) no longer reference this.
+ @SuppressWarnings("unchecked")
+ @Deprecated
@NonNull
public List<Object> getRows() {
+ return (List<Object>) (List<?>) mRows;
+ }
+
+ /**
+ * Returns the list of {@link Row} objects that make up the {@link Pane}.
+ */
+ // TODO(b/177591128): rename back to getRows after removal of the deprecated API.
+ @NonNull
+ public List<Row> getRowList() {
return mRows;
}
@@ -127,7 +141,7 @@
/** A builder of {@link Pane}. */
public static final class Builder {
- final List<Object> mRows = new ArrayList<>();
+ final List<Row> mRows = new ArrayList<>();
List<Action> mActionList = new ArrayList<>();
boolean mIsLoading;
diff --git a/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java b/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java
index 34d4fd4..71a04c3 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/PlaceListMapTemplate.java
@@ -267,7 +267,7 @@
@NonNull
public Builder setItemList(@Nullable ItemList itemList) {
if (itemList != null) {
- List<Object> items = itemList.getItems();
+ List<Item> items = itemList.getItemList();
ROW_LIST_CONSTRAINTS_SIMPLE.validateOrThrow(itemList);
ModelUtils.validateAllNonBrowsableRowsHaveDistance(items);
ModelUtils.validateAllRowsHaveOnlySmallImages(items);
diff --git a/car/app/app/src/main/java/androidx/car/app/model/SectionedItemList.java b/car/app/app/src/main/java/androidx/car/app/model/SectionedItemList.java
index b9ce5b9..c06189c 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/SectionedItemList.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/SectionedItemList.java
@@ -38,13 +38,28 @@
/**
* Creates an instance of a {@link SectionedItemList} with the given {@code itemList} and
* {@code sectionHeader}.
+ *
+ * @deprecated use {@link #create(ItemList, CharSequence)} ()} instead.
*/
+ // TODO(b/177591128): remove after host(s) no longer reference this.
+ @Deprecated
@NonNull
public static SectionedItemList create(
@NonNull ItemList itemList, @NonNull CarText sectionHeader) {
return new SectionedItemList(requireNonNull(itemList), requireNonNull(sectionHeader));
}
+ /**
+ * Creates an instance of a {@link SectionedItemList} with the given {@code itemList} and
+ * {@code sectionHeader}.
+ */
+ @NonNull
+ public static SectionedItemList create(
+ @NonNull ItemList itemList, @NonNull CharSequence sectionHeader) {
+ return new SectionedItemList(requireNonNull(itemList),
+ CarText.create(requireNonNull(sectionHeader)));
+ }
+
/** Returns the {@link ItemList} for the section. */
@NonNull
public ItemList getItemList() {
diff --git a/car/app/app/src/main/java/androidx/car/app/model/constraints/RowConstraints.java b/car/app/app/src/main/java/androidx/car/app/model/constraints/RowConstraints.java
index e88c148..965d6d2 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/constraints/RowConstraints.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/constraints/RowConstraints.java
@@ -123,9 +123,7 @@
*
* @throws IllegalArgumentException if the constraints are not met.
*/
- public void validateOrThrow(@NonNull Object rowObj) {
- Row row = (Row) rowObj;
-
+ public void validateOrThrow(@NonNull Row row) {
if (!mIsOnClickListenerAllowed && row.getOnClickListener() != null) {
throw new IllegalArgumentException("A click listener is not allowed on the row");
}
diff --git a/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java b/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java
index e4bbcf5..16511c7 100644
--- a/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java
+++ b/car/app/app/src/main/java/androidx/car/app/model/constraints/RowListConstraints.java
@@ -26,8 +26,10 @@
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.car.app.model.Action;
+import androidx.car.app.model.Item;
import androidx.car.app.model.ItemList;
import androidx.car.app.model.Pane;
+import androidx.car.app.model.Row;
import androidx.car.app.model.SectionedItemList;
import java.util.ArrayList;
@@ -112,24 +114,25 @@
* Validates that the {@link ItemList} satisfies this {@link RowListConstraints} instance.
*
* @throws IllegalArgumentException if the constraints are not met.
+ * @throws IllegalArgumentException if the list contains non-Row instances.
*/
public void validateOrThrow(@NonNull ItemList itemList) {
if (itemList.getOnSelectedListener() != null && !mAllowSelectableLists) {
throw new IllegalArgumentException("Selectable lists are not allowed");
}
- validateRows(itemList.getItems());
+ validateRows(itemList.getItemList());
}
/**
* Validates that the list of {@link SectionedItemList}s satisfies this
- * {@link RowListConstraints}
- * instance.
+ * {@link RowListConstraints} instance.
*
* @throws IllegalArgumentException if the constraints are not met.
+ * @throws IllegalArgumentException if the lists contain any non-Row instances.
*/
public void validateOrThrow(@NonNull List<SectionedItemList> sections) {
- List<Object> combinedLists = new ArrayList<>();
+ List<Item> combinedLists = new ArrayList<>();
for (SectionedItemList section : sections) {
ItemList sectionList = section.getItemList();
@@ -137,7 +140,7 @@
throw new IllegalArgumentException("Selectable lists are not allowed");
}
- combinedLists.addAll(sectionList.getItems());
+ combinedLists.addAll(sectionList.getItemList());
}
validateRows(combinedLists);
@@ -156,12 +159,15 @@
+ mMaxActions);
}
- validateRows(pane.getRows());
+ validateRows(pane.getRowList());
}
- private void validateRows(List<Object> rows) {
- for (Object rowObj : rows) {
- mRowConstraints.validateOrThrow(rowObj);
+ private void validateRows(List<? extends Item> rows) {
+ for (Item rowObj : rows) {
+ if (!(rowObj instanceof Row)) {
+ throw new IllegalArgumentException("Only Row instances are supported in the list");
+ }
+ mRowConstraints.validateOrThrow((Row) rowObj);
}
}
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java
index 9415fb0..fbce905 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/PlaceListNavigationTemplate.java
@@ -29,6 +29,7 @@
import androidx.car.app.model.ActionStrip;
import androidx.car.app.model.CarText;
import androidx.car.app.model.DistanceSpan;
+import androidx.car.app.model.Item;
import androidx.car.app.model.ItemList;
import androidx.car.app.model.ModelUtils;
import androidx.car.app.model.Place;
@@ -240,7 +241,7 @@
@NonNull
public Builder setItemList(@Nullable ItemList itemList) {
if (itemList != null) {
- List<Object> items = itemList.getItems();
+ List<Item> items = itemList.getItemList();
ROW_LIST_CONSTRAINTS_SIMPLE.validateOrThrow(itemList);
ModelUtils.validateAllNonBrowsableRowsHaveDistance(items);
ModelUtils.validateAllRowsHaveOnlySmallImages(items);
diff --git a/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java b/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java
index e519e85..508c272 100644
--- a/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java
+++ b/car/app/app/src/main/java/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.java
@@ -284,10 +284,10 @@
public Builder setItemList(@Nullable ItemList itemList) {
if (itemList != null) {
ROW_LIST_CONSTRAINTS_ROUTE_PREVIEW.validateOrThrow(itemList);
- ModelUtils.validateAllRowsHaveDistanceOrDuration(itemList.getItems());
- ModelUtils.validateAllRowsHaveOnlySmallImages(itemList.getItems());
+ ModelUtils.validateAllRowsHaveDistanceOrDuration(itemList.getItemList());
+ ModelUtils.validateAllRowsHaveOnlySmallImages(itemList.getItemList());
- if (!itemList.getItems().isEmpty() && itemList.getOnSelectedListener() == null) {
+ if (!itemList.getItemList().isEmpty() && itemList.getOnSelectedListener() == null) {
throw new IllegalArgumentException(
"The OnSelectedListener must be set for the route list");
}
diff --git a/car/app/app/src/test/java/androidx/car/app/TestUtils.java b/car/app/app/src/test/java/androidx/car/app/TestUtils.java
index d64e13e..70394f8 100644
--- a/car/app/app/src/test/java/androidx/car/app/TestUtils.java
+++ b/car/app/app/src/test/java/androidx/car/app/TestUtils.java
@@ -29,7 +29,6 @@
import androidx.annotation.RequiresApi;
import androidx.car.app.model.Action;
import androidx.car.app.model.CarIcon;
-import androidx.car.app.model.CarText;
import androidx.car.app.model.DateTimeWithZone;
import androidx.car.app.model.DistanceSpan;
import androidx.car.app.model.GridItem;
@@ -155,7 +154,7 @@
sections.add(
SectionedItemList.create(
createItemList(rowCountPerSection, isSelectable),
- CarText.create("Section " + i)));
+ "Section " + i));
}
return sections;
diff --git a/car/app/app/src/test/java/androidx/car/app/model/ItemListTest.java b/car/app/app/src/test/java/androidx/car/app/model/ItemListTest.java
index 0751762f..f94ced1 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/ItemListTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/ItemListTest.java
@@ -67,7 +67,7 @@
@Test
public void createEmpty() {
ItemList list = builder().build();
- assertThat(list.getItems()).isEqualTo(Collections.emptyList());
+ assertThat(list.getItemList()).isEqualTo(Collections.emptyList());
}
@Test
@@ -76,9 +76,9 @@
Row row2 = new Row.Builder().setTitle("Row2").build();
ItemList list = builder().addItem(row1).addItem(row2).build();
- assertThat(list.getItems()).hasSize(2);
- assertThat(list.getItems().get(0)).isEqualTo(row1);
- assertThat(list.getItems().get(1)).isEqualTo(row2);
+ assertThat(list.getItemList()).hasSize(2);
+ assertThat(list.getItemList().get(0)).isEqualTo(row1);
+ assertThat(list.getItemList().get(1)).isEqualTo(row2);
}
@Test
@@ -87,7 +87,7 @@
GridItem gridItem2 = new GridItem.Builder().setTitle("title 2").setImage(BACK).build();
ItemList list = builder().addItem(gridItem1).addItem(gridItem2).build();
- assertThat(list.getItems()).containsExactly(gridItem1, gridItem2).inOrder();
+ assertThat(list.getItemList()).containsExactly(gridItem1, gridItem2).inOrder();
}
@Test
diff --git a/car/app/app/src/test/java/androidx/car/app/model/ListTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/model/ListTemplateTest.java
index 6900b78..e5879bc 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/ListTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/ListTemplateTest.java
@@ -56,19 +56,22 @@
ItemList emptyList = new ItemList.Builder().build();
assertThrows(
IllegalArgumentException.class,
- () -> new ListTemplate.Builder().setTitle("Title").addList(emptyList,
- "header").build());
+ () -> new ListTemplate.Builder().setTitle("Title").addSectionedList(
+ SectionedItemList.create(emptyList,
+ "header")).build());
}
@Test
- public void addList_emptyHeader_throws() {
+ public void addSectionedList_emptyHeader_throws() {
assertThrows(
IllegalArgumentException.class,
- () -> new ListTemplate.Builder().setTitle("Title").addList(getList(), "").build());
+ () -> new ListTemplate.Builder().setTitle("Title").addSectionedList(
+ SectionedItemList.create(getList(),
+ "")).build());
}
@Test
- public void addList_withVisibilityListener_throws() {
+ public void addSectionedList_withVisibilityListener_throws() {
ItemList list =
new ItemList.Builder()
.addItem(new Row.Builder().setTitle("Title").build())
@@ -77,11 +80,13 @@
.build();
assertThrows(
IllegalArgumentException.class,
- () -> new ListTemplate.Builder().setTitle("Title").addList(list, "header").build());
+ () -> new ListTemplate.Builder().setTitle("Title").addSectionedList(
+ SectionedItemList.create(list,
+ "header")).build());
}
@Test
- public void addList_moreThanMaxTexts_throws() {
+ public void addSectionedList_moreThanMaxTexts_throws() {
Row rowExceedsMaxTexts =
new Row.Builder().setTitle("Title").addText("text1").addText("text2").addText(
"text3").build();
@@ -120,25 +125,25 @@
ListTemplate template = new ListTemplate.Builder().setTitle("Title").setSingleList(
list).build();
assertThat(template.getSingleList()).isEqualTo(list);
- assertThat(template.getSectionLists()).isEmpty();
+ assertThat(template.getSectionedLists()).isEmpty();
}
@Test
- public void createInstance_addList() {
+ public void createInstance_addSectionedList() {
ItemList list1 = getList();
ItemList list2 = getList();
ListTemplate template =
new ListTemplate.Builder()
.setTitle("Title")
- .addList(list1, "header1")
- .addList(list2, "header2")
+ .addSectionedList(SectionedItemList.create(list1, "header1"))
+ .addSectionedList(SectionedItemList.create(list2, "header2"))
.build();
assertThat(template.getSingleList()).isNull();
- assertThat(template.getSectionLists()).hasSize(2);
- assertThat(template.getSectionLists().get(0).getItemList()).isEqualTo(list1);
- assertThat(template.getSectionLists().get(0).getHeader().getText()).isEqualTo("header1");
- assertThat(template.getSectionLists().get(1).getItemList()).isEqualTo(list2);
- assertThat(template.getSectionLists().get(1).getHeader().getText()).isEqualTo("header2");
+ assertThat(template.getSectionedLists()).hasSize(2);
+ assertThat(template.getSectionedLists().get(0).getItemList()).isEqualTo(list1);
+ assertThat(template.getSectionedLists().get(0).getHeader().getText()).isEqualTo("header1");
+ assertThat(template.getSectionedLists().get(1).getItemList()).isEqualTo(list2);
+ assertThat(template.getSectionedLists().get(1).getHeader().getText()).isEqualTo("header2");
}
@Test
@@ -149,16 +154,16 @@
ListTemplate template =
new ListTemplate.Builder()
.setTitle("Title")
- .addList(list1, "header1")
- .addList(list2, "header2")
+ .addSectionedList(SectionedItemList.create(list1, "header1"))
+ .addSectionedList(SectionedItemList.create(list2, "header2"))
.setSingleList(list3)
.build();
assertThat(template.getSingleList()).isEqualTo(list3);
- assertThat(template.getSectionLists()).isEmpty();
+ assertThat(template.getSectionedLists()).isEmpty();
}
@Test
- public void addList_clearSingleList() {
+ public void addSectionedList_clearSingleList() {
ItemList list1 = getList();
ItemList list2 = getList();
ItemList list3 = getList();
@@ -166,11 +171,11 @@
new ListTemplate.Builder()
.setTitle("Title")
.setSingleList(list1)
- .addList(list2, "header1")
- .addList(list3, "header2")
+ .addSectionedList(SectionedItemList.create(list2, "header1"))
+ .addSectionedList(SectionedItemList.create(list3, "header2"))
.build();
assertThat(template.getSingleList()).isNull();
- assertThat(template.getSectionLists()).hasSize(2);
+ assertThat(template.getSectionedLists()).hasSize(2);
}
@Test
diff --git a/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java b/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java
index f7a91ae..648c664 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/PaneTest.java
@@ -57,7 +57,7 @@
public void addRow() {
Row row = createRow(1);
Pane pane = new Pane.Builder().addRow(row).build();
- assertThat(pane.getRows()).containsExactly(row);
+ assertThat(pane.getRowList()).containsExactly(row);
}
@Test
@@ -66,7 +66,7 @@
Row row2 = createRow(2);
Row row3 = createRow(3);
Pane pane = new Pane.Builder().addRow(row1).addRow(row2).addRow(row3).build();
- assertThat(pane.getRows()).containsExactly(row1, row2, row3);
+ assertThat(pane.getRowList()).containsExactly(row1, row2, row3);
}
@Test
diff --git a/car/app/app/src/test/java/androidx/car/app/model/SectionedItemListTest.java b/car/app/app/src/test/java/androidx/car/app/model/SectionedItemListTest.java
index 45ea854..61b7d7d 100644
--- a/car/app/app/src/test/java/androidx/car/app/model/SectionedItemListTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/model/SectionedItemListTest.java
@@ -23,7 +23,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.internal.DoNotInstrument;
-/** Tests for {@link ItemListTest}. */
+/** Tests for {@link SectionedItemList}. */
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
public class SectionedItemListTest {
@@ -31,22 +31,19 @@
@Test
public void createInstance() {
ItemList list = new ItemList.Builder().build();
- CarText header = CarText.create("header");
- SectionedItemList sectionList = SectionedItemList.create(list, header);
+ SectionedItemList sectionList = SectionedItemList.create(list, "header");
assertThat(sectionList.getItemList()).isEqualTo(list);
- assertThat(sectionList.getHeader()).isEqualTo(header);
+ assertThat(sectionList.getHeader().getText()).isEqualTo("header");
}
@Test
public void equals() {
ItemList list = new ItemList.Builder().build();
- CarText header = CarText.create("header");
- SectionedItemList sectionList = SectionedItemList.create(list, header);
+ SectionedItemList sectionList = SectionedItemList.create(list, "header");
ItemList list2 = new ItemList.Builder().build();
- CarText header2 = CarText.create("header");
- SectionedItemList sectionList2 = SectionedItemList.create(list2, header2);
+ SectionedItemList sectionList2 = SectionedItemList.create(list2, "header");
assertThat(sectionList2).isEqualTo(sectionList);
}
@@ -55,12 +52,10 @@
public void notEquals_differentItemList() {
ItemList list = new ItemList.Builder().addItem(
new Row.Builder().setTitle("Title").build()).build();
- CarText header = CarText.create("header");
- SectionedItemList sectionList = SectionedItemList.create(list, header);
+ SectionedItemList sectionList = SectionedItemList.create(list, "header");
ItemList list2 = new ItemList.Builder().build();
- CarText header2 = CarText.create("header");
- SectionedItemList sectionList2 = SectionedItemList.create(list2, header2);
+ SectionedItemList sectionList2 = SectionedItemList.create(list2, "header");
assertThat(sectionList2).isNotEqualTo(sectionList);
}
@@ -68,12 +63,10 @@
@Test
public void notEquals_differentHeader() {
ItemList list = new ItemList.Builder().build();
- CarText header = CarText.create("header1");
- SectionedItemList sectionList = SectionedItemList.create(list, header);
+ SectionedItemList sectionList = SectionedItemList.create(list, "header1");
ItemList list2 = new ItemList.Builder().build();
- CarText header2 = CarText.create("header2");
- SectionedItemList sectionList2 = SectionedItemList.create(list2, header2);
+ SectionedItemList sectionList2 = SectionedItemList.create(list2, "header2");
assertThat(sectionList2).isNotEqualTo(sectionList);
}
diff --git a/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java b/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java
index 612c13b..9950780 100644
--- a/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/navigation/model/PlaceListNavigationTemplateTest.java
@@ -167,7 +167,7 @@
.setTitle("Title")
.setItemList(new ItemList.Builder().build())
.build();
- assertThat(template.getItemList().getItems()).isEmpty();
+ assertThat(template.getItemList().getItemList()).isEmpty();
assertThat(template.getTitle().getText()).isEqualTo("Title");
assertThat(template.getActionStrip()).isNull();
}
diff --git a/car/app/app/src/test/java/androidx/car/app/serialization/BundlerTest.java b/car/app/app/src/test/java/androidx/car/app/serialization/BundlerTest.java
index 896ed16..dc437b5 100644
--- a/car/app/app/src/test/java/androidx/car/app/serialization/BundlerTest.java
+++ b/car/app/app/src/test/java/androidx/car/app/serialization/BundlerTest.java
@@ -176,7 +176,7 @@
Bundle bundle = Bundler.toBundle(mapTemplate);
PlaceListMapTemplate readIn = (PlaceListMapTemplate) Bundler.fromBundle(bundle);
- Row row = (Row) readIn.getItemList().getItems().get(0);
+ Row row = (Row) readIn.getItemList().getItemList().get(0);
assertThat(row.getTitle().toString()).isEqualTo("foo");
OnDoneCallback >
row.getOnClickListener().onClick(onDoneCallback);
@@ -370,9 +370,9 @@
assertThat(readIn.getTitle().toString()).isEqualTo(mapTemplate.getTitle().toString());
ItemList readInItemList = readIn.getItemList();
- assertThat(readInItemList.getItems()).hasSize(2);
- assertThat(row1).isEqualTo(readInItemList.getItems().get(0));
- assertThat(row2).isEqualTo(readInItemList.getItems().get(1));
+ assertThat(readInItemList.getItemList()).hasSize(2);
+ assertThat(row1).isEqualTo(readInItemList.getItemList().get(0));
+ assertThat(row2).isEqualTo(readInItemList.getItemList().get(1));
assertThat(actionStrip).isEqualTo(readIn.getActionStrip());
}