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 p037.p041.p042.C1511;
import p037.p041.p042.LayoutInflaterFactory2C1494;
import p037.p041.p049.p050.C1572;
import p037.p041.p051.InterfaceC1648;

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

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

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

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

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

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

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public TypedValue f314;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public final Rect f315;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public InterfaceC0046 f316;

    /* JADX INFO: renamed from: androidx.appcompat.widget.ContentFrameLayout$֏, reason: contains not printable characters */
    public interface InterfaceC0046 {
    }

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

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

    public ContentFrameLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f315 = new Rect();
    }

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

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

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

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

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

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

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        InterfaceC0046 interfaceC0046 = this.f316;
        if (interfaceC0046 != null && ((C1511) interfaceC0046) == null) {
            throw null;
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        C1572 c1572;
        super.onDetachedFromWindow();
        InterfaceC0046 interfaceC0046 = this.f316;
        if (interfaceC0046 != null) {
            LayoutInflaterFactory2C1494 layoutInflaterFactory2C1494 = ((C1511) interfaceC0046).f4787;
            InterfaceC1648 interfaceC1648 = layoutInflaterFactory2C1494.f4690;
            if (interfaceC1648 != null) {
                interfaceC1648.mo138();
            }
            if (layoutInflaterFactory2C1494.f4695 != null) {
                layoutInflaterFactory2C1494.f4684.getDecorView().removeCallbacks(layoutInflaterFactory2C1494.f4696);
                if (layoutInflaterFactory2C1494.f4695.isShowing()) {
                    try {
                        layoutInflaterFactory2C1494.f4695.dismiss();
                    } catch (IllegalArgumentException unused) {
                    }
                }
                layoutInflaterFactory2C1494.f4695 = null;
            }
            layoutInflaterFactory2C1494.m2849();
            LayoutInflaterFactory2C1494.C1507 c1507M2847 = layoutInflaterFactory2C1494.m2847(0);
            if (c1507M2847 == null || (c1572 = c1507M2847.f4774) == null) {
                return;
            }
            c1572.m3093(true);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x004a  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0086  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x00cc  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x00d6  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x00db  */
    @Override // android.widget.FrameLayout, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void onMeasure(int i, int i2) {
        boolean z;
        int i3;
        int i4;
        float fraction;
        int i5;
        int i6;
        float fraction2;
        int i7;
        int i8;
        float fraction3;
        DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
        boolean z2 = true;
        boolean z3 = displayMetrics.widthPixels < displayMetrics.heightPixels;
        int mode = View.MeasureSpec.getMode(i);
        int mode2 = View.MeasureSpec.getMode(i2);
        if (mode != Integer.MIN_VALUE) {
            z = false;
        } else {
            TypedValue typedValue = z3 ? this.f312 : this.f311;
            if (typedValue != null && (i7 = typedValue.type) != 0) {
                if (i7 == 5) {
                    fraction3 = typedValue.getDimension(displayMetrics);
                } else if (i7 == 6) {
                    int i9 = displayMetrics.widthPixels;
                    fraction3 = typedValue.getFraction(i9, i9);
                } else {
                    i8 = 0;
                    if (i8 <= 0) {
                        Rect rect = this.f315;
                        i = View.MeasureSpec.makeMeasureSpec(Math.min(i8 - (rect.left + rect.right), View.MeasureSpec.getSize(i)), 1073741824);
                        z = true;
                    }
                }
                i8 = (int) fraction3;
                if (i8 <= 0) {
                }
            }
        }
        if (mode2 == Integer.MIN_VALUE) {
            TypedValue typedValue2 = z3 ? this.f313 : this.f314;
            if (typedValue2 != null && (i5 = typedValue2.type) != 0) {
                if (i5 == 5) {
                    fraction2 = typedValue2.getDimension(displayMetrics);
                } else if (i5 == 6) {
                    int i10 = displayMetrics.heightPixels;
                    fraction2 = typedValue2.getFraction(i10, i10);
                } else {
                    i6 = 0;
                    if (i6 > 0) {
                        Rect rect2 = this.f315;
                        i2 = View.MeasureSpec.makeMeasureSpec(Math.min(i6 - (rect2.top + rect2.bottom), View.MeasureSpec.getSize(i2)), 1073741824);
                    }
                }
                i6 = (int) fraction2;
                if (i6 > 0) {
                }
            }
        }
        super.onMeasure(i, i2);
        int measuredWidth = getMeasuredWidth();
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(measuredWidth, 1073741824);
        if (z || mode != Integer.MIN_VALUE) {
            z2 = false;
        } else {
            TypedValue typedValue3 = z3 ? this.f310 : this.f309;
            if (typedValue3 != null && (i3 = typedValue3.type) != 0) {
                if (i3 == 5) {
                    fraction = typedValue3.getDimension(displayMetrics);
                } else if (i3 == 6) {
                    int i11 = displayMetrics.widthPixels;
                    fraction = typedValue3.getFraction(i11, i11);
                } else {
                    i4 = 0;
                    if (i4 > 0) {
                        Rect rect3 = this.f315;
                        i4 -= rect3.left + rect3.right;
                    }
                    if (measuredWidth >= i4) {
                        iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i4, 1073741824);
                    }
                }
                i4 = (int) fraction;
                if (i4 > 0) {
                }
                if (measuredWidth >= i4) {
                }
            }
        }
        if (z2) {
            super.onMeasure(iMakeMeasureSpec, i2);
        }
    }

    public void setAttachListener(InterfaceC0046 interfaceC0046) {
        this.f316 = interfaceC0046;
    }
}
