package androidx.appcompat.widget;

import M.J;
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.widget.FrameLayout;
import com.martsnew.tv.R;
import java.lang.reflect.Field;
import n.AbstractC1240v0;
import n.C1198a;

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

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f7742q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public View f7743r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public View f7744s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public Drawable f7745t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Drawable f7746u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public Drawable f7747v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final boolean f7748w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public boolean f7749x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final int f7750y;

    public ActionBarContainer(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        C1198a c1198a = new C1198a(this);
        Field field = J.f4065a;
        setBackground(c1198a);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, h.a.f13005a);
        boolean z8 = false;
        this.f7745t = typedArrayObtainStyledAttributes.getDrawable(0);
        this.f7746u = typedArrayObtainStyledAttributes.getDrawable(2);
        this.f7750y = typedArrayObtainStyledAttributes.getDimensionPixelSize(13, -1);
        if (getId() == R.id.split_action_bar) {
            this.f7748w = true;
            this.f7747v = typedArrayObtainStyledAttributes.getDrawable(1);
        }
        typedArrayObtainStyledAttributes.recycle();
        if (!this.f7748w ? !(this.f7745t != null || this.f7746u != null) : this.f7747v == null) {
            z8 = true;
        }
        setWillNotDraw(z8);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void drawableStateChanged() {
        super.drawableStateChanged();
        Drawable drawable = this.f7745t;
        if (drawable != null && drawable.isStateful()) {
            this.f7745t.setState(getDrawableState());
        }
        Drawable drawable2 = this.f7746u;
        if (drawable2 != null && drawable2.isStateful()) {
            this.f7746u.setState(getDrawableState());
        }
        Drawable drawable3 = this.f7747v;
        if (drawable3 == null || !drawable3.isStateful()) {
            return;
        }
        this.f7747v.setState(getDrawableState());
    }

    public View getTabContainer() {
        return null;
    }

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

    @Override // android.view.View
    public final void onFinishInflate() {
        super.onFinishInflate();
        this.f7743r = findViewById(R.id.action_bar);
        this.f7744s = findViewById(R.id.action_context_bar);
    }

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

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

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z8, int i, int i5, int i8, int i9) {
        super.onLayout(z8, i, i5, i8, i9);
        boolean z9 = true;
        if (this.f7748w) {
            Drawable drawable = this.f7747v;
            if (drawable != null) {
                drawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            } else {
                z9 = false;
            }
        } else {
            if (this.f7745t == null) {
                z9 = false;
            } else if (this.f7743r.getVisibility() == 0) {
                this.f7745t.setBounds(this.f7743r.getLeft(), this.f7743r.getTop(), this.f7743r.getRight(), this.f7743r.getBottom());
            } else {
                View view = this.f7744s;
                if (view == null || view.getVisibility() != 0) {
                    this.f7745t.setBounds(0, 0, 0, 0);
                } else {
                    this.f7745t.setBounds(this.f7744s.getLeft(), this.f7744s.getTop(), this.f7744s.getRight(), this.f7744s.getBottom());
                }
            }
            this.f7749x = false;
        }
        if (z9) {
            invalidate();
        }
    }

    @Override // android.widget.FrameLayout, android.view.View
    public final void onMeasure(int i, int i5) {
        int i8;
        if (this.f7743r == null && View.MeasureSpec.getMode(i5) == Integer.MIN_VALUE && (i8 = this.f7750y) >= 0) {
            i5 = View.MeasureSpec.makeMeasureSpec(Math.min(i8, View.MeasureSpec.getSize(i5)), Integer.MIN_VALUE);
        }
        super.onMeasure(i, i5);
        if (this.f7743r == null) {
            return;
        }
        View.MeasureSpec.getMode(i5);
    }

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

    public void setPrimaryBackground(Drawable drawable) {
        Drawable drawable2 = this.f7745t;
        if (drawable2 != null) {
            drawable2.setCallback(null);
            unscheduleDrawable(this.f7745t);
        }
        this.f7745t = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            View view = this.f7743r;
            if (view != null) {
                this.f7745t.setBounds(view.getLeft(), this.f7743r.getTop(), this.f7743r.getRight(), this.f7743r.getBottom());
            }
        }
        boolean z8 = false;
        if (!this.f7748w ? !(this.f7745t != null || this.f7746u != null) : this.f7747v == null) {
            z8 = true;
        }
        setWillNotDraw(z8);
        invalidate();
        invalidateOutline();
    }

    public void setSplitBackground(Drawable drawable) {
        Drawable drawable2;
        Drawable drawable3 = this.f7747v;
        if (drawable3 != null) {
            drawable3.setCallback(null);
            unscheduleDrawable(this.f7747v);
        }
        this.f7747v = drawable;
        boolean z8 = this.f7748w;
        boolean z9 = false;
        if (drawable != null) {
            drawable.setCallback(this);
            if (z8 && (drawable2 = this.f7747v) != null) {
                drawable2.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            }
        }
        if (!z8 ? !(this.f7745t != null || this.f7746u != null) : this.f7747v == null) {
            z9 = true;
        }
        setWillNotDraw(z9);
        invalidate();
        invalidateOutline();
    }

    public void setStackedBackground(Drawable drawable) {
        Drawable drawable2 = this.f7746u;
        if (drawable2 != null) {
            drawable2.setCallback(null);
            unscheduleDrawable(this.f7746u);
        }
        this.f7746u = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.f7749x && this.f7746u != null) {
                throw null;
            }
        }
        boolean z8 = false;
        if (!this.f7748w ? !(this.f7745t != null || this.f7746u != null) : this.f7747v == null) {
            z8 = true;
        }
        setWillNotDraw(z8);
        invalidate();
        invalidateOutline();
    }

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

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

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

    @Override // android.view.View
    public final boolean verifyDrawable(Drawable drawable) {
        Drawable drawable2 = this.f7745t;
        boolean z8 = this.f7748w;
        if (drawable == drawable2 && !z8) {
            return true;
        }
        if (drawable == this.f7746u && this.f7749x) {
            return true;
        }
        return (drawable == this.f7747v && z8) || super.verifyDrawable(drawable);
    }

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

    public void setTabContainer(AbstractC1240v0 abstractC1240v0) {
    }
}
