aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-06-03 01:15:21 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-06-03 01:15:21 +0000
commit40c36dcad3ae7e319716f4c7cc7aa72355f7a551 (patch)
tree9a59b9fc4a5dc9d4940988b1dd306cc97dc9f6f6
parent6759153a4f270e3681098ee013ac29c3cbdedc23 (diff)
parent55340419ca385e12794eacea70eedcb38ffc5450 (diff)
downloadtests-40c36dcad3ae7e319716f4c7cc7aa72355f7a551.tar.gz
Snap for 6553159 from 55340419ca385e12794eacea70eedcb38ffc5450 to rvc-release
Change-Id: Ie6f50ba0cf1d31868f91cb4a050838ccb48cafc1
-rw-r--r--RotaryPlayground/res/layout/rotary_cards.xml24
-rw-r--r--RotaryPlayground/res/layout/rotary_menu.xml6
-rw-r--r--RotaryPlayground/res/layout/rotary_scroll.xml27
-rw-r--r--RotaryPlayground/res/layout/rotary_scroll_button.xml35
-rw-r--r--RotaryPlayground/res/layout/rotary_scroll_text.xml32
-rw-r--r--RotaryPlayground/res/values/arrays.xml69
-rw-r--r--RotaryPlayground/res/values/colors.xml1
-rw-r--r--RotaryPlayground/res/values/dimens.xml3
-rw-r--r--RotaryPlayground/res/values/strings.xml3
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryActivity.java12
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java25
-rw-r--r--RotaryPlayground/src/com/android/car/rotaryplayground/ScrollFragment.java170
12 files changed, 387 insertions, 20 deletions
diff --git a/RotaryPlayground/res/layout/rotary_cards.xml b/RotaryPlayground/res/layout/rotary_cards.xml
index 7fc8297..e3d9e87 100644
--- a/RotaryPlayground/res/layout/rotary_cards.xml
+++ b/RotaryPlayground/res/layout/rotary_cards.xml
@@ -60,7 +60,7 @@
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button" />
@@ -72,20 +72,20 @@
android:background="@color/button_disabled_background_color"
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:enabled="false"
android:tag="test_button"
android:text="Disabled" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button" />
</com.android.car.ui.FocusArea>
@@ -110,28 +110,28 @@
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:enabled="false"
android:tag="test_button"
android:text="Disabled" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:enabled="false"
android:tag="test_button"
android:text="Disabled" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:enabled="false"
android:tag="test_button"
android:text="Disabled" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:enabled="false"
android:tag="test_button"
android:text="Disabled" />
@@ -157,26 +157,26 @@
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button" />
<!-- TODO(b/154180719): Make this button the default focus in this FocusArea -->
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button (Default)" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button" />
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
- android:onClick="onRotaryCardsButtonClick"
+ android:onClick="onRotaryButtonClick"
android:tag="test_button"
android:text="Button" />
</com.android.car.ui.FocusArea>
diff --git a/RotaryPlayground/res/layout/rotary_menu.xml b/RotaryPlayground/res/layout/rotary_menu.xml
index 8aa2f56..176d58c 100644
--- a/RotaryPlayground/res/layout/rotary_menu.xml
+++ b/RotaryPlayground/res/layout/rotary_menu.xml
@@ -44,4 +44,10 @@
android:layout_height="0dp"
android:layout_weight="1"
android:text="Menu Item 4" />
+ <Button
+ android:id="@+id/scroll"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="Scroll" />
</com.android.car.ui.FocusArea>
diff --git a/RotaryPlayground/res/layout/rotary_scroll.xml b/RotaryPlayground/res/layout/rotary_scroll.xml
new file mode 100644
index 0000000..78c90c0
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_scroll.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<com.android.car.ui.FocusArea
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <com.android.car.ui.recyclerview.CarUiRecyclerView
+ android:id="@+id/rotary_scroll_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+</com.android.car.ui.FocusArea>
diff --git a/RotaryPlayground/res/layout/rotary_scroll_button.xml b/RotaryPlayground/res/layout/rotary_scroll_button.xml
new file mode 100644
index 0000000..a223aa9
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_scroll_button.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+ <Button
+ android:layout_height="wrap_content"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:onClick="onRotaryButtonClick"
+ android:text="Button" />
+ <Button
+ android:layout_height="wrap_content"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:onClick="onRotaryButtonClick"
+ android:text="Button" />
+</LinearLayout> \ No newline at end of file
diff --git a/RotaryPlayground/res/layout/rotary_scroll_text.xml b/RotaryPlayground/res/layout/rotary_scroll_text.xml
new file mode 100644
index 0000000..d9d82f6
--- /dev/null
+++ b/RotaryPlayground/res/layout/rotary_scroll_text.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/scroll_text_view"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:background="@color/scroll_text_background_color"
+ android:layout_marginTop="@dimen/margin"
+ android:layout_marginBottom="@dimen/margin"
+ android:padding="@dimen/padding"
+ android:text="@string/lorem" />
+</LinearLayout> \ No newline at end of file
diff --git a/RotaryPlayground/res/values/arrays.xml b/RotaryPlayground/res/values/arrays.xml
new file mode 100644
index 0000000..18b0015
--- /dev/null
+++ b/RotaryPlayground/res/values/arrays.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<resources>
+ <!-- List of greetings to display on button clicks -->
+ <string-array name="greetings" translatable="false">
+ <item>Hello!</item>
+ <item>Bonjour!</item>
+ <item>Hola!</item>
+ <item>Zdravstvuyte!</item>
+ <item>Ni Hao!</item>
+ <item>Salve!</item>
+ <item>Konnichiwa!</item>
+ <item>Guten Tag!</item>
+ <item>Ola!</item>
+ <item>Anyoung haseyo!</item>
+ <item>Asalaam alaikum!</item>
+ <item>Goddag!</item>
+ <item>Shikamoo!</item>
+ <item>Goedendag!</item>
+ <item>Yassas!</item>
+ <item>Dzien dobry!</item>
+ <item>Selamat siang!</item>
+ <item>Namaste, Namaskar!</item>
+ <item>Merhaba!</item>
+ <item>Shalom!</item>
+ </string-array>
+
+ <!-- Array used for creating items in the scroll demo. The scroll demos creates 2 types of
+ items: (1) A view with two buttons (fixed height) and (2) a textview with varying
+ height. Items here with '0' indicates the buttons item and items with value > 0 indicates
+ the text item where the integer value is the height of the textview. -->
+ <integer-array name="scroll_item_heights">
+ <item>0</item>
+ <item>60</item>
+ <item>0</item>
+ <item>60</item>
+ <item>60</item>
+ <item>0</item>
+ <item>120</item>
+ <item>0</item>
+ <item>120</item>
+ <item>120</item>
+ <item>0</item>
+ <item>180</item>
+ <item>0</item>
+ <item>180</item>
+ <item>180</item>
+ <item>0</item>
+ <item>240</item>
+ <item>0</item>
+ <item>240</item>
+ <item>240</item>
+ <item>0</item>
+ </integer-array>
+</resources> \ No newline at end of file
diff --git a/RotaryPlayground/res/values/colors.xml b/RotaryPlayground/res/values/colors.xml
index 05e030c..b49ea51 100644
--- a/RotaryPlayground/res/values/colors.xml
+++ b/RotaryPlayground/res/values/colors.xml
@@ -19,4 +19,5 @@
<color name="card_disabled_background_color">#61646b</color>
<color name="grid_item_background_color">#006666</color>
<color name="button_disabled_background_color">#61646b</color>
+ <color name="scroll_text_background_color">#61646b</color>
</resources> \ No newline at end of file
diff --git a/RotaryPlayground/res/values/dimens.xml b/RotaryPlayground/res/values/dimens.xml
index b919705..77e907f 100644
--- a/RotaryPlayground/res/values/dimens.xml
+++ b/RotaryPlayground/res/values/dimens.xml
@@ -15,6 +15,9 @@
~ limitations under the License
-->
<resources>
+ <!-- common values -->
+ <dimen name="padding">16dp</dimen>
+ <dimen name="margin">16dp</dimen>
<!-- Rotary Menu values -->
<dimen name="menu_width">200dp</dimen>
<!-- Card example values -->
diff --git a/RotaryPlayground/res/values/strings.xml b/RotaryPlayground/res/values/strings.xml
index fd38e6b..35c960a 100644
--- a/RotaryPlayground/res/values/strings.xml
+++ b/RotaryPlayground/res/values/strings.xml
@@ -30,4 +30,7 @@
<string name="card_that_wraps_around_text" translatable="false">
The focus should move clockwise when rotating clockwise and similarly for counterclockwise. Focus also wraps around the elements (H -> A clockwise and A -> H counterclockwise).
</string>
+ <string name="lorem" translatable="false">
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et velit finibus, tempor ipsum vel, pellentesque lorem. Suspendisse congue urna pulvinar, congue dolor in, eleifend orci. Nam egestas sodales sapien. Integer sit amet ligula in ex commodo semper. Phasellus ac facilisis ligula. Ut mollis risus eu nunc consequat, eu molestie dolor maximus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Donec commodo lectus non est lacinia accumsan. Nulla tristique cursus iaculis. Sed in hendrerit nulla, vel faucibus mi. Aenean placerat turpis eros, non sagittis enim viverra id. Vestibulum vel rutrum est, eu consequat felis. Maecenas ac suscipit ante. Fusce dapibus ut libero blandit vehicula. Vivamus vel ipsum condimentum, maximus tellus nec, rutrum lorem.
+ </string>
</resources>
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryActivity.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryActivity.java
index 1b44ac6..32ab6a5 100644
--- a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryActivity.java
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryActivity.java
@@ -24,6 +24,8 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
+import java.util.Random;
+
/**
* The main activity for Rotary Playground
*
@@ -33,7 +35,8 @@ import android.widget.Toast;
public class RotaryActivity extends FragmentActivity {
private static final String TAG = "RotaryActivity";
- private static final String MESSAGE = "Hello there!";
+
+ private final Random mRandom = new Random();
private Fragment mMenuFragment = null;
@@ -44,9 +47,10 @@ public class RotaryActivity extends FragmentActivity {
showMenuFragment();
}
- /** Event handler for buttons in res/layout/rotary_cards.xml */
- public void onRotaryCardsButtonClick(View v) {
- showToast(MESSAGE);
+ /** Event handler for button clicks. */
+ public void onRotaryButtonClick(View v) {
+ final String[] greetings = getResources().getStringArray(R.array.greetings);
+ showToast(greetings[mRandom.nextInt(greetings.length)]);
}
private void showMenuFragment() {
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
index d54a721..d28d007 100644
--- a/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/RotaryMenu.java
@@ -33,10 +33,12 @@ public class RotaryMenu extends Fragment {
private Fragment mRotaryCards = null;
private Fragment mRotaryGrid = null;
private Fragment mDirectManipulation = null;
+ private Fragment mScrollFragment = null;
private Button mCardButton;
private Button mGridButton;
private Button mDirectManipulationButton;
+ private Button mScrollButton;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@@ -56,6 +58,11 @@ public class RotaryMenu extends Fragment {
(v, hasFocus) -> showDirectManipulationExamples(hasFocus));
mDirectManipulationButton.setOnClickListener(
(v -> showDirectManipulationExamples(/* hasFocus= */ true)));
+
+ mScrollButton = view.findViewById(R.id.scroll);
+ mScrollButton.setOnFocusChangeListener((v, hasFocus) -> showScrollFragment(hasFocus));
+ mScrollButton.setOnClickListener(v -> showScrollFragment(/* hasFocus= */ true));
+
return view;
}
@@ -66,7 +73,7 @@ public class RotaryMenu extends Fragment {
if (mRotaryCards == null) {
mRotaryCards = new RotaryCards();
}
- showContent(mRotaryCards);
+ showFragment(mRotaryCards);
}
private void showGridExample(boolean hasFocus) {
@@ -76,7 +83,7 @@ public class RotaryMenu extends Fragment {
if (mRotaryGrid == null) {
mRotaryGrid = new RotaryGrid();
}
- showContent(mRotaryGrid);
+ showFragment(mRotaryGrid);
}
// TODO(agathaman): refactor this and the showRotaryCards above into a
@@ -88,10 +95,20 @@ public class RotaryMenu extends Fragment {
if (mDirectManipulation == null) {
mDirectManipulation = new RotaryDirectManipulationWidgets();
}
- showContent(mDirectManipulation);
+ showFragment(mDirectManipulation);
+ }
+
+ private void showScrollFragment(boolean hasFocus) {
+ if (!hasFocus) {
+ return; // Do nothing if no focus.
+ }
+ if (mScrollFragment == null) {
+ mScrollFragment = new ScrollFragment();
+ }
+ showFragment(mScrollFragment);
}
- private void showContent(Fragment fragment) {
+ private void showFragment(Fragment fragment) {
getFragmentManager().beginTransaction()
.replace(R.id.rotary_content, fragment)
.commit();
diff --git a/RotaryPlayground/src/com/android/car/rotaryplayground/ScrollFragment.java b/RotaryPlayground/src/com/android/car/rotaryplayground/ScrollFragment.java
new file mode 100644
index 0000000..49e341d
--- /dev/null
+++ b/RotaryPlayground/src/com/android/car/rotaryplayground/ScrollFragment.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.car.rotaryplayground;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** Fragment to demo scrolling with CarRecyclerView. */
+public class ScrollFragment extends Fragment {
+
+ // Item types
+ private static final int TYPE_BUTTONS = 1;
+ private static final int TYPE_TEXT = 2;
+
+ private View mScrollView;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ mScrollView = inflater.inflate(R.layout.rotary_scroll, container, false);
+ initView();
+ return mScrollView;
+ }
+
+ private void initView() {
+ List<ScrollListItem> items = new ArrayList<>();
+
+ // List of height for items to be added to the demo.
+ // 0 indicates focusable buttons inflated by R.layout.rotary_scroll.button.
+ // Values > 0 indiciates non-focusable texts inflated by R.layout.rotary_scroll_text.
+ final int[] itemHeights = getResources().getIntArray(R.array.scroll_item_heights);
+
+ for (int height : itemHeights) {
+ if (height < 0) {
+ continue;
+ }
+ ScrollListItem item = (height == 0)
+ ? ScrollListItem.createButtonsItem()
+ : ScrollListItem.createTextItemWithHeight(height);
+ items.add(item);
+ }
+
+ // Set adapter
+ Context context = getContext();
+ ScrollListItemAdapter adapter = new ScrollListItemAdapter(context, items);
+ RecyclerView view = (RecyclerView) mScrollView.findViewById(R.id.rotary_scroll_view);
+ view.setAdapter(adapter);
+ }
+
+ /** The adapter used by RotaryScroll to render ScrollListItems. */
+ private static class ScrollListItemAdapter extends
+ RecyclerView.Adapter<RecyclerView.ViewHolder> {
+
+ final Context mContext;
+ final List<ScrollListItem> mItems;
+
+ ScrollListItemAdapter(Context context, List<ScrollListItem> items) {
+ this.mContext = context;
+ this.mItems = items;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(
+ @NonNull ViewGroup viewGroup, int viewType) {
+ View view;
+ switch (viewType) {
+ case TYPE_BUTTONS:
+ view = LayoutInflater.from(mContext).inflate(
+ R.layout.rotary_scroll_button, viewGroup, false);
+ return new RecyclerView.ViewHolder(view) {};
+
+ case TYPE_TEXT:
+ view = LayoutInflater.from(mContext).inflate(
+ R.layout.rotary_scroll_text, viewGroup, false);
+ return new ScrollTextHolder(view);
+
+ default:
+ throw new IllegalArgumentException("Unexpected viewType: " + viewType);
+ }
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ return mItems.get(position).getType();
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
+ if (getItemViewType(position) == TYPE_TEXT) {
+ ((ScrollTextHolder) viewHolder).setHeight(mItems.get(position).getHeight());
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return mItems.size();
+ }
+ }
+
+ /** A ViewHolder for non-focusable ScrollListItems */
+ private static class ScrollTextHolder extends RecyclerView.ViewHolder {
+
+ @NonNull
+ final TextView mScrollTextView;
+
+ ScrollTextHolder(@NonNull View itemView) {
+ super(itemView);
+ mScrollTextView = itemView.findViewById(R.id.scroll_text_view);
+ }
+
+ void setHeight(int height) {
+ mScrollTextView.setHeight(height);
+ }
+ }
+
+ private static class ScrollListItem {
+
+ final int mHeight;
+ final int mType;
+
+ static ScrollListItem createTextItemWithHeight(int height) {
+ return new ScrollListItem(TYPE_TEXT, height);
+ }
+ static ScrollListItem createButtonsItem() {
+ return new ScrollListItem(TYPE_BUTTONS, 0);
+ }
+
+ ScrollListItem(int type, int height) {
+ this.mType = type;
+ this.mHeight = height;
+ }
+
+ int getHeight() {
+ return mHeight;
+ }
+
+ int getType() {
+ return mType;
+ }
+ }
+}