package androidx.appcompat.widget;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.view.z1;
import e.m0;
import l.j;
import l.k1;
import l.l1;
import l.p;
import l.w3;
import xyz.stream.utils.a0;

/* JADX INFO: loaded from: classes.dex */
@RestrictTo({RestrictTo.Scope.f555a})
public class ContentFrameLayout extends FrameLayout {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public TypedValue f701a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public TypedValue f702b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public TypedValue f703c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public TypedValue f704d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public TypedValue f705e;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final Rect f707g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public k1 f708h;

    public ContentFrameLayout(@NonNull Context context) {
        this(context, null);
    }

    public TypedValue getFixedHeightMajor() {
        if (this.f705e == null) {
            this.f705e = new TypedValue();
        }
        return this.f705e;
    }

    public TypedValue getFixedHeightMinor() {
        if (this.f706f == null) {
            this.f706f = new TypedValue();
        }
        return this.f706f;
    }

    public TypedValue getFixedWidthMajor() {
        if (this.f703c == null) {
            this.f703c = new TypedValue();
        }
        return this.f703c;
    }

    public TypedValue getFixedWidthMinor() {
        if (this.f704d == null) {
            this.f704d = new TypedValue();
        }
        return this.f704d;
    }

    public TypedValue getMinWidthMajor() {
        if (this.f701a == null) {
            this.f701a = new TypedValue();
        }
        return this.f701a;
    }

    public TypedValue getMinWidthMinor() {
        if (this.f702b == null) {
            this.f702b = new TypedValue();
        }
        return this.f702b;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        k1 k1Var = this.f708h;
        if (k1Var != null) {
            k1Var.getClass();
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        p pVar;
        super.onDetachedFromWindow();
        k1 k1Var = this.f708h;
        if (k1Var != null) {
            m0 m0Var = (m0) ((a0) k1Var).f36098a;
            l1 l1Var = m0Var.U;
            if (l1Var != null) {
                ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) l1Var;
                actionBarOverlayLayout.e();
                ActionMenuView actionMenuView = ((w3) actionBarOverlayLayout.f613e).f29883a.f798a;
                if (actionMenuView != null && (pVar = actionMenuView.W) != null) {
                    pVar.e();
                    j jVar = pVar.X;
                    if (jVar != null && jVar.b()) {
                        jVar.f28955j.dismiss();
                    }
                }
            }
            if (m0Var.Z != null) {
                m0Var.f25287l.getDecorView().removeCallbacks(m0Var.f25274a0);
                if (m0Var.Z.isShowing()) {
                    try {
                        m0Var.Z.dismiss();
                    } catch (IllegalArgumentException unused) {
                    }
                }
                m0Var.Z = null;
            }
            z1 z1Var = m0Var.f25275b0;
            if (z1Var != null) {
                z1Var.b();
            }
            k.p pVar2 = m0Var.w(0).f25264h;
            if (pVar2 != null) {
                pVar2.c(true);
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x004e  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0062  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x008a  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00d1  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x00d9  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00de  */
    @Override // android.widget.FrameLayout, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onMeasure(int i10, int i11) {
        int iMakeMeasureSpec;
        boolean z10;
        int iMakeMeasureSpec2;
        int i12;
        int i13;
        float fraction;
        int i14;
        int i15;
        float fraction2;
        int i16;
        int i17;
        float fraction3;
        DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
        boolean z11 = true;
        boolean z12 = displayMetrics.widthPixels < displayMetrics.heightPixels;
        int mode = View.MeasureSpec.getMode(i10);
        int mode2 = View.MeasureSpec.getMode(i11);
        Rect rect = this.f707g;
        if (mode != Integer.MIN_VALUE) {
            iMakeMeasureSpec = i10;
            z10 = false;
        } else {
            TypedValue typedValue = z12 ? this.f704d : this.f703c;
            if (typedValue != null && (i16 = typedValue.type) != 0) {
                if (i16 == 5) {
                    fraction3 = typedValue.getDimension(displayMetrics);
                } else if (i16 == 6) {
                    int i18 = displayMetrics.widthPixels;
                    fraction3 = typedValue.getFraction(i18, i18);
                } else {
                    i17 = 0;
                    if (i17 <= 0) {
                        iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(Math.min(i17 - (rect.left + rect.right), View.MeasureSpec.getSize(i10)), 1073741824);
                        z10 = true;
                    }
                }
                i17 = (int) fraction3;
                if (i17 <= 0) {
                }
            }
        }
        if (mode2 != Integer.MIN_VALUE) {
            iMakeMeasureSpec2 = i11;
        } else {
            TypedValue typedValue2 = z12 ? this.f705e : this.f706f;
            if (typedValue2 != null && (i14 = typedValue2.type) != 0) {
                if (i14 == 5) {
                    fraction2 = typedValue2.getDimension(displayMetrics);
                } else if (i14 == 6) {
                    int i19 = displayMetrics.heightPixels;
                    fraction2 = typedValue2.getFraction(i19, i19);
                } else {
                    i15 = 0;
                    if (i15 <= 0) {
                        iMakeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(Math.min(i15 - (rect.top + rect.bottom), View.MeasureSpec.getSize(i11)), 1073741824);
                    }
                }
                i15 = (int) fraction2;
                if (i15 <= 0) {
                }
            }
        }
        super.onMeasure(iMakeMeasureSpec, iMakeMeasureSpec2);
        int measuredWidth = getMeasuredWidth();
        int iMakeMeasureSpec3 = View.MeasureSpec.makeMeasureSpec(measuredWidth, 1073741824);
        if (z10 || mode != Integer.MIN_VALUE) {
            z11 = false;
        } else {
            TypedValue typedValue3 = z12 ? this.f702b : this.f701a;
            if (typedValue3 != null && (i12 = typedValue3.type) != 0) {
                if (i12 == 5) {
                    fraction = typedValue3.getDimension(displayMetrics);
                } else if (i12 == 6) {
                    int i20 = displayMetrics.widthPixels;
                    fraction = typedValue3.getFraction(i20, i20);
                } else {
                    i13 = 0;
                    if (i13 > 0) {
                        i13 -= rect.left + rect.right;
                    }
                    if (measuredWidth >= i13) {
                        iMakeMeasureSpec3 = View.MeasureSpec.makeMeasureSpec(i13, 1073741824);
                    }
                }
                i13 = (int) fraction;
                if (i13 > 0) {
                }
                if (measuredWidth >= i13) {
                }
            }
        }
        if (z11) {
            super.onMeasure(iMakeMeasureSpec3, iMakeMeasureSpec2);
        }
    }

    public void setAttachListener(k1 k1Var) {
        this.f708h = k1Var;
    }

    @RestrictTo({RestrictTo.Scope.f555a})
    public void setDecorPadding(int i10, int i11, int i12, int i13) {
        this.f707g.set(i10, i11, i12, i13);
        if (isLaidOut()) {
            requestLayout();
        }
    }

    public ContentFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public ContentFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f707g = new Rect();
    }
}
