Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1459fd83 authored by Holly Jiuyu Sun's avatar Holly Jiuyu Sun Committed by Android (Google) Code Review
Browse files

Merge "[ps] Add helper function to scroll a recycler view to bottom and...

Merge "[ps] Add helper function to scroll a recycler view to bottom and `resetAndScrollToPrivateSpace`." into main
parents dacb0765 d670f303
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -192,4 +192,14 @@ public abstract class FastScrollRecyclerView extends RecyclerView {
        }
        scrollToPosition(0);
    }

    /**
     * Scrolls this recycler view to the bottom.
     */
    public void scrollToBottom() {
        if (mScrollbar != null) {
            mScrollbar.reattachThumbToScroll();
        }
        smoothScrollToPosition(getAdapter().getItemCount() - 1);
    }
}
+24 −0
Original line number Diff line number Diff line
@@ -495,6 +495,30 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        }
    }

    /**
     * Exits search and returns to A-Z apps list. Scroll to the bottom.
     */
    public void resetAndScrollToBottom() {
        if (mTouchHandler != null) {
            mTouchHandler.endFastScrolling();
        }

        // Reset the base recycler view after transitioning home.
        updateHeaderScroll(0);

        // Animate to A-Z with 0 time to reset the animation with proper state management.
        animateToSearchState(false, 0);

        MAIN_EXECUTOR.getHandler().post(() -> {
            // Reset the search bar after transitioning home.
            mSearchUiManager.resetSearch();
            // Switch to the main tab
            switchToTab(ActivityAllAppsContainerView.AdapterHolder.MAIN);
            // Scroll to bottom
            getActiveRecyclerView().scrollToBottom();
        });
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        mSearchUiManager.preDispatchKeyEvent(event);