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

Commit 00cdbce6 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Clear check mark resource ID when set from Drawable object"

parents 3111d4e1 c60feca6
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -152,13 +152,8 @@ public class CheckedTextView extends TextView implements Checkable {
            return;
        }

        mCheckMarkResource = resId;

        Drawable d = null;
        if (mCheckMarkResource != 0) {
            d = getContext().getDrawable(mCheckMarkResource);
        }
        setCheckMarkDrawable(d);
        final Drawable d = resId != 0 ? getContext().getDrawable(resId) : null;
        setCheckMarkDrawableInternal(d, resId);
    }

    /**
@@ -172,12 +167,18 @@ public class CheckedTextView extends TextView implements Checkable {
     * @see #setCheckMarkDrawable(int)
     * @see #getCheckMarkDrawable()
     */
    public void setCheckMarkDrawable(Drawable d) {
    public void setCheckMarkDrawable(@Nullable Drawable d) {
        setCheckMarkDrawableInternal(d, 0);
    }

    private void setCheckMarkDrawableInternal(@Nullable Drawable d, @DrawableRes int resId) {
        if (mCheckMarkDrawable != null) {
            mCheckMarkDrawable.setCallback(null);
            unscheduleDrawable(mCheckMarkDrawable);
        }

        mNeedRequestlayout = (d != mCheckMarkDrawable);

        if (d != null) {
            d.setCallback(this);
            d.setVisible(getVisibility() == VISIBLE, false);
@@ -190,7 +191,9 @@ public class CheckedTextView extends TextView implements Checkable {
        } else {
            mCheckMarkWidth = 0;
        }

        mCheckMarkDrawable = d;
        mCheckMarkResource = resId;

        // Do padding resolution. This will call internalSetPadding() and do a
        // requestLayout() if needed.