package androidx.appcompat.widget;

import a.c.c.b.f;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.widget.TextView;
import java.lang.ref.WeakReference;

/* JADX INFO: compiled from: AppCompatTextHelper.java */
/* JADX INFO: loaded from: classes.dex */
class n {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final TextView f653a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private g0 f654b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private g0 f655c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private g0 f656d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private g0 f657e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private g0 f658f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private g0 f659g;
    private final p h;
    private int i = 0;
    private Typeface j;
    private boolean k;

    /* JADX INFO: compiled from: AppCompatTextHelper.java */
    class a extends f.a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ WeakReference f660a;

        a(WeakReference weakReference) {
            this.f660a = weakReference;
        }

        @Override // a.c.c.b.f.a
        public void c(int i) {
        }

        @Override // a.c.c.b.f.a
        public void d(Typeface typeface) {
            n.this.l(this.f660a, typeface);
        }
    }

    n(TextView textView) {
        this.f653a = textView;
        this.h = new p(textView);
    }

    private void a(Drawable drawable, g0 g0Var) {
        if (drawable == null || g0Var == null) {
            return;
        }
        f.B(drawable, g0Var, this.f653a.getDrawableState());
    }

    private static g0 d(Context context, f fVar, int i) {
        ColorStateList colorStateListS = fVar.s(context, i);
        if (colorStateListS == null) {
            return null;
        }
        g0 g0Var = new g0();
        g0Var.f601d = true;
        g0Var.f598a = colorStateListS;
        return g0Var;
    }

    private void t(int i, float f2) {
        this.h.t(i, f2);
    }

    private void u(Context context, i0 i0Var) {
        String strM;
        this.i = i0Var.i(a.a.j.m2, this.i);
        int i = a.a.j.q2;
        if (i0Var.p(i) || i0Var.p(a.a.j.r2)) {
            this.j = null;
            int i2 = a.a.j.r2;
            if (i0Var.p(i2)) {
                i = i2;
            }
            if (!context.isRestricted()) {
                try {
                    Typeface typefaceH = i0Var.h(i, this.i, new a(new WeakReference(this.f653a)));
                    this.j = typefaceH;
                    this.k = typefaceH == null;
                } catch (Resources.NotFoundException | UnsupportedOperationException unused) {
                }
            }
            if (this.j != null || (strM = i0Var.m(i)) == null) {
                return;
            }
            this.j = Typeface.create(strM, this.i);
            return;
        }
        int i3 = a.a.j.l2;
        if (i0Var.p(i3)) {
            this.k = false;
            int i4 = i0Var.i(i3, 1);
            if (i4 == 1) {
                this.j = Typeface.SANS_SERIF;
            } else if (i4 == 2) {
                this.j = Typeface.SERIF;
            } else {
                if (i4 != 3) {
                    return;
                }
                this.j = Typeface.MONOSPACE;
            }
        }
    }

    void b() {
        if (this.f654b != null || this.f655c != null || this.f656d != null || this.f657e != null) {
            Drawable[] compoundDrawables = this.f653a.getCompoundDrawables();
            a(compoundDrawables[0], this.f654b);
            a(compoundDrawables[1], this.f655c);
            a(compoundDrawables[2], this.f656d);
            a(compoundDrawables[3], this.f657e);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            if (this.f658f == null && this.f659g == null) {
                return;
            }
            Drawable[] compoundDrawablesRelative = this.f653a.getCompoundDrawablesRelative();
            a(compoundDrawablesRelative[0], this.f658f);
            a(compoundDrawablesRelative[2], this.f659g);
        }
    }

    void c() {
        this.h.a();
    }

    int e() {
        return this.h.g();
    }

    int f() {
        return this.h.h();
    }

    int g() {
        return this.h.i();
    }

    int[] h() {
        return this.h.j();
    }

    int i() {
        return this.h.k();
    }

    boolean j() {
        return this.h.n();
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x00b6  */
    @android.annotation.SuppressLint({"NewApi"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void k(android.util.AttributeSet r19, int r20) {
        /*
            Method dump skipped, instruction units count: 488
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.n.k(android.util.AttributeSet, int):void");
    }

    void l(WeakReference<TextView> weakReference, Typeface typeface) {
        if (this.k) {
            this.j = typeface;
            TextView textView = weakReference.get();
            if (textView != null) {
                textView.setTypeface(typeface, this.i);
            }
        }
    }

    void m(boolean z, int i, int i2, int i3, int i4) {
        if (androidx.core.widget.b.f781a) {
            return;
        }
        c();
    }

    void n(Context context, int i) {
        ColorStateList colorStateListC;
        i0 i0VarQ = i0.q(context, i, a.a.j.j2);
        int i2 = a.a.j.s2;
        if (i0VarQ.p(i2)) {
            o(i0VarQ.a(i2, false));
        }
        if (Build.VERSION.SDK_INT < 23) {
            int i3 = a.a.j.n2;
            if (i0VarQ.p(i3) && (colorStateListC = i0VarQ.c(i3)) != null) {
                this.f653a.setTextColor(colorStateListC);
            }
        }
        int i4 = a.a.j.k2;
        if (i0VarQ.p(i4) && i0VarQ.e(i4, -1) == 0) {
            this.f653a.setTextSize(0, 0.0f);
        }
        u(context, i0VarQ);
        i0VarQ.t();
        Typeface typeface = this.j;
        if (typeface != null) {
            this.f653a.setTypeface(typeface, this.i);
        }
    }

    void o(boolean z) {
        this.f653a.setAllCaps(z);
    }

    void p(int i, int i2, int i3, int i4) throws IllegalArgumentException {
        this.h.p(i, i2, i3, i4);
    }

    void q(int[] iArr, int i) throws IllegalArgumentException {
        this.h.q(iArr, i);
    }

    void r(int i) {
        this.h.r(i);
    }

    void s(int i, float f2) {
        if (androidx.core.widget.b.f781a || j()) {
            return;
        }
        t(i, f2);
    }
}
