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

Commit cc80396b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added a ScrollView#scrollToDescendant() API."

parents feabe4e8 6d21df2e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -56669,6 +56669,7 @@ package android.widget {
    method public boolean isFillViewport();
    method public boolean isSmoothScrollingEnabled();
    method public boolean pageScroll(int);
    method public void scrollToDescendant(android.view.View);
    method public void setFillViewport(boolean);
    method public void setSmoothScrollingEnabled(boolean);
    method public final void smoothScrollBy(int, int);
+14 −10
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public class ScrollView extends FrameLayout {
     * layout is dirty. This prevents the scroll from being wrong if the child has not been
     * laid out before requesting focus.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769715)
    private View mChildToScrollTo = null;

    /**
@@ -1384,7 +1384,8 @@ public class ScrollView extends FrameLayout {
     *
     * @param child the View to scroll to
     */
    private void scrollToChild(View child) {
    public void scrollToDescendant(View child) {
        if (!mIsLayoutDirty) {
            child.getDrawingRect(mTempRect);

            /* Offset from child's local coordinates to ScrollView coordinates */
@@ -1395,6 +1396,9 @@ public class ScrollView extends FrameLayout {
            if (scrollDelta != 0) {
                scrollBy(0, scrollDelta);
            }
        } else {
            mChildToScrollTo = child;
        }
    }

    /**
@@ -1488,7 +1492,7 @@ public class ScrollView extends FrameLayout {
    public void requestChildFocus(View child, View focused) {
        if (focused != null && focused.getRevealOnFocusHint()) {
            if (!mIsLayoutDirty) {
                scrollToChild(focused);
                scrollToDescendant(focused);
            } else {
                // The child may not be laid out yet, we can't compute the scroll yet
                mChildToScrollTo = focused;
@@ -1569,7 +1573,7 @@ public class ScrollView extends FrameLayout {
        mIsLayoutDirty = false;
        // Give a child focus if it needs it
        if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this)) {
            scrollToChild(mChildToScrollTo);
            scrollToDescendant(mChildToScrollTo);
        }
        mChildToScrollTo = null;