package androidx.core.graphics.drawable;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;

/* JADX INFO: compiled from: WrappedDrawableApi14.java */
/* JADX INFO: loaded from: classes.dex */
class d extends Drawable implements Drawable.Callback, c, androidx.core.graphics.drawable.b {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    static final PorterDuff.Mode f751c = PorterDuff.Mode.SRC_IN;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private int f752d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private PorterDuff.Mode f753e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private boolean f754f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    a f755g;
    private boolean h;
    Drawable i;

    /* JADX INFO: compiled from: WrappedDrawableApi14.java */
    protected static abstract class a extends Drawable.ConstantState {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        int f756a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        Drawable.ConstantState f757b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        ColorStateList f758c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        PorterDuff.Mode f759d;

        a(a aVar, Resources resources) {
            this.f758c = null;
            this.f759d = d.f751c;
            if (aVar != null) {
                this.f756a = aVar.f756a;
                this.f757b = aVar.f757b;
                this.f758c = aVar.f758c;
                this.f759d = aVar.f759d;
            }
        }

        boolean a() {
            return this.f757b != null;
        }

        @Override // android.graphics.drawable.Drawable.ConstantState
        public int getChangingConfigurations() {
            int i = this.f756a;
            Drawable.ConstantState constantState = this.f757b;
            return i | (constantState != null ? constantState.getChangingConfigurations() : 0);
        }

        @Override // android.graphics.drawable.Drawable.ConstantState
        public Drawable newDrawable() {
            return newDrawable(null);
        }

        @Override // android.graphics.drawable.Drawable.ConstantState
        public abstract Drawable newDrawable(Resources resources);
    }

    /* JADX INFO: compiled from: WrappedDrawableApi14.java */
    private static class b extends a {
        b(a aVar, Resources resources) {
            super(aVar, resources);
        }

        @Override // androidx.core.graphics.drawable.d.a, android.graphics.drawable.Drawable.ConstantState
        public Drawable newDrawable(Resources resources) {
            return new d(this, resources);
        }
    }

    d(a aVar, Resources resources) {
        this.f755g = aVar;
        e(resources);
    }

    private void e(Resources resources) {
        Drawable.ConstantState constantState;
        a aVar = this.f755g;
        if (aVar == null || (constantState = aVar.f757b) == null) {
            return;
        }
        d(constantState.newDrawable(resources));
    }

    private boolean f(int[] iArr) {
        if (!b()) {
            return false;
        }
        a aVar = this.f755g;
        ColorStateList colorStateList = aVar.f758c;
        PorterDuff.Mode mode = aVar.f759d;
        if (colorStateList == null || mode == null) {
            this.f754f = false;
            clearColorFilter();
        } else {
            int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
            if (!this.f754f || colorForState != this.f752d || mode != this.f753e) {
                setColorFilter(colorForState, mode);
                this.f752d = colorForState;
                this.f753e = mode;
                this.f754f = true;
                return true;
            }
        }
        return false;
    }

    @Override // androidx.core.graphics.drawable.c
    public final Drawable a() {
        return this.i;
    }

    protected boolean b() {
        return true;
    }

    a c() {
        return new b(this.f755g, null);
    }

    public final void d(Drawable drawable) {
        Drawable drawable2 = this.i;
        if (drawable2 != null) {
            drawable2.setCallback(null);
        }
        this.i = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            setVisible(drawable.isVisible(), true);
            setState(drawable.getState());
            setLevel(drawable.getLevel());
            setBounds(drawable.getBounds());
            a aVar = this.f755g;
            if (aVar != null) {
                aVar.f757b = drawable.getConstantState();
            }
        }
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public void draw(Canvas canvas) {
        this.i.draw(canvas);
    }

    @Override // android.graphics.drawable.Drawable
    public int getChangingConfigurations() {
        int changingConfigurations = super.getChangingConfigurations();
        a aVar = this.f755g;
        return changingConfigurations | (aVar != null ? aVar.getChangingConfigurations() : 0) | this.i.getChangingConfigurations();
    }

    @Override // android.graphics.drawable.Drawable
    public Drawable.ConstantState getConstantState() {
        a aVar = this.f755g;
        if (aVar == null || !aVar.a()) {
            return null;
        }
        this.f755g.f756a = getChangingConfigurations();
        return this.f755g;
    }

