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

Commit 809e1a8e authored by Shamali P's avatar Shamali P Committed by Shamali Patwa
Browse files

Fix issue that old search results list show up momentarily

After exiting the search, we clear the search results and hide the
results lists (because that recycler view shouldn't be accessible after it). However, it often doesn't get chance to layout the empty data.
So, the next time we show the search results list again with new data,
it first animates to clear the old results and then animates in the new
ones. In this fix,
[demo](http://screencast/cast/NDg5OTg2NzIyMTU1NzI0OHxhMTk0NzEzZS1hYw), we swap the adapter to remove any old views, because old search results aren't valid anymore. Spoke with yigit who worked on RV in past and they suggested swapAdapter
was fine for this.

Other options explored:
1. set item animator = null; so, it doesn't animate flushing out old
results -> but we want animations
2. delay the visibility update to let layout happen -> but, if we are
 hiding the section,  why wait making the other UI updates until
layout?

Bug: 274051332
Flag: N/A
Test: Manual
Change-Id: I9f9c5a67b47b5415b2d9e4caa23fd4b6daf7cdea
parent 1270b081
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -548,6 +548,14 @@ public class WidgetsFullSheet extends BaseWidgetSheet
    public void exitSearchMode() {
    public void exitSearchMode() {
        if (!mIsInSearchMode) return;
        if (!mIsInSearchMode) return;
        onSearchResults(new ArrayList<>());
        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);
        setViewVisibilityBasedOnSearch(/*isInSearchMode=*/ false);
        if (mHasWorkProfile) {
        if (mHasWorkProfile) {
            mViewPager.snapToPage(AdapterHolder.PRIMARY);
            mViewPager.snapToPage(AdapterHolder.PRIMARY);