package com.google.android.exoplayer2.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import p037.p065.p066.AbstractC1802;
import p037.p065.p066.AbstractC1805;
import p037.p065.p066.C1829;
import p138.p176.p177.p190.p236.C4064;
import p138.p176.p177.p190.p236.C4068;

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

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final RunnableC0312 f1889;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public InterfaceC0311 f1890;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public float f1891;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public int f1892;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public C1829 f1893;

    /* JADX INFO: renamed from: com.google.android.exoplayer2.ui.AspectRatioFrameLayout$֏, reason: contains not printable characters */
    public class C0310 extends AbstractC1805 {
        public C0310() {
        }

        @Override // p037.p065.p066.AbstractC1802.InterfaceC1803
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo1260(AbstractC1802 abstractC1802) {
            AspectRatioFrameLayout.this.f1893 = null;
        }

        @Override // p037.p065.p066.AbstractC1805, p037.p065.p066.AbstractC1802.InterfaceC1803
        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public void mo1261(AbstractC1802 abstractC1802) {
            AspectRatioFrameLayout.this.f1893 = null;
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.ui.AspectRatioFrameLayout$ؠ, reason: contains not printable characters */
    public interface InterfaceC0311 {
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        void m1262(float f, float f2, boolean z);
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.ui.AspectRatioFrameLayout$ހ, reason: contains not printable characters */
    public final class RunnableC0312 implements Runnable {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public float f1895;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public float f1896;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public boolean f1897;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public boolean f1898;

        public /* synthetic */ RunnableC0312(C0310 c0310) {
        }

        @Override // java.lang.Runnable
        public void run() {
            this.f1898 = false;
            InterfaceC0311 interfaceC0311 = AspectRatioFrameLayout.this.f1890;
            if (interfaceC0311 == null) {
                return;
            }
            interfaceC0311.m1262(this.f1895, this.f1896, this.f1897);
        }
    }

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

    public AspectRatioFrameLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f1892 = 0;
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, C4068.AspectRatioFrameLayout, 0, 0);
            try {
                this.f1892 = typedArrayObtainStyledAttributes.getInt(C4068.AspectRatioFrameLayout_resize_mode, 0);
            } finally {
                typedArrayObtainStyledAttributes.recycle();
            }
        }
        this.f1889 = new RunnableC0312(null);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m1256(int i, int i2, int i3, int i4, View view, View view2, AbstractC1802 abstractC1802) {
        float fFloatValue = ((Float) ((C1829) abstractC1802).m3626()).floatValue();
        int iRound = Math.round(((i2 - i) * fFloatValue) + i);
        int iRound2 = Math.round((fFloatValue * (i4 - i3)) + i3);
        m1257(view, iRound, iRound2);
        m1257(view2, iRound, iRound2);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m1257(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.f1892;
    }

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

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

    public void setAspectRatioListener(InterfaceC0311 interfaceC0311) {
        this.f1890 = interfaceC0311;
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x0054, code lost:
    
        if (r9 != 5) goto L34;
     */
    /* JADX WARN: Removed duplicated region for block: B:36:0x0084  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00bc  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00f7  */
    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters and merged with bridge method [inline-methods] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m1258(final boolean z) {
        float f;
        float f2;
        RunnableC0312 runnableC0312;
        double d;
        double d2;
        if (this.f1891 <= 0.0f) {
            return;
        }
        int width = getWidth();
        int height = getHeight();
        if (width == 0 || height == 0) {
            post(new Runnable() { // from class: ދ.ހ.֏.ؠ.ྉ.ؠ
                @Override // java.lang.Runnable
                public final void run() {
                    this.f12849.m1258(z);
                }
            });
            return;
        }
        float f3 = width;
        float f4 = height;
        float f5 = f3 / f4;
        float f6 = (this.f1891 / f5) - 1.0f;
        if (Math.abs(f6) <= 0.01f) {
            RunnableC0312 runnableC03122 = this.f1889;
            runnableC03122.f1895 = this.f1891;
            runnableC03122.f1896 = f5;
            runnableC03122.f1897 = false;
            if (!runnableC03122.f1898) {
                runnableC03122.f1898 = true;
                AspectRatioFrameLayout.this.post(runnableC03122);
            }
        } else {
            int i = this.f1892;
            if (i != 0) {
                if (i != 1) {
                    if (i == 2) {
                        f = this.f1891;
                    } else if (i == 4) {
                        if (f6 > 0.0f) {
                            f = this.f1891;
                        } else {
                            f2 = this.f1891;
                        }
                    }
                    width = (int) (f4 * f);
                    runnableC0312 = this.f1889;
                    runnableC0312.f1895 = this.f1891;
                    runnableC0312.f1896 = f5;
                    runnableC0312.f1897 = true;
                    if (!runnableC0312.f1898) {
                    }
                } else {
                    f2 = this.f1891;
                }
                height = (int) (f3 / f2);
                runnableC0312 = this.f1889;
                runnableC0312.f1895 = this.f1891;
                runnableC0312.f1896 = f5;
                runnableC0312.f1897 = true;
                if (!runnableC0312.f1898) {
                }
            } else if (f6 > 0.0f) {
                f2 = this.f1891;
                height = (int) (f3 / f2);
                runnableC0312 = this.f1889;
                runnableC0312.f1895 = this.f1891;
                runnableC0312.f1896 = f5;
                runnableC0312.f1897 = true;
                if (!runnableC0312.f1898) {
                    runnableC0312.f1898 = true;
                    AspectRatioFrameLayout.this.post(runnableC0312);
                }
            } else {
                f = this.f1891;
                width = (int) (f4 * f);
                runnableC0312 = this.f1889;
                runnableC0312.f1895 = this.f1891;
                runnableC0312.f1896 = f5;
                runnableC0312.f1897 = true;
                if (!runnableC0312.f1898) {
                }
            }
        }
        int i2 = this.f1892;
        if (i2 != 5) {
            if (i2 == 6) {
                width = (height * 4) / 3;
            } else if (i2 == 8) {
                d2 = 1.3218750000000001d;
                d = width;
            }
            final View childAt = getChildAt(0);
            final View viewFindViewById = findViewById(C4064.exo_subtitles);
            if (z) {
                m1257(childAt, width, height);
                m1257(viewFindViewById, width, height);
                return;
            }
            final int width2 = childAt.getWidth();
            final int height2 = childAt.getHeight();
            C1829 c1829M3618 = C1829.m3618(0.0f, 1.0f);
            this.f1893 = c1829M3618;
            final int i3 = width;
            final int i4 = height;
            c1829M3618.m3554(new AbstractC1802.InterfaceC1804() { // from class: ދ.ހ.֏.ؠ.ྉ.ހ
                @Override // p037.p065.p066.AbstractC1802.InterfaceC1804
                /* JADX INFO: renamed from: ֏ */
                public final void mo1547(AbstractC1802 abstractC1802) {
                    AspectRatioFrameLayout.m1256(width2, i3, height2, i4, childAt, viewFindViewById, abstractC1802);
                }
            });
            this.f1893.m3553(new C0310());
            this.f1893.mo3562(300L);
            this.f1893.mo3569();
            return;
        }
        d = width;
        d2 = 0.8d;
        width = (int) (d * d2);
        height = (int) (((double) height) * d2);
        final View childAt2 = getChildAt(0);
        final View viewFindViewById2 = findViewById(C4064.exo_subtitles);
        if (z) {
        }
    }
}
