Simplifying some scrollbar binding logic in all-apps

Bug: 256684299
Test: Manual
Change-Id: I1cee6cb783f0f805d9a0f0a4b2b668a709cacf1a
This commit is contained in:
Sunny Goyal
2023-01-30 16:54:31 -08:00
parent 192e7afc3c
commit 4d18ad4825
5 changed files with 24 additions and 41 deletions

View File

@@ -134,6 +134,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
protected AllAppsPagedView mViewPager;
protected FloatingHeaderView mHeader;
protected View mBottomSheetBackground;
protected RecyclerViewFastScroller mFastScroller;
/**
* View that defines the search box. Result is rendered inside {@link #mSearchRecyclerView}.
*/
@@ -219,6 +221,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
mFastScroller = findViewById(R.id.fast_scroller);
mFastScroller.setPopupView(findViewById(R.id.fast_scroller_popup));
// Add the search box above everything else.
mSearchContainer = inflateSearchBox();
@@ -302,6 +306,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
return;
}
mFastScroller.setVisibility(goingToSearch ? INVISIBLE : VISIBLE);
if (goingToSearch) {
// Fade out the button to pause work apps.
mWorkManager.onActivePageChanged(SEARCH);
@@ -408,7 +413,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
return;
}
if (mAH.get(currentActivePage).mRecyclerView != null) {
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar();
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar(mFastScroller);
}
// Header keeps track of active recycler view to properly render header protection.
mHeader.setActiveRV(currentActivePage);
@@ -491,7 +496,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
if (isSearchBarOnBottom()) {
// Keep the scroller above the search bar.
RelativeLayout.LayoutParams scrollerLayoutParams =
(LayoutParams) findViewById(R.id.fast_scroller).getLayoutParams();
(LayoutParams) mFastScroller.getLayoutParams();
scrollerLayoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
scrollerLayoutParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
scrollerLayoutParams.bottomMargin = getResources().getDimensionPixelSize(
@@ -1052,12 +1057,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
: mViewPager == null ? AdapterHolder.MAIN : mViewPager.getNextPage();
}
/** The scroll bar for the active apps recycler view. */
public RecyclerViewFastScroller getScrollBar() {
AllAppsRecyclerView rv = getActiveAppsRecyclerView();
return rv == null ? null : rv.getScrollbar();
}
/**
* Adds an update listener to animator that adds springs to the animation.
*/
@@ -1249,6 +1248,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
void setup(@NonNull View rv, @Nullable Predicate<ItemInfo> matcher) {
mAppsList.updateItemFilter(matcher);
mRecyclerView = (AllAppsRecyclerView) rv;
mRecyclerView.bindFastScrollbar(mFastScroller);
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
mRecyclerView.setApps(mAppsList);
mRecyclerView.setLayoutManager(mLayoutManager);