    @Override // android.graphics.drawable.Drawable
    public Drawable getCurrent() {
        return this.i.getCurrent();
    }

    @Override // android.graphics.drawable.Drawable
    public int getIntrinsicHeight() {
        return this.i.getIntrinsicHeight();
    }

    @Override // android.graphics.drawable.Drawable
    public int getIntrinsicWidth() {
        return this.i.getIntrinsicWidth();
    }

    @Override // android.graphics.drawable.Drawable
    public int getMinimumHeight() {
        return this.i.getMinimumHeight();
    }

    @Override // android.graphics.drawable.Drawable
    public int getMinimumWidth() {
        return this.i.getMinimumWidth();
    }

    @Override // android.graphics.drawable.Drawable
    public int getOpacity() {
        return this.i.getOpacity();
    }

    @Override // android.graphics.drawable.Drawable
    public boolean getPadding(Rect rect) {
        return this.i.getPadding(rect);
    }

    @Override // android.graphics.drawable.Drawable
    public int[] getState() {
        return this.i.getState();
    }

    @Override // android.graphics.drawable.Drawable
    public Region getTransparentRegion() {
        return this.i.getTransparentRegion();
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public void invalidateDrawable(Drawable drawable) {
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public boolean isAutoMirrored() {
        return this.i.isAutoMirrored();
    }

    @Override // android.graphics.drawable.Drawable
    public boolean isStateful() {
        a aVar;
        ColorStateList colorStateList = (!b() || (aVar = this.f755g) == null) ? null : aVar.f758c;
        return (colorStateList != null && colorStateList.isStateful()) || this.i.isStateful();
    }

    @Override // android.graphics.drawable.Drawable
    public void jumpToCurrentState() {
        this.i.jumpToCurrentState();
    }

    @Override // android.graphics.drawable.Drawable
    public Drawable mutate() {
        if (!this.h && super.mutate() == this) {
            this.f755g = c();
            Drawable drawable = this.i;
            if (drawable != null) {
                drawable.mutate();
            }
            a aVar = this.f755g;
            if (aVar != null) {
                Drawable drawable2 = this.i;
                aVar.f757b = drawable2 != null ? drawable2.getConstantState() : null;
            }
            this.h = true;
        }
        return this;
    }

    @Override // android.graphics.drawable.Drawable
    protected void onBoundsChange(Rect rect) {
        Drawable drawable = this.i;
        if (drawable != null) {
            drawable.setBounds(rect);
        }
    }

    @Override // android.graphics.drawable.Drawable
    protected boolean onLevelChange(int i) {
        return this.i.setLevel(i);
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
        scheduleSelf(runnable, j);
    }

    @Override // android.graphics.drawable.Drawable
    public void setAlpha(int i) {
        this.i.setAlpha(i);
    }

    @Override // android.graphics.drawable.Drawable
    public void setAutoMirrored(boolean z) {
        this.i.setAutoMirrored(z);
    }

    @Override // android.graphics.drawable.Drawable
    public void setChangingConfigurations(int i) {
        this.i.setChangingConfigurations(i);
    }

    @Override // android.graphics.drawable.Drawable
    public void setColorFilter(ColorFilter colorFilter) {
        this.i.setColorFilter(colorFilter);
    }

    @Override // android.graphics.drawable.Drawable
    public void setDither(boolean z) {
        this.i.setDither(z);
    }

    @Override // android.graphics.drawable.Drawable
    public void setFilterBitmap(boolean z) {
        this.i.setFilterBitmap(z);
    }

    @Override // android.graphics.drawable.Drawable
    public boolean setState(int[] iArr) {
        return f(iArr) || this.i.setState(iArr);
    }

    @Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.b
    public void setTint(int i) {
        setTintList(ColorStateList.valueOf(i));
    }

    @Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.b
    public void setTintList(ColorStateList colorStateList) {
        this.f755g.f758c = colorStateList;
        f(getState());
    }

    @Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.b
    public void setTintMode(PorterDuff.Mode mode) {
        this.f755g.f759d = mode;
        f(getState());
    }

    @Override // android.graphics.drawable.Drawable
    public boolean setVisible(boolean z, boolean z2) {
        return super.setVisible(z, z2) || this.i.setVisible(z, z2);
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
        unscheduleSelf(runnable);
    }

    d(Drawable drawable) {
        this.f755g = c();
        d(drawable);
    }
}
