package androidx.leanback.widget;

import a.AbstractC0872a;
import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Layout;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.widget.TextView;

/* JADX INFO: loaded from: classes.dex */
class ResizingTextView extends TextView {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f11868a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f11869b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final boolean f11870c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int f11871d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f11872e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f11873f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f11874j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public float f11875k;
    public int l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f11876m;

    public ResizingTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, R.attr.textViewStyle);
        this.f11873f = false;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Z1.a.f9146f, R.attr.textViewStyle, 0);
        try {
            this.f11868a = typedArrayObtainStyledAttributes.getInt(1, 1);
            this.f11869b = typedArrayObtainStyledAttributes.getDimensionPixelSize(4, -1);
            this.f11870c = typedArrayObtainStyledAttributes.getBoolean(0, false);
            this.f11871d = typedArrayObtainStyledAttributes.getDimensionPixelOffset(3, 0);
            this.f11872e = typedArrayObtainStyledAttributes.getDimensionPixelOffset(2, 0);
        } finally {
            typedArrayObtainStyledAttributes.recycle();
        }
    }

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

    /* 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 i6, int i7) {
        boolean z6;
        int i8;
        boolean z7 = true;
        if (!this.f11873f) {
            this.f11874j = (int) getTextSize();
            this.f11875k = getLineSpacingExtra();
            this.l = getPaddingTop();
            this.f11876m = getPaddingBottom();
            this.f11873f = true;
        }
        boolean z8 = false;
        setTextSize(0, this.f11874j);
        setLineSpacing(this.f11875k, getLineSpacingMultiplier());
        a(this.l, this.f11876m);
        super.onMeasure(i6, i7);
        Layout layout = getLayout();
        if (layout == null || (this.f11868a & 1) <= 0) {
            z6 = false;
        } else {
            int lineCount = layout.getLineCount();
            int maxLines = getMaxLines();
            if (maxLines > 1 && lineCount == maxLines) {
                z6 = true;
            }
        }
        int textSize = (int) getTextSize();
        boolean z9 = this.f11870c;
        int i9 = this.f11869b;
        if (z6) {
            if (i9 != -1 && textSize != i9) {
                setTextSize(0, i9);
                z8 = true;
            }
            float f6 = (this.f11875k + this.f11874j) - i9;
            if (z9 && getLineSpacingExtra() != f6) {
                setLineSpacing(f6, getLineSpacingMultiplier());
                z8 = true;
            }
            int i10 = this.l + this.f11871d;
            int i11 = this.f11876m + this.f11872e;
            if (getPaddingTop() == i10 && getPaddingBottom() == i11) {
                z7 = z8;
            } else {
                a(i10, i11);
            }
        } else {
            if (i9 != -1 && textSize != (i8 = this.f11874j)) {
                setTextSize(0, i8);
                z8 = true;
            }
            if (z9) {
                float lineSpacingExtra = getLineSpacingExtra();
                float f7 = this.f11875k;
                if (lineSpacingExtra != f7) {
                    setLineSpacing(f7, getLineSpacingMultiplier());
                    z8 = true;
                }
            }
            if (getPaddingTop() != this.l || getPaddingBottom() != this.f11876m) {
                a(this.l, this.f11876m);
            }
        }
        if (z7) {
            super.onMeasure(i6, i7);
        }
    }

    @Override // android.widget.TextView
    public final void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
        super.setCustomSelectionActionModeCallback(AbstractC0872a.j0(callback, this));
    }
}
