package androidx.leanback.widget;

import android.R;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Layout;
import android.util.AttributeSet;
import android.widget.TextView;
import defpackage.bo7;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"AppCompatCustomView"})
class ResizingTextView extends TextView {
    public final int a;
    public final int b;
    public final boolean c;
    public final int d;
    public final int e;
    public boolean f;
    public int i;
    public float j;
    public int k;
    public int l;

    public ResizingTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, R.attr.textViewStyle);
        this.f = false;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, bo7.n.j, R.attr.textViewStyle, 0);
        try {
            this.a = typedArrayObtainStyledAttributes.getInt(1, 1);
            this.b = typedArrayObtainStyledAttributes.getDimensionPixelSize(4, -1);
            this.c = typedArrayObtainStyledAttributes.getBoolean(0, false);
            this.d = typedArrayObtainStyledAttributes.getDimensionPixelOffset(3, 0);
            this.e = typedArrayObtainStyledAttributes.getDimensionPixelOffset(2, 0);
        } finally {
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    public final void a(int i, int i2) {
        if (isPaddingRelative()) {
            setPaddingRelative(getPaddingStart(), i, getPaddingEnd(), i2);
        } else {
            setPadding(getPaddingLeft(), i, getPaddingRight(), i2);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0053  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00cd A[PHI: r2
      0x00cd: PHI (r2v6 boolean) = (r2v2 boolean), (r2v8 boolean) binds: [B:40:0x00ca, B:27:0x0097] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // android.widget.TextView, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onMeasure(int i, int i2) {
        boolean z;
        int i3;
        boolean z2 = true;
        if (!this.f) {
            this.i = (int) getTextSize();
            this.j = getLineSpacingExtra();
            this.k = getPaddingTop();
            this.l = getPaddingBottom();
            this.f = true;
        }
        boolean z3 = false;
        setTextSize(0, this.i);
        setLineSpacing(this.j, getLineSpacingMultiplier());
        a(this.k, this.l);
        super.onMeasure(i, i2);
        Layout layout = getLayout();
        if (layout == null || (this.a & 1) <= 0) {
            z = false;
        } else {
            int lineCount = layout.getLineCount();
            int maxLines = getMaxLines();
            if (maxLines > 1 && lineCount == maxLines) {
                z = true;
            }
        }
        int textSize = (int) getTextSize();
        boolean z4 = this.c;
        int i4 = this.b;
        if (z) {
            if (i4 != -1 && textSize != i4) {
                setTextSize(0, i4);
                z3 = true;
            }
            float f = (this.j + this.i) - i4;
            if (z4 && getLineSpacingExtra() != f) {
                setLineSpacing(f, getLineSpacingMultiplier());
                z3 = true;
            }
            int i5 = this.k + this.d;
            int i6 = this.l + this.e;
            if (getPaddingTop() == i5 && getPaddingBottom() == i6) {
                z2 = z3;
            } else {
                a(i5, i6);
            }
        } else {
            if (i4 != -1 && textSize != (i3 = this.i)) {
                setTextSize(0, i3);
                z3 = true;
            }
            if (z4) {
                float lineSpacingExtra = getLineSpacingExtra();
                float f2 = this.j;
                if (lineSpacingExtra != f2) {
                    setLineSpacing(f2, getLineSpacingMultiplier());
                    z3 = true;
                }
            }
            if (getPaddingTop() != this.k || getPaddingBottom() != this.l) {
                a(this.k, this.l);
            }
        }
        if (z2) {
            super.onMeasure(i, i2);
        }
    }
}
