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

Commit 0090f200 authored by Adam Powell's avatar Adam Powell
Browse files

Fix a padding resolution bug for adapter-based views

If padding has not been resolved by the time measure() is called,
resolve it.

Bug 6938579

Change-Id: Idd3ffa3e4e441cd462d6594b1e20d153d7632994
parent 4224790f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -2076,6 +2076,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    static final int VIEW_QUICK_REJECTED = 0x10000000;
    /**
     * Flag indicating that start/end padding has been resolved into left/right padding
     * for use in measurement, layout, drawing, etc. This is set by {@link #resolvePadding()}
     * and checked by {@link #measure(int, int)} to determine if padding needs to be resolved
     * during measurement. In some special cases this is required such as when an adapter-based
     * view measures prospective children without attaching them to a window.
     */
    static final int PADDING_RESOLVED = 0x20000000;
    // There are a couple of flags left in mPrivateFlags2
    /* End of masks for mPrivateFlags2 */
@@ -11335,6 +11344,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        internalSetPadding(mUserPaddingLeft, mPaddingTop, mUserPaddingRight, mUserPaddingBottom);
        onPaddingChanged(resolvedLayoutDirection);
        mPrivateFlags2 |= PADDING_RESOLVED;
    }
    /**
@@ -11430,6 +11440,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        resetResolvedLayoutDirection();
        resetResolvedTextAlignment();
        resetAccessibilityStateChanged();
        mPrivateFlags2 &= ~PADDING_RESOLVED;
    }
    /**
@@ -14949,6 +14960,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // first clears the measured dimension flag
            mPrivateFlags &= ~MEASURED_DIMENSION_SET;
            if ((mPrivateFlags2 & PADDING_RESOLVED) == 0) {
                resolvePadding();
            }
            // measure ourselves, this should set the measured dimension flag back
            onMeasure(widthMeasureSpec, heightMeasureSpec);