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

Commit a71a7033 authored by Yigit Boyar's avatar Yigit Boyar Committed by android-build-merger
Browse files

Merge "Invalidate child bounds when AbsListView bounds change" into nyc-dev...

Merge "Invalidate child bounds when AbsListView bounds change" into nyc-dev am: bb039d2f am: 1968ffe2
am: cd44c163

* commit 'cd44c163':
  Invalidate child bounds when AbsListView bounds change

Change-Id: I32e6b83700ca9ba9799a1bd4349f2ca2d44b8e61
parents b9746650 cd44c163
Loading
Loading
Loading
Loading
+34 −4
Original line number Diff line number Diff line
@@ -2675,18 +2675,48 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        return (mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK ? 0 : mPaddingBottom;
    }

    /**
     * @hide
     */
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        if (getChildCount() > 0) {
            mDataChanged = true;
            rememberSyncState();
    protected void internalSetPadding(int left, int top, int right, int bottom) {
        super.internalSetPadding(left, top, right, bottom);
        if (isLayoutRequested()) {
            handleBoundsChange();
        }
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        handleBoundsChange();
        if (mFastScroll != null) {
            mFastScroll.onSizeChanged(w, h, oldw, oldh);
        }
    }

    /**
     * Called when bounds of the AbsListView are changed. AbsListView marks data set as changed
     * and force layouts all children that don't have exact measure specs.
     * <p>
     * This invalidation is necessary, otherwise, AbsListView may think the children are valid and
     * fail to relayout them properly to accommodate for new bounds.
     */
    void handleBoundsChange() {
        final int childCount = getChildCount();
        if (childCount > 0) {
            mDataChanged = true;
            rememberSyncState();
            for (int i = 0; i < childCount; i++) {
                final View child = getChildAt(i);
                final ViewGroup.LayoutParams lp = child.getLayoutParams();
                // force layout child unless it has exact specs
                if (lp == null || lp.width < 1 || lp.height < 1) {
                    child.forceLayout();
                }
            }
        }
    }

    /**
     * @return True if the current touch mode requires that we draw the selector in the pressed
     *         state.