package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.ImageButton;
import android.widget.ImageView;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.view.x0;
import l.g0;
import l.l3;
import l.m3;
import l.n3;
import l.y;
import u0.u;

/* JADX INFO: loaded from: classes.dex */
public class AppCompatImageButton extends ImageButton implements x0, u {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final y f665a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final g0 f666b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f667c;

    public AppCompatImageButton(@NonNull Context context) {
        this(context, null);
    }

    @Override // android.widget.ImageView, android.view.View
    public final void drawableStateChanged() {
        super.drawableStateChanged();
        y yVar = this.f665a;
        if (yVar != null) {
            yVar.a();
        }
        g0 g0Var = this.f666b;
        if (g0Var != null) {
            g0Var.a();
        }
    }

    @Override // androidx.core.view.x0
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public ColorStateList getSupportBackgroundTintList() {
        y yVar = this.f665a;
        if (yVar != null) {
            return yVar.b();
        }
        return null;
    }

    @Override // androidx.core.view.x0
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public PorterDuff.Mode getSupportBackgroundTintMode() {
        y yVar = this.f665a;
        if (yVar != null) {
            return yVar.c();
        }
        return null;
    }

    @Override // u0.u
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public ColorStateList getSupportImageTintList() {
        n3 n3Var;
        g0 g0Var = this.f666b;
        if (g0Var == null || (n3Var = g0Var.f29686b) == null) {
            return null;
        }
        return n3Var.f29782a;
    }

    @Override // u0.u
    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public PorterDuff.Mode getSupportImageTintMode() {
        n3 n3Var;
        g0 g0Var = this.f666b;
        if (g0Var == null || (n3Var = g0Var.f29686b) == null) {
            return null;
        }
        return n3Var.f29783b;
    }

    @Override // android.widget.ImageView, android.view.View
    public final boolean hasOverlappingRendering() {
        return ((this.f666b.f29685a.getBackground() instanceof RippleDrawable) ^ true) && super.hasOverlappingRendering();
    }

    @Override // android.view.View
    public void setBackgroundDrawable(@Nullable Drawable drawable) {
        super.setBackgroundDrawable(drawable);
        y yVar = this.f665a;
        if (yVar != null) {
            yVar.d();
        }
    }

    @Override // android.view.View
    public void setBackgroundResource(@DrawableRes int i10) {
        super.setBackgroundResource(i10);
        y yVar = this.f665a;
        if (yVar != null) {
            yVar.e(i10);
        }
    }

    @Override // android.widget.ImageView
    public void setImageBitmap(Bitmap bitmap) {
        super.setImageBitmap(bitmap);
        g0 g0Var = this.f666b;
        if (g0Var != null) {
            g0Var.a();
        }
    }

    @Override // android.widget.ImageView
    public void setImageDrawable(@Nullable Drawable drawable) {
        g0 g0Var = this.f666b;
        if (g0Var != null && drawable != null && !this.f667c) {
            g0Var.f29687c = drawable.getLevel();
        }
        super.setImageDrawable(drawable);
        if (g0Var != null) {
            g0Var.a();
            if (this.f667c) {
                return;
            }
            ImageView imageView = g0Var.f29685a;
            if (imageView.getDrawable() != null) {
                imageView.getDrawable().setLevel(g0Var.f29687c);
            }
        }
    }

    @Override // android.widget.ImageView
    public void setImageLevel(int i10) {
        super.setImageLevel(i10);
        this.f667c = true;
    }

    @Override // android.widget.ImageView
    public void setImageResource(@DrawableRes int i10) {
        this.f666b.c(i10);
    }

    @Override // android.widget.ImageView
    public void setImageURI(@Nullable Uri uri) {
        super.setImageURI(uri);
        g0 g0Var = this.f666b;
        if (g0Var != null) {
            g0Var.a();
        }
    }

    @Override // androidx.core.view.x0
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportBackgroundTintList(@Nullable ColorStateList colorStateList) {
        y yVar = this.f665a;
        if (yVar != null) {
            yVar.g(colorStateList);
        }
    }

    @Override // androidx.core.view.x0
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode mode) {
        y yVar = this.f665a;
        if (yVar != null) {
            yVar.h(mode);
        }
    }

    @Override // u0.u
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportImageTintList(@Nullable ColorStateList colorStateList) {
        g0 g0Var = this.f666b;
        if (g0Var != null) {
            if (g0Var.f29686b == null) {
                g0Var.f29686b = new n3();
            }
            n3 n3Var = g0Var.f29686b;
            n3Var.f29782a = colorStateList;
            n3Var.f29785d = true;
            g0Var.a();
        }
    }

    @Override // u0.u
    @RestrictTo({RestrictTo.Scope.f557c})
    public void setSupportImageTintMode(@Nullable PorterDuff.Mode mode) {
        g0 g0Var = this.f666b;
        if (g0Var != null) {
            if (g0Var.f29686b == null) {
                g0Var.f29686b = new n3();
            }
            n3 n3Var = g0Var.f29686b;
            n3Var.f29783b = mode;
            n3Var.f29784c = true;
            g0Var.a();
        }
    }

    public AppCompatImageButton(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, d.a.imageButtonStyle);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public AppCompatImageButton(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        m3.a(context);
        this.f667c = false;
        l3.a(getContext(), this);
        y yVar = new y(this);
        this.f665a = yVar;
        yVar.loadFromAttributes(attributeSet, i10);
        g0 g0Var = new g0(this);
        this.f666b = g0Var;
        g0Var.b(attributeSet, i10);
    }
}
