package androidx.appcompat.widget; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.CompoundButton; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.R; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.view.ViewCompat; import androidx.core.widget.CompoundButtonCompat; public class AppCompatCompoundButtonHelper { private ColorStateList mButtonTintList = null; private PorterDuff.Mode mButtonTintMode = null; private boolean mHasButtonTint = false; private boolean mHasButtonTintMode = false; private boolean mSkipNextApply; @NonNull private final CompoundButton mView; public AppCompatCompoundButtonHelper(@NonNull CompoundButton compoundButton) { this.mView = compoundButton; } public void applyButtonTint() { Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this.mView); if (buttonDrawable == null) { return; } if (this.mHasButtonTint || this.mHasButtonTintMode) { Drawable mutate = DrawableCompat.wrap(buttonDrawable).mutate(); if (this.mHasButtonTint) { DrawableCompat.setTintList(mutate, this.mButtonTintList); } if (this.mHasButtonTintMode) { DrawableCompat.setTintMode(mutate, this.mButtonTintMode); } if (mutate.isStateful()) { mutate.setState(this.mView.getDrawableState()); } this.mView.setButtonDrawable(mutate); } } public int getCompoundPaddingLeft(int i) { return i; } public ColorStateList getSupportButtonTintList() { return this.mButtonTintList; } public PorterDuff.Mode getSupportButtonTintMode() { return this.mButtonTintMode; } /* JADX WARNING: Removed duplicated region for block: B:12:0x003d */ /* JADX WARNING: Removed duplicated region for block: B:19:0x0060 */ /* JADX WARNING: Removed duplicated region for block: B:22:0x0071 */ public void loadFromAttributes(@Nullable AttributeSet attributeSet, int i) { boolean z2; int i2; int i3; int resourceId; int resourceId2; Context context = this.mView.getContext(); int[] iArr = R.styleable.CompoundButton; TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, iArr, i, 0); CompoundButton compoundButton = this.mView; ViewCompat.saveAttributeDataForStyleable(compoundButton, compoundButton.getContext(), iArr, attributeSet, obtainStyledAttributes.getWrappedTypeArray(), i, 0); try { int i4 = R.styleable.CompoundButton_buttonCompat; if (obtainStyledAttributes.hasValue(i4) && (resourceId2 = obtainStyledAttributes.getResourceId(i4, 0)) != 0) { try { CompoundButton compoundButton2 = this.mView; compoundButton2.setButtonDrawable(AppCompatResources.getDrawable(compoundButton2.getContext(), resourceId2)); z2 = true; } catch (Resources.NotFoundException unused) { } if (!z2) { int i5 = R.styleable.CompoundButton_android_button; if (obtainStyledAttributes.hasValue(i5) && (resourceId = obtainStyledAttributes.getResourceId(i5, 0)) != 0) { CompoundButton compoundButton3 = this.mView; compoundButton3.setButtonDrawable(AppCompatResources.getDrawable(compoundButton3.getContext(), resourceId)); } } i2 = R.styleable.CompoundButton_buttonTint; if (obtainStyledAttributes.hasValue(i2)) { CompoundButtonCompat.setButtonTintList(this.mView, obtainStyledAttributes.getColorStateList(i2)); } i3 = R.styleable.CompoundButton_buttonTintMode; if (obtainStyledAttributes.hasValue(i3)) { CompoundButtonCompat.setButtonTintMode(this.mView, DrawableUtils.parseTintMode(obtainStyledAttributes.getInt(i3, -1), null)); } } z2 = false; if (!z2) { } i2 = R.styleable.CompoundButton_buttonTint; if (obtainStyledAttributes.hasValue(i2)) { } i3 = R.styleable.CompoundButton_buttonTintMode; if (obtainStyledAttributes.hasValue(i3)) { } } finally { obtainStyledAttributes.recycle(); } } public void onSetButtonDrawable() { if (this.mSkipNextApply) { this.mSkipNextApply = false; return; } this.mSkipNextApply = true; applyButtonTint(); } public void setSupportButtonTintList(ColorStateList colorStateList) { this.mButtonTintList = colorStateList; this.mHasButtonTint = true; applyButtonTint(); } public void setSupportButtonTintMode(@Nullable PorterDuff.Mode mode) { this.mButtonTintMode = mode; this.mHasButtonTintMode = true; applyButtonTint(); } }