jimu-decompiled/sources/androidx/core/widget/CompoundButtonCompat.java
2025-05-13 19:24:51 +02:00

59 lines
2.1 KiB
Java

package androidx.core.widget;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;
import android.widget.CompoundButton;
import java.lang.reflect.Field;
/* loaded from: classes.dex */
public final class CompoundButtonCompat {
private static Field a;
private static boolean b;
/* JADX WARN: Multi-variable type inference failed */
public static void a(CompoundButton compoundButton, ColorStateList colorStateList) {
if (Build.VERSION.SDK_INT >= 21) {
compoundButton.setButtonTintList(colorStateList);
} else if (compoundButton instanceof TintableCompoundButton) {
((TintableCompoundButton) compoundButton).setSupportButtonTintList(colorStateList);
}
}
/* JADX WARN: Multi-variable type inference failed */
public static void a(CompoundButton compoundButton, PorterDuff.Mode mode) {
if (Build.VERSION.SDK_INT >= 21) {
compoundButton.setButtonTintMode(mode);
} else if (compoundButton instanceof TintableCompoundButton) {
((TintableCompoundButton) compoundButton).setSupportButtonTintMode(mode);
}
}
public static Drawable a(CompoundButton compoundButton) {
if (Build.VERSION.SDK_INT >= 23) {
return compoundButton.getButtonDrawable();
}
if (!b) {
try {
a = CompoundButton.class.getDeclaredField("mButtonDrawable");
a.setAccessible(true);
} catch (NoSuchFieldException e) {
Log.i("CompoundButtonCompat", "Failed to retrieve mButtonDrawable field", e);
}
b = true;
}
Field field = a;
if (field != null) {
try {
return (Drawable) field.get(compoundButton);
} catch (IllegalAccessException e2) {
Log.i("CompoundButtonCompat", "Failed to get button drawable via reflection", e2);
a = null;
}
}
return null;
}
}