package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private boolean f456c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private View f457d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private View f458e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private View f459f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    Drawable f460g;
    Drawable h;
    Drawable i;
    boolean j;
    boolean k;
    private int l;

    public ActionBarContainer(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        a.c.i.l.l(this, new b(this));
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, a.a.j.f51a);
        this.f460g = typedArrayObtainStyledAttributes.getDrawable(a.a.j.f52b);
        this.h = typedArrayObtainStyledAttributes.getDrawable(a.a.j.f54d);
        this.l = typedArrayObtainStyledAttributes.getDimensionPixelSize(a.a.j.i, -1);
        boolean z = true;
        if (getId() == a.a.f.x) {
            this.j = true;
            this.i = typedArrayObtainStyledAttributes.getDrawable(a.a.j.f53c);
        }
        typedArrayObtainStyledAttributes.recycle();
        if (!this.j ? this.f460g != null || this.h != null : this.i != null) {
            z = false;
        }
        setWillNotDraw(z);
    }

    private int a(View view) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
        return view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
    }

    private boolean b(View view) {
        return view == null || view.getVisibility() == 8 || view.getMeasuredHeight() == 0;
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void drawableStateChanged() {
        super.drawableStateChanged();
        Drawable drawable = this.f460g;
        if (drawable != null && drawable.isStateful()) {
            this.f460g.setState(getDrawableState());
        }
        Drawable drawable2 = this.h;
        if (drawable2 != null && drawable2.isStateful()) {
            this.h.setState(getDrawableState());
        }
        Drawable drawable3 = this.i;
        if (drawable3 == null || !drawable3.isStateful()) {
            return;
        }
        this.i.setState(getDrawableState());
    }

    public View getTabContainer() {
        return this.f457d;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void jumpDrawablesToCurrentState() {
        super.jumpDrawablesToCurrentState();
        Drawable drawable = this.f460g;
        if (drawable != null) {
            drawable.jumpToCurrentState();
        }
        Drawable drawable2 = this.h;
        if (drawable2 != null) {
            drawable2.jumpToCurrentState();
        }
        Drawable drawable3 = this.i;
        if (drawable3 != null) {
            drawable3.jumpToCurrentState();
        }
    }

    @Override // android.view.View
    public void onFinishInflate() {
        super.onFinishInflate();
        this.f458e = findViewById(a.a.f.f28a);
        this.f459f = findViewById(a.a.f.f33f);
    }

    @Override // android.view.View
    public boolean onHoverEvent(MotionEvent motionEvent) {
        super.onHoverEvent(motionEvent);
        return true;
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return this.f456c || super.onInterceptTouchEvent(motionEvent);
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0048 A[PHI: r0
      0x0048: PHI (r0v8 boolean) = (r0v1 boolean), (r0v1 boolean), (r0v0 boolean) binds: [B:31:0x00a5, B:33:0x00a9, B:15:0x0039] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void onLayout(boolean r5, int r6, int r7, int r8, int r9) {
        /*
            r4 = this;
            super.onLayout(r5, r6, r7, r8, r9)
            android.view.View r5 = r4.f457d
            r7 = 8
            r9 = 1
            r0 = 0
            if (r5 == 0) goto L13
            int r1 = r5.getVisibility()
            if (r1 == r7) goto L13
            r1 = r9
            goto L14
        L13:
            r1 = r0
        L14:
            if (r5 == 0) goto L33
            int r2 = r5.getVisibility()
            if (r2 == r7) goto L33
            int r7 = r4.getMeasuredHeight()
            android.view.ViewGroup$LayoutParams r2 = r5.getLayoutParams()
            android.widget.FrameLayout$LayoutParams r2 = (android.widget.FrameLayout.LayoutParams) r2
            int r3 = r5.getMeasuredHeight()
            int r3 = r7 - r3
            int r2 = r2.bottomMargin
            int r3 = r3 - r2
            int r7 = r7 - r2
            r5.layout(r6, r3, r8, r7)
        L33:
            boolean r6 = r4.j
            if (r6 == 0) goto L4b
            android.graphics.drawable.Drawable r5 = r4.i
            if (r5 == 0) goto L48
            int r6 = r4.getMeasuredWidth()
            int r7 = r4.getMeasuredHeight()
            r5.setBounds(r0, r0, r6, r7)
            goto Lbe
        L48:
            r9 = r0
            goto Lbe
        L4b:
            android.graphics.drawable.Drawable r6 = r4.f460g
            if (r6 == 0) goto La3
            android.view.View r6 = r4.f458e
            int r6 = r6.getVisibility()
            if (r6 != 0) goto L75
            android.graphics.drawable.Drawable r6 = r4.f460g
            android.view.View r7 = r4.f458e
            int r7 = r7.getLeft()
            android.view.View r8 = r4.f458e
            int r8 = r8.getTop()
            android.view.View r0 = r4.f458e
            int r0 = r0.getRight()
            android.view.View r2 = r4.f458e
            int r2 = r2.getBottom()
            r6.setBounds(r7, r8, r0, r2)
            goto La2
        L75:
            android.view.View r6 = r4.f459f
            if (r6 == 0) goto L9d
            int r6 = r6.getVisibility()
            if (r6 != 0) goto L9d
            android.graphics.drawable.Drawable r6 = r4.f460g
            android.view.View r7 = r4.f459f
            int r7 = r7.getLeft()
            android.view.View r8 = r4.f459f
            int r8 = r8.getTop()
            android.view.View r0 = r4.f459f
            int r0 = r0.getRight()
            android.view.View r2 = r4.f459f
            int r2 = r2.getBottom()
            r6.setBounds(r7, r8, r0, r2)
            goto La2
        L9d:
            android.graphics.drawable.Drawable r6 = r4.f460g
            r6.setBounds(r0, r0, r0, r0)
        La2:
            r0 = r9
        La3:
            r4.k = r1
            if (r1 == 0) goto L48
            android.graphics.drawable.Drawable r6 = r4.h
            if (r6 == 0) goto L48
            int r7 = r5.getLeft()
            int r8 = r5.getTop()
            int r0 = r5.getRight()
            int r5 = r5.getBottom()
            r6.setBounds(r7, r8, r0, r5)
        Lbe:
            if (r9 == 0) goto Lc3
            r4.invalidate()
        Lc3:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.ActionBarContainer.onLayout(boolean, int, int, int, int):void");
    }

    @Override // android.widget.FrameLayout, android.view.View
    public void onMeasure(int i, int i2) {
        int i3;
        if (this.f458e == null && View.MeasureSpec.getMode(i2) == Integer.MIN_VALUE && (i3 = this.l) >= 0) {
            i2 = View.MeasureSpec.makeMeasureSpec(Math.min(i3, View.MeasureSpec.getSize(i2)), Integer.MIN_VALUE);
        }
        super.onMeasure(i, i2);
        if (this.f458e == null) {
            return;
        }
        int mode = View.MeasureSpec.getMode(i2);
        View view = this.f457d;
        if (view == null || view.getVisibility() == 8 || mode == 1073741824) {
            return;
        }
        setMeasuredDimension(getMeasuredWidth(), Math.min((!b(this.f458e) ? a(this.f458e) : !b(this.f459f) ? a(this.f459f) : 0) + a(this.f457d), mode == Integer.MIN_VALUE ? View.MeasureSpec.getSize(i2) : Integer.MAX_VALUE));
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        super.onTouchEvent(motionEvent);
        return true;
    }

    public void setPrimaryBackground(Drawable drawable) {
        Drawable drawable2 = this.f460g;
        if (drawable2 != null) {
            drawable2.setCallback(null);
            unscheduleDrawable(this.f460g);
        }
        this.f460g = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            View view = this.f458e;
            if (view != null) {
                this.f460g.setBounds(view.getLeft(), this.f458e.getTop(), this.f458e.getRight(), this.f458e.getBottom());
            }
        }
        boolean z = true;
        if (!this.j ? this.f460g != null || this.h != null : this.i != null) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
    }

    public void setSplitBackground(Drawable drawable) {
        Drawable drawable2;
        Drawable drawable3 = this.i;
        if (drawable3 != null) {
            drawable3.setCallback(null);
            unscheduleDrawable(this.i);
        }
        this.i = drawable;
        boolean z = false;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.j && (drawable2 = this.i) != null) {
                drawable2.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            }
        }
        if (!this.j ? !(this.f460g != null || this.h != null) : this.i == null) {
            z = true;
        }
        setWillNotDraw(z);
        invalidate();
    }

    public void setStackedBackground(Drawable drawable) {
        Drawable drawable2;
        Drawable drawable3 = this.h;
        if (drawable3 != null) {
            drawable3.setCallback(null);
            unscheduleDrawable(this.h);
        }
        this.h = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.k && (drawable2 = this.h) != null) {
                drawable2.setBounds(this.f457d.getLeft(), this.f457d.getTop(), this.f457d.getRight(), this.f457d.getBottom());
            }
        }
        boolean z = true;
        if (!this.j ? this.f460g != null || this.h != null : this.i != null) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
    }

    public void setTabContainer(b0 b0Var) {
        View view = this.f457d;
        if (view != null) {
            removeView(view);
        }
        this.f457d = b0Var;
        if (b0Var != null) {
            addView(b0Var);
            ViewGroup.LayoutParams layoutParams = b0Var.getLayoutParams();
            layoutParams.width = -1;
            layoutParams.height = -2;
            b0Var.setAllowCollapse(false);
        }
    }

    public void setTransitioning(boolean z) {
        this.f456c = z;
        setDescendantFocusability(z ? 393216 : 262144);
    }

    @Override // android.view.View
    public void setVisibility(int i) {
        super.setVisibility(i);
        boolean z = i == 0;
        Drawable drawable = this.f460g;
        if (drawable != null) {
            drawable.setVisible(z, false);
        }
        Drawable drawable2 = this.h;
        if (drawable2 != null) {
            drawable2.setVisible(z, false);
        }
        Drawable drawable3 = this.i;
        if (drawable3 != null) {
            drawable3.setVisible(z, false);
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public ActionMode startActionModeForChild(View view, ActionMode.Callback callback) {
        return null;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public ActionMode startActionModeForChild(View view, ActionMode.Callback callback, int i) {
        if (i != 0) {
            return super.startActionModeForChild(view, callback, i);
        }
        return null;
    }

    @Override // android.view.View
    protected boolean verifyDrawable(Drawable drawable) {
        return (drawable == this.f460g && !this.j) || (drawable == this.h && this.k) || ((drawable == this.i && this.j) || super.verifyDrawable(drawable));
    }
}
