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

Commit ad0020f8 authored by Alan Viverette's avatar Alan Viverette
Browse files

Invalidate when Drawable.setState() returns true

Ensures views that manage drawables follow the contract set forth in
the Drawable.setState() documentation.

Bug: 23792020
Change-Id: I4e5a449cd6535487873fd8443da50555c38e8ed9
parent 3916e7e7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -256,10 +256,10 @@ public class MediaRouteButton extends View {
    protected void drawableStateChanged() {
        super.drawableStateChanged();

        if (mRemoteIndicator != null) {
            int[] myDrawableState = getDrawableState();
            mRemoteIndicator.setState(myDrawableState);
            invalidate();
        final Drawable remoteIndicator = mRemoteIndicator;
        if (remoteIndicator != null && remoteIndicator.isStateful()
                && remoteIndicator.setState(getDrawableState())) {
            invalidateDrawable(remoteIndicator);
        }
    }

+10 −4
Original line number Diff line number Diff line
@@ -17042,27 +17042,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    @CallSuper
    protected void drawableStateChanged() {
        final int[] state = getDrawableState();
        boolean changed = false;
        final Drawable bg = mBackground;
        if (bg != null && bg.isStateful()) {
            bg.setState(state);
            changed |= bg.setState(state);
        }
        final Drawable fg = mForegroundInfo != null ? mForegroundInfo.mDrawable : null;
        if (fg != null && fg.isStateful()) {
            fg.setState(state);
            changed |= fg.setState(state);
        }
        if (mScrollCache != null) {
            final Drawable scrollBar = mScrollCache.scrollBar;
            if (scrollBar != null && scrollBar.isStateful()) {
                scrollBar.setState(state);
                changed |= scrollBar.setState(state)
                        && mScrollCache.state != ScrollabilityCache.OFF;
            }
        }
        if (mStateListAnimator != null) {
            mStateListAnimator.setState(state);
        }
        if (changed) {
            invalidate();
        }
    }
    /**
+6 −3
Original line number Diff line number Diff line
@@ -2777,11 +2777,14 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    }

    void updateSelectorState() {
        if (mSelector != null) {
        final Drawable selector = mSelector;
        if (selector != null && selector.isStateful()) {
            if (shouldShowSelector()) {
                mSelector.setState(getDrawableStateForSelector());
                if (selector.setState(getDrawableStateForSelector())) {
                    invalidateDrawable(selector);
                }
            } else {
                mSelector.setState(StateSet.NOTHING);
                selector.setState(StateSet.NOTHING);
            }
        }
    }
+3 −2
Original line number Diff line number Diff line
@@ -369,8 +369,9 @@ public abstract class AbsSeekBar extends ProgressBar {
        }

        final Drawable thumb = mThumb;
        if (thumb != null && thumb.isStateful()) {
            thumb.setState(getDrawableState());
        if (thumb != null && thumb.isStateful()
                && thumb.setState(getDrawableState())) {
            invalidateDrawable(thumb);
        }
    }

+5 −8
Original line number Diff line number Diff line
@@ -426,13 +426,10 @@ public class CheckedTextView extends TextView implements Checkable {
    protected void drawableStateChanged() {
        super.drawableStateChanged();

        if (mCheckMarkDrawable != null) {
            int[] myDrawableState = getDrawableState();
            
            // Set the state of the Drawable
            mCheckMarkDrawable.setState(myDrawableState);
            
            invalidate();
        final Drawable checkMarkDrawable = mCheckMarkDrawable;
        if (checkMarkDrawable != null && checkMarkDrawable.isStateful()
                && checkMarkDrawable.setState(getDrawableState())) {
            invalidateDrawable(checkMarkDrawable);
        }
    }

Loading