Merge "Simplifying some scrollbar binding logic in all-apps" into tm-qpr-dev

This commit is contained in:
Sunny Goyal
2023-02-22 18:09:32 +00:00
committed by Android (Google) Code Review
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);
@@ -411,7 +416,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);
@@ -494,7 +499,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(
@@ -1055,12 +1060,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.
*/
@@ -1252,6 +1251,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);