package d.b.f;

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.view.LayoutInflater;

/* JADX INFO: loaded from: classes.dex */
public class c extends ContextWrapper {
    public int a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Resources.Theme f1671b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public LayoutInflater f1672c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Configuration f1673d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Resources f1674e;

    public c() {
        super(null);
    }

    public c(Context context, int i2) {
        super(context);
        this.a = i2;
    }

    public void a(Configuration configuration) {
        if (this.f1674e != null) {
            throw new IllegalStateException("getResources() or getAssets() has already been called");
        }
        if (this.f1673d != null) {
            throw new IllegalStateException("Override configuration has already been set");
        }
        this.f1673d = new Configuration(configuration);
    }

    @Override // android.content.ContextWrapper
    public void attachBaseContext(Context context) {
        super.attachBaseContext(context);
    }

    public final void b() {
        if (this.f1671b == null) {
            this.f1671b = getResources().newTheme();
            Resources.Theme theme = getBaseContext().getTheme();
            if (theme != null) {
                this.f1671b.setTo(theme);
            }
        }
        this.f1671b.applyStyle(this.a, true);
    }

    @Override // android.content.ContextWrapper, android.content.Context
    public AssetManager getAssets() {
        return getResources().getAssets();
    }

    @Override // android.content.ContextWrapper, android.content.Context
    public Resources getResources() {
        if (this.f1674e == null) {
            Configuration configuration = this.f1673d;
            this.f1674e = configuration == null ? super.getResources() : createConfigurationContext(configuration).getResources();
        }
        return this.f1674e;
    }

    @Override // android.content.ContextWrapper, android.content.Context
    public Object getSystemService(String str) {
        if (!"layout_inflater".equals(str)) {
            return getBaseContext().getSystemService(str);
        }
        if (this.f1672c == null) {
            this.f1672c = LayoutInflater.from(getBaseContext()).cloneInContext(this);
        }
        return this.f1672c;
    }

    @Override // android.content.ContextWrapper, android.content.Context
    public Resources.Theme getTheme() {
        Resources.Theme theme = this.f1671b;
        if (theme != null) {
            return theme;
        }
        if (this.a == 0) {
            this.a = 2131886492;
        }
        b();
        return this.f1671b;
    }

    @Override // android.content.ContextWrapper, android.content.Context
    public void setTheme(int i2) {
        if (this.a != i2) {
            this.a = i2;
            b();
        }
    }
}
