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

Commit e279aa4f authored by Tony Huang's avatar Tony Huang Committed by android-build-merger
Browse files

Merge "Fine tune scroll behavior after model update" into qt-dev am: 140b59f4

am: d40c4a69

Change-Id: I4022a3279c8ebeb704dda1812c6249a9464f9e38
parents 8b35ce66 d40c4a69
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);
            }