discord-jadx/app/src/main/java/androidx/core/widget/CheckedTextViewCompat.java

108 lines
3.8 KiB
Java

package androidx.core.widget;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.widget.CheckedTextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.lang.reflect.Field;
public final class CheckedTextViewCompat {
private static final String TAG = "CheckedTextViewCompat";
public static class Api14Impl {
private static Field sCheckMarkDrawableField;
private static boolean sResolved;
private Api14Impl() {
}
@Nullable
public static Drawable getCheckMarkDrawable(@NonNull CheckedTextView checkedTextView) {
if (!sResolved) {
try {
Field declaredField = CheckedTextView.class.getDeclaredField("mCheckMarkDrawable");
sCheckMarkDrawableField = declaredField;
declaredField.setAccessible(true);
} catch (NoSuchFieldException e) {
Log.i(CheckedTextViewCompat.TAG, "Failed to retrieve mCheckMarkDrawable field", e);
}
sResolved = true;
}
Field field = sCheckMarkDrawableField;
if (field != null) {
try {
return (Drawable) field.get(checkedTextView);
} catch (IllegalAccessException e2) {
Log.i(CheckedTextViewCompat.TAG, "Failed to get check mark drawable via reflection", e2);
sCheckMarkDrawableField = null;
}
}
return null;
}
}
@RequiresApi(16)
public static class Api16Impl {
private Api16Impl() {
}
@Nullable
public static Drawable getCheckMarkDrawable(@NonNull CheckedTextView checkedTextView) {
return checkedTextView.getCheckMarkDrawable();
}
}
@RequiresApi(21)
public static class Api21Impl {
private Api21Impl() {
}
@Nullable
public static ColorStateList getCheckMarkTintList(@NonNull CheckedTextView checkedTextView) {
return checkedTextView.getCheckMarkTintList();
}
@Nullable
public static PorterDuff.Mode getCheckMarkTintMode(@NonNull CheckedTextView checkedTextView) {
return checkedTextView.getCheckMarkTintMode();
}
public static void setCheckMarkTintList(@NonNull CheckedTextView checkedTextView, @Nullable ColorStateList colorStateList) {
checkedTextView.setCheckMarkTintList(colorStateList);
}
public static void setCheckMarkTintMode(@NonNull CheckedTextView checkedTextView, @Nullable PorterDuff.Mode mode) {
checkedTextView.setCheckMarkTintMode(mode);
}
}
private CheckedTextViewCompat() {
}
@Nullable
public static Drawable getCheckMarkDrawable(@NonNull CheckedTextView checkedTextView) {
return Api16Impl.getCheckMarkDrawable(checkedTextView);
}
@Nullable
public static ColorStateList getCheckMarkTintList(@NonNull CheckedTextView checkedTextView) {
return Api21Impl.getCheckMarkTintList(checkedTextView);
}
@Nullable
public static PorterDuff.Mode getCheckMarkTintMode(@NonNull CheckedTextView checkedTextView) {
return Api21Impl.getCheckMarkTintMode(checkedTextView);
}
public static void setCheckMarkTintList(@NonNull CheckedTextView checkedTextView, @Nullable ColorStateList colorStateList) {
Api21Impl.setCheckMarkTintList(checkedTextView, colorStateList);
}
public static void setCheckMarkTintMode(@NonNull CheckedTextView checkedTextView, @Nullable PorterDuff.Mode mode) {
Api21Impl.setCheckMarkTintMode(checkedTextView, mode);
}
}