Add methods to allow scrolling the list in the drawer.
These methods will be used in media.
Bug: 37999972
Test: Tested together with the other change in the topic.
Change-Id: I882bf683f56f91a439dfe83d6d1514a171d3cd2d
diff --git a/car-stream-ui-lib/src/com/android/car/app/CarDrawerActivity.java b/car-stream-ui-lib/src/com/android/car/app/CarDrawerActivity.java
index ce6f04a..c8bf22a 100644
--- a/car-stream-ui-lib/src/com/android/car/app/CarDrawerActivity.java
+++ b/car-stream-ui-lib/src/com/android/car/app/CarDrawerActivity.java
@@ -219,7 +219,7 @@
public void onDrawerClosed(View drawerView) {
// If drawer is closed for any reason, revert stack/drawer to initial root state.
cleanupStackAndShowRoot();
- mDrawerList.getRecyclerView().scrollToPosition(0);
+ scrollToPosition(0);
}
@Override
public void onDrawerStateChanged(int newState) {}
@@ -277,7 +277,11 @@
// NOTE: We don't use swapAdapter() since different levels in the Drawer may switch between
// car_menu_list_item_normal, car_menu_list_item_small and car_list_empty layouts.
mDrawerList.getRecyclerView().setAdapter(adapter);
- mDrawerList.getRecyclerView().scrollToPosition(0);
+ scrollToPosition(0);
+ }
+
+ public void scrollToPosition(int position) {
+ mDrawerList.getRecyclerView().smoothScrollToPosition(position);
}
private boolean maybeHandleUpClick() {