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

Commit d40c4a69 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

Change-Id: I2a0a3efecc6611a1f479b46888c30999512201b7
parents 44376d52 140b59f4
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -177,6 +177,12 @@ public abstract class BaseActivity
                }
                }


                mInjector.actions.loadDocumentsForCurrentStack();
                mInjector.actions.loadDocumentsForCurrentStack();

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


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


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

    @Override
    @Override
    public void onRefresh() {
    public void onRefresh() {
        // Remove thumbnail cache. We do this not because we're worried about stale thumbnails as it
        // 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;
                mRestoredState = null;
            }
            }


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


            final SortDimension curSortedDimension =
            final SortDimension curSortedDimension =
                    mState.sortModel.getDimensionById(curSortedDimensionId);
                    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.mLastSortDimensionId = curSortedDimension.getId();
            mLocalState.mLastSortDirection = curSortedDimension.getSortDirection();
            mLocalState.mLastSortDirection = curSortedDimension.getSortDirection();


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


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


                setPreDrawListener(true);
                setPreDrawListener(true);
            }
            }