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

This commit is contained in:
Edgar Wang
2024-07-25 14:51:18 +00:00
committed by Android (Google) Code Review

View File

@@ -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);