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

Commit e92602f9 authored by Edgar Wang's avatar Edgar Wang Committed by Android (Google) Code Review
Browse files

Merge "Fix the scrolling behavior in Settings homepage" into main

parents 2f257a19 615133cc
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.widget;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
@@ -212,6 +213,14 @@ public class HighlightableTopLevelPreferenceAdapter extends RoundCornerPreferenc
        // Scroll to the top to reset the position.
        mRecyclerView.nestedScrollBy(0, -mRecyclerView.getHeight());

        // get the visible area of the recycler view
        Rect rvRect = new Rect();
        mRecyclerView.getGlobalVisibleRect(rvRect);
        if (Flags.homepageRevamp() && view.getBottom() <= rvRect.height()) {
            // the request position already fully visible in the visible area
            return;
        }

        final int scrollY = view.getTop();
        if (scrollY > 0) {
            mRecyclerView.nestedScrollBy(0, scrollY);