Merge "Fix issue that old search results list show up momentarily" into 24D1-dev

This commit is contained in:
Shamali Patwa
2024-04-15 20:06:32 +00:00
committed by Android (Google) Code Review
@@ -541,6 +541,14 @@ public class WidgetsFullSheet extends BaseWidgetSheet
public void exitSearchMode() {
if (!mIsInSearchMode) return;
onSearchResults(new ArrayList<>());
WidgetsRecyclerView searchRecyclerView = mAdapters.get(
AdapterHolder.SEARCH).mWidgetsRecyclerView;
// Remove all views when exiting the search mode; this prevents animating from stale results
// to new ones the next time we enter search mode. By the time recycler view is hidden,
// layout may not have happened to clear up existing results. So, instead of waiting for it
// to happen, we clear the views here.
searchRecyclerView.swapAdapter(
searchRecyclerView.getAdapter(), /*removeAndRecycleExistingViews=*/ true);
setViewVisibilityBasedOnSearch(/*isInSearchMode=*/ false);
if (mHasWorkProfile) {
mViewPager.snapToPage(AdapterHolder.PRIMARY);