jimu-decompiled/sources/androidx/appcompat/view/ContextThemeWrapper.java
2025-05-13 19:24:51 +02:00

113 lines
3.0 KiB
Java

package androidx.appcompat.view;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.view.LayoutInflater;
import androidx.appcompat.R$style;
/* loaded from: classes.dex */
public class ContextThemeWrapper extends ContextWrapper {
private int a;
private Resources.Theme b;
private LayoutInflater c;
private Configuration d;
private Resources e;
public ContextThemeWrapper() {
super(null);
}
private Resources b() {
if (this.e == null) {
Configuration configuration = this.d;
if (configuration == null) {
this.e = super.getResources();
} else if (Build.VERSION.SDK_INT >= 17) {
this.e = createConfigurationContext(configuration).getResources();
}
}
return this.e;
}
private void c() {
boolean z = this.b == null;
if (z) {
this.b = getResources().newTheme();
Resources.Theme theme = getBaseContext().getTheme();
if (theme != null) {
this.b.setTo(theme);
}
}
a(this.b, this.a, z);
}
public int a() {
return this.a;
}
@Override // android.content.ContextWrapper
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
}
@Override // android.content.ContextWrapper, android.content.Context
public AssetManager getAssets() {
return getResources().getAssets();
}
@Override // android.content.ContextWrapper, android.content.Context
public Resources getResources() {
return b();
}
@Override // android.content.ContextWrapper, android.content.Context
public Object getSystemService(String str) {
if (!"layout_inflater".equals(str)) {
return getBaseContext().getSystemService(str);
}
if (this.c == null) {
this.c = LayoutInflater.from(getBaseContext()).cloneInContext(this);
}
return this.c;
}
@Override // android.content.ContextWrapper, android.content.Context
public Resources.Theme getTheme() {
Resources.Theme theme = this.b;
if (theme != null) {
return theme;
}
if (this.a == 0) {
this.a = R$style.Theme_AppCompat_Light;
}
c();
return this.b;
}
@Override // android.content.ContextWrapper, android.content.Context
public void setTheme(int i) {
if (this.a != i) {
this.a = i;
c();
}
}
public ContextThemeWrapper(Context context, int i) {
super(context);
this.a = i;
}
protected void a(Resources.Theme theme, int i, boolean z) {
theme.applyStyle(i, true);
}
public ContextThemeWrapper(Context context, Resources.Theme theme) {
super(context);
this.b = theme;
}
}