Initial commit
This commit is contained in:
154
sources/androidx/appcompat/widget/AppCompatBackgroundHelper.java
Normal file
154
sources/androidx/appcompat/widget/AppCompatBackgroundHelper.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package androidx.appcompat.widget;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.R$styleable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class AppCompatBackgroundHelper {
|
||||
private final View a;
|
||||
private TintInfo d;
|
||||
private TintInfo e;
|
||||
private TintInfo f;
|
||||
private int c = -1;
|
||||
private final AppCompatDrawableManager b = AppCompatDrawableManager.a();
|
||||
|
||||
AppCompatBackgroundHelper(View view) {
|
||||
this.a = view;
|
||||
}
|
||||
|
||||
private boolean d() {
|
||||
int i = Build.VERSION.SDK_INT;
|
||||
return i > 21 ? this.d != null : i == 21;
|
||||
}
|
||||
|
||||
void a(AttributeSet attributeSet, int i) {
|
||||
TintTypedArray a = TintTypedArray.a(this.a.getContext(), attributeSet, R$styleable.ViewBackgroundHelper, i, 0);
|
||||
try {
|
||||
if (a.g(R$styleable.ViewBackgroundHelper_android_background)) {
|
||||
this.c = a.g(R$styleable.ViewBackgroundHelper_android_background, -1);
|
||||
ColorStateList b = this.b.b(this.a.getContext(), this.c);
|
||||
if (b != null) {
|
||||
a(b);
|
||||
}
|
||||
}
|
||||
if (a.g(R$styleable.ViewBackgroundHelper_backgroundTint)) {
|
||||
ViewCompat.a(this.a, a.a(R$styleable.ViewBackgroundHelper_backgroundTint));
|
||||
}
|
||||
if (a.g(R$styleable.ViewBackgroundHelper_backgroundTintMode)) {
|
||||
ViewCompat.a(this.a, DrawableUtils.a(a.d(R$styleable.ViewBackgroundHelper_backgroundTintMode, -1), null));
|
||||
}
|
||||
} finally {
|
||||
a.a();
|
||||
}
|
||||
}
|
||||
|
||||
void b(ColorStateList colorStateList) {
|
||||
if (this.e == null) {
|
||||
this.e = new TintInfo();
|
||||
}
|
||||
TintInfo tintInfo = this.e;
|
||||
tintInfo.a = colorStateList;
|
||||
tintInfo.d = true;
|
||||
a();
|
||||
}
|
||||
|
||||
PorterDuff.Mode c() {
|
||||
TintInfo tintInfo = this.e;
|
||||
if (tintInfo != null) {
|
||||
return tintInfo.b;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
ColorStateList b() {
|
||||
TintInfo tintInfo = this.e;
|
||||
if (tintInfo != null) {
|
||||
return tintInfo.a;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean b(Drawable drawable) {
|
||||
if (this.f == null) {
|
||||
this.f = new TintInfo();
|
||||
}
|
||||
TintInfo tintInfo = this.f;
|
||||
tintInfo.a();
|
||||
ColorStateList c = ViewCompat.c(this.a);
|
||||
if (c != null) {
|
||||
tintInfo.d = true;
|
||||
tintInfo.a = c;
|
||||
}
|
||||
PorterDuff.Mode d = ViewCompat.d(this.a);
|
||||
if (d != null) {
|
||||
tintInfo.c = true;
|
||||
tintInfo.b = d;
|
||||
}
|
||||
if (!tintInfo.d && !tintInfo.c) {
|
||||
return false;
|
||||
}
|
||||
AppCompatDrawableManager.a(drawable, tintInfo, this.a.getDrawableState());
|
||||
return true;
|
||||
}
|
||||
|
||||
void a(int i) {
|
||||
this.c = i;
|
||||
AppCompatDrawableManager appCompatDrawableManager = this.b;
|
||||
a(appCompatDrawableManager != null ? appCompatDrawableManager.b(this.a.getContext(), i) : null);
|
||||
a();
|
||||
}
|
||||
|
||||
void a(Drawable drawable) {
|
||||
this.c = -1;
|
||||
a((ColorStateList) null);
|
||||
a();
|
||||
}
|
||||
|
||||
void a(PorterDuff.Mode mode) {
|
||||
if (this.e == null) {
|
||||
this.e = new TintInfo();
|
||||
}
|
||||
TintInfo tintInfo = this.e;
|
||||
tintInfo.b = mode;
|
||||
tintInfo.c = true;
|
||||
a();
|
||||
}
|
||||
|
||||
void a() {
|
||||
Drawable background = this.a.getBackground();
|
||||
if (background != null) {
|
||||
if (d() && b(background)) {
|
||||
return;
|
||||
}
|
||||
TintInfo tintInfo = this.e;
|
||||
if (tintInfo != null) {
|
||||
AppCompatDrawableManager.a(background, tintInfo, this.a.getDrawableState());
|
||||
return;
|
||||
}
|
||||
TintInfo tintInfo2 = this.d;
|
||||
if (tintInfo2 != null) {
|
||||
AppCompatDrawableManager.a(background, tintInfo2, this.a.getDrawableState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void a(ColorStateList colorStateList) {
|
||||
if (colorStateList != null) {
|
||||
if (this.d == null) {
|
||||
this.d = new TintInfo();
|
||||
}
|
||||
TintInfo tintInfo = this.d;
|
||||
tintInfo.a = colorStateList;
|
||||
tintInfo.d = true;
|
||||
} else {
|
||||
this.d = null;
|
||||
}
|
||||
a();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user