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

Commit 98c465a9 authored by Tony Huang's avatar Tony Huang
Browse files

Fine tune scroll behavior after model update

In search history patch, it add scroll to top call in model update
callback for better UX after search, however, it cause it always
scroll to top after preview file.
Revert code back in model update callback and scoll to top behavior
code to search callback.

Fix: 131423704
Test: manual
Test: atest DocumentsUIGoogleTests
Change-Id: I870bb15fb79c92e494d02f0c72a4f6a5a9d15a36
parent 3b30dc16
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -177,6 +177,12 @@ public abstract class BaseActivity
                }

                mInjector.actions.loadDocumentsForCurrentStack();

                expandAppBar();
                DirectoryFragment dir = getDirectoryFragment();
                if (dir != null) {
                    dir.scrollToTop();
                }
            }

            @Override
+23 −3
Original line number Diff line number Diff line
@@ -1095,6 +1095,15 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
        return R.id.container_directory;
    }

    /**
     *  Scroll recycler view in fregment to top
     */
    public void scrollToTop() {
        if (mRecView != null) {
            mRecView.scrollToPosition(0);
        }
    }

    @Override
    public void onRefresh() {
        // Remove thumbnail cache. We do this not because we're worried about stale thumbnails as it
@@ -1145,11 +1154,25 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
                mRestoredState = null;
            }

            // Restore any previous instance state
            final SparseArray<Parcelable> container =
                    mState.dirConfigs.remove(mLocalState.getConfigKey());
            final int curSortedDimensionId = mState.sortModel.getSortedDimensionId();

            final SortDimension curSortedDimension =
                    mState.sortModel.getDimensionById(curSortedDimensionId);

            // Default not restore to avoid app bar layout expand to confuse users.
            if (container != null
                    && !getArguments().getBoolean(Shared.EXTRA_IGNORE_STATE, true)) {
                getView().restoreHierarchyState(container);
            } else if (mLocalState.mLastSortDimensionId != curSortedDimension.getId()
                    || mLocalState.mLastSortDimensionId == SortModel.SORT_DIMENSION_ID_UNKNOWN
                    || mLocalState.mLastSortDirection != curSortedDimension.getSortDirection()) {
                // Scroll to the top if the sort order actually changed.
                mRecView.smoothScrollToPosition(0);
            }

            mLocalState.mLastSortDimensionId = curSortedDimension.getId();
            mLocalState.mLastSortDirection = curSortedDimension.getSortDirection();

@@ -1168,9 +1191,6 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
                mInjector.menuManager.updateOptionMenu();

                mActivity.updateHeaderTitle();
                mActivity.expandAppBar();
                // Always back to top avoid app bar layout overlay on container.
                mRecView.scrollToPosition(0);

                setPreDrawListener(true);
            }