package androidx.media3.ui;

import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.media3.ui.AspectRatioFrameLayout;
import ar.tvplayer.tv.R;
import defpackage.AbstractC4694;
import defpackage.C1033;
import defpackage.InterfaceC3264;
import defpackage.RunnableC2801;

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

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public static final /* synthetic */ int f661 = 0;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final RunnableC2801 f662;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public int f663;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public float f664;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public ValueAnimator f665;

    public AspectRatioFrameLayout(Context context) {
        this(context, null);
    }

    public AspectRatioFrameLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f663 = 0;
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, AbstractC4694.f17860, 0, 0);
            try {
                this.f663 = typedArrayObtainStyledAttributes.getInt(0, 0);
            } finally {
                typedArrayObtainStyledAttributes.recycle();
            }
        }
        this.f662 = new RunnableC2801(this);
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static void m410(View view, int i, int i2) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
        if (layoutParams.width == i && layoutParams.height == i2) {
            return;
        }
        layoutParams.gravity = 17;
        layoutParams.width = i;
        layoutParams.height = i2;
        view.setLayoutParams(layoutParams);
    }

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

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        if (this.f665 == null) {
            m411(false);
        }
    }

    public void setAspectRatio(float f) {
        if (this.f664 != f) {
            this.f664 = f;
            m411(false);
        }
    }

    public void setAspectRatioListener(InterfaceC3264 interfaceC3264) {
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x004e, code lost:
    
        if (r8 != 5) goto L33;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0055, code lost:
    
        if (r9 > 0.0f) goto L24;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0057, code lost:
    
        r7 = r7 * r8;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x005a, code lost:
    
        r6 = r6 / r8;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x0069, code lost:
    
        if (r9 > 0.0f) goto L26;
     */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0070  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00b8  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00ea  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m411(final boolean z) {
        float f;
        double d;
        double d2;
        double d3;
        if (this.f664 <= 0.0f) {
            return;
        }
        int width = getWidth();
        int height = getHeight();
        final int i = 0;
        if (width == 0 || height == 0) {
            post(new Runnable() { // from class: ᵘᵿˊ
                @Override // java.lang.Runnable
                public final void run() {
                    int i2 = i;
                    boolean z2 = z;
                    Object obj = this;
                    switch (i2) {
                        case 0:
                            int i3 = AspectRatioFrameLayout.f661;
                            ((AspectRatioFrameLayout) obj).m411(z2);
                            break;
                        default:
                            InterfaceC5154 interfaceC5154 = (InterfaceC5154) ((ˊˊᵞᵽ) obj).ᵔᵖᵹᵫ;
                            String str = AbstractC0956.f4222;
                            C3262 c3262 = ((SurfaceHolderCallbackC2683) interfaceC5154).f10352;
                            if (c3262.f12442 != z2) {
                                c3262.f12442 = z2;
                                c3262.f12452.m7412(23, new C1428(1, z2));
                                break;
                            }
                            break;
                    }
                }
            });
            return;
        }
        float f2 = width;
        float f3 = height;
        float f4 = (this.f664 / (f2 / f3)) - 1.0f;
        float fAbs = Math.abs(f4);
        RunnableC2801 runnableC2801 = this.f662;
        if (fAbs > 0.01f) {
            int i2 = this.f663;
            if (i2 == 0) {
                f = this.f664;
            } else if (i2 == 1) {
                float f5 = f2 / this.f664;
                height = (int) f5;
                if (!runnableC2801.f10751) {
                }
            } else if (i2 == 2) {
                float f6 = f3 * this.f664;
                width = (int) f6;
                if (!runnableC2801.f10751) {
                    runnableC2801.f10751 = true;
                    ((AspectRatioFrameLayout) runnableC2801.f10750).post(runnableC2801);
                }
            } else if (i2 == 4) {
                f = this.f664;
            }
        } else if (!runnableC2801.f10751) {
            runnableC2801.f10751 = true;
            ((AspectRatioFrameLayout) runnableC2801.f10750).post(runnableC2801);
        }
        int i3 = this.f663;
        if (i3 != 5) {
            if (i3 == 6) {
                width = (height * 4) / 3;
            } else if (i3 == 8) {
                d = width;
                d2 = 1.3218750000000001d;
            } else if (i3 == 9) {
                d3 = ((double) width) / 2.35d;
                height = (int) d3;
            }
            final int i4 = width;
            final int i5 = height;
            final View childAt = getChildAt(0);
            final View viewFindViewById = findViewById(R.id.jf);
            if (z) {
                m410(childAt, i4, i5);
                m410(viewFindViewById, i4, i5);
                return;
            }
            final int width2 = childAt.getWidth();
            final int height2 = childAt.getHeight();
            ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
            this.f665 = valueAnimatorOfFloat;
            valueAnimatorOfFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: ᵨᵺᵻ
                @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    int i6 = AspectRatioFrameLayout.f661;
                    float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
                    int iRound = Math.round(((i4 - r0) * fFloatValue) + width2);
                    int iRound2 = Math.round((fFloatValue * (i5 - r1)) + height2);
                    AspectRatioFrameLayout.m410(childAt, iRound, iRound2);
                    AspectRatioFrameLayout.m410(viewFindViewById, iRound, iRound2);
                }
            });
            this.f665.addListener(new C1033(2, this));
            this.f665.setDuration(300L);
            this.f665.start();
            return;
        }
        d = width;
        d2 = 0.8d;
        width = (int) (d * d2);
        d3 = ((double) height) * d2;
        height = (int) d3;
        final int i42 = width;
        final int i52 = height;
        final View childAt2 = getChildAt(0);
        final View viewFindViewById2 = findViewById(R.id.jf);
        if (z) {
        }
    }
}
