package androidx.media3.ui;

import D1.E;
import D1.InterfaceC0076a;
import D1.RunnableC0077b;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;

/* JADX INFO: loaded from: classes.dex */
public final class AspectRatioFrameLayout extends FrameLayout {

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public static final /* synthetic */ int f8882t = 0;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final RunnableC0077b f8883q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public float f8884r;

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

    public AspectRatioFrameLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f8885s = 0;
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, E.f1655a, 0, 0);
            try {
                this.f8885s = typedArrayObtainStyledAttributes.getInt(0, 0);
            } finally {
                typedArrayObtainStyledAttributes.recycle();
            }
        }
        this.f8883q = new RunnableC0077b(this);
    }

    public int getResizeMode() {
        return this.f8885s;
    }

    @Override // android.widget.FrameLayout, android.view.View
    public final void onMeasure(int i, int i5) {
        float f3;
        float f7;
        super.onMeasure(i, i5);
        if (this.f8884r <= 0.0f) {
            return;
        }
        int measuredWidth = getMeasuredWidth();
        int measuredHeight = getMeasuredHeight();
        float f8 = measuredWidth;
        float f9 = measuredHeight;
        float f10 = (this.f8884r / (f8 / f9)) - 1.0f;
        float fAbs = Math.abs(f10);
        RunnableC0077b runnableC0077b = this.f8883q;
        if (fAbs <= 0.01f) {
            if (runnableC0077b.f1715r) {
                return;
            }
            runnableC0077b.f1715r = true;
            ((AspectRatioFrameLayout) runnableC0077b.f1716s).post(runnableC0077b);
            return;
        }
        int i8 = this.f8885s;
        if (i8 != 0) {
            if (i8 != 1) {
                if (i8 == 2) {
                    f3 = this.f8884r;
                } else if (i8 == 4) {
                    if (f10 > 0.0f) {
                        f3 = this.f8884r;
                    } else {
                        f7 = this.f8884r;
                    }
                }
                measuredWidth = (int) (f9 * f3);
            } else {
                f7 = this.f8884r;
            }
            measuredHeight = (int) (f8 / f7);
        } else if (f10 > 0.0f) {
            f7 = this.f8884r;
            measuredHeight = (int) (f8 / f7);
        } else {
            f3 = this.f8884r;
            measuredWidth = (int) (f9 * f3);
        }
        if (!runnableC0077b.f1715r) {
            runnableC0077b.f1715r = true;
            ((AspectRatioFrameLayout) runnableC0077b.f1716s).post(runnableC0077b);
        }
        super.onMeasure(View.MeasureSpec.makeMeasureSpec(measuredWidth, 1073741824), View.MeasureSpec.makeMeasureSpec(measuredHeight, 1073741824));
    }

    public void setAspectRatio(float f3) {
        if (this.f8884r != f3) {
            this.f8884r = f3;
            requestLayout();
        }
    }

    public void setResizeMode(int i) {
        if (this.f8885s != i) {
            this.f8885s = i;
            requestLayout();
        }
    }

    public void setAspectRatioListener(InterfaceC0076a interfaceC0076a) {
    }
}
