99 lines
3.2 KiB
Java
99 lines
3.2 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.content.res.ColorStateList;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Build;
|
|
import android.util.AttributeSet;
|
|
import android.widget.CompoundButton;
|
|
import androidx.appcompat.R$styleable;
|
|
import androidx.appcompat.content.res.AppCompatResources;
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
import androidx.core.widget.CompoundButtonCompat;
|
|
|
|
/* loaded from: classes.dex */
|
|
class AppCompatCompoundButtonHelper {
|
|
private final CompoundButton a;
|
|
private ColorStateList b = null;
|
|
private PorterDuff.Mode c = null;
|
|
private boolean d = false;
|
|
private boolean e = false;
|
|
private boolean f;
|
|
|
|
AppCompatCompoundButtonHelper(CompoundButton compoundButton) {
|
|
this.a = compoundButton;
|
|
}
|
|
|
|
void a(AttributeSet attributeSet, int i) {
|
|
int resourceId;
|
|
TypedArray obtainStyledAttributes = this.a.getContext().obtainStyledAttributes(attributeSet, R$styleable.CompoundButton, i, 0);
|
|
try {
|
|
if (obtainStyledAttributes.hasValue(R$styleable.CompoundButton_android_button) && (resourceId = obtainStyledAttributes.getResourceId(R$styleable.CompoundButton_android_button, 0)) != 0) {
|
|
this.a.setButtonDrawable(AppCompatResources.c(this.a.getContext(), resourceId));
|
|
}
|
|
if (obtainStyledAttributes.hasValue(R$styleable.CompoundButton_buttonTint)) {
|
|
CompoundButtonCompat.a(this.a, obtainStyledAttributes.getColorStateList(R$styleable.CompoundButton_buttonTint));
|
|
}
|
|
if (obtainStyledAttributes.hasValue(R$styleable.CompoundButton_buttonTintMode)) {
|
|
CompoundButtonCompat.a(this.a, DrawableUtils.a(obtainStyledAttributes.getInt(R$styleable.CompoundButton_buttonTintMode, -1), null));
|
|
}
|
|
} finally {
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
}
|
|
|
|
ColorStateList b() {
|
|
return this.b;
|
|
}
|
|
|
|
PorterDuff.Mode c() {
|
|
return this.c;
|
|
}
|
|
|
|
void d() {
|
|
if (this.f) {
|
|
this.f = false;
|
|
} else {
|
|
this.f = true;
|
|
a();
|
|
}
|
|
}
|
|
|
|
void a(ColorStateList colorStateList) {
|
|
this.b = colorStateList;
|
|
this.d = true;
|
|
a();
|
|
}
|
|
|
|
void a(PorterDuff.Mode mode) {
|
|
this.c = mode;
|
|
this.e = true;
|
|
a();
|
|
}
|
|
|
|
void a() {
|
|
Drawable a = CompoundButtonCompat.a(this.a);
|
|
if (a != null) {
|
|
if (this.d || this.e) {
|
|
Drawable mutate = DrawableCompat.h(a).mutate();
|
|
if (this.d) {
|
|
DrawableCompat.a(mutate, this.b);
|
|
}
|
|
if (this.e) {
|
|
DrawableCompat.a(mutate, this.c);
|
|
}
|
|
if (mutate.isStateful()) {
|
|
mutate.setState(this.a.getDrawableState());
|
|
}
|
|
this.a.setButtonDrawable(mutate);
|
|
}
|
|
}
|
|
}
|
|
|
|
int a(int i) {
|
|
Drawable a;
|
|
return (Build.VERSION.SDK_INT >= 17 || (a = CompoundButtonCompat.a(this.a)) == null) ? i : i + a.getIntrinsicWidth();
|
|
}
|
|
}
|