package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

/* JADX INFO: compiled from: AbsActionBarView.java */
/* JADX INFO: loaded from: classes.dex */
abstract class a extends ViewGroup {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    protected final C0021a f528c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    protected final Context f529d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    protected ActionMenuView f530e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    protected c f531f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    protected int f532g;
    protected a.c.i.o h;
    private boolean i;
    private boolean j;

    /* JADX INFO: renamed from: androidx.appcompat.widget.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: AbsActionBarView.java */
    protected class C0021a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private boolean f533a = false;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        int f534b;

        protected C0021a() {
        }
    }

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

    protected static int b(int i, int i2, boolean z) {
        return z ? i - i2 : i + i2;
    }

    protected int a(View view, int i, int i2, int i3) {
        view.measure(View.MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE), i2);
        return Math.max(0, (i - view.getMeasuredWidth()) - i3);
    }

    protected int c(View view, int i, int i2, int i3, boolean z) {
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        int i4 = i2 + ((i3 - measuredHeight) / 2);
        if (z) {
            view.layout(i - measuredWidth, i4, i, measuredHeight + i4);
        } else {
            view.layout(i, i4, i + measuredWidth, measuredHeight + i4);
        }
        return z ? -measuredWidth : measuredWidth;
    }

    public int getAnimatedVisibility() {
        return this.h != null ? this.f528c.f534b : getVisibility();
    }

    public int getContentHeight() {
        return this.f532g;
    }

    @Override // android.view.View
    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, a.a.j.f51a, a.a.a.f2c, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(a.a.j.i, 0));
        typedArrayObtainStyledAttributes.recycle();
        c cVar = this.f531f;
        if (cVar != null) {
            cVar.B(configuration);
        }
    }

    @Override // android.view.View
    public boolean onHoverEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 9) {
            this.j = false;
        }
        if (!this.j) {
            boolean zOnHoverEvent = super.onHoverEvent(motionEvent);
            if (actionMasked == 9 && !zOnHoverEvent) {
                this.j = true;
            }
        }
        if (actionMasked == 10 || actionMasked == 3) {
            this.j = false;
        }
        return true;
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.i = false;
        }
        if (!this.i) {
            boolean zOnTouchEvent = super.onTouchEvent(motionEvent);
            if (actionMasked == 0 && !zOnTouchEvent) {
                this.i = true;
            }
        }
        if (actionMasked == 1 || actionMasked == 3) {
            this.i = false;
        }
        return true;
    }

    public abstract void setContentHeight(int i);

    @Override // android.view.View
    public void setVisibility(int i) {
        if (i != getVisibility()) {
            if (this.h != null) {
                throw null;
            }
            super.setVisibility(i);
        }
    }

    a(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f528c = new C0021a();
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(a.a.a.f0a, typedValue, true) || typedValue.resourceId == 0) {
            this.f529d = context;
        } else {
            this.f529d = new ContextThemeWrapper(context, typedValue.resourceId);
        }
    }
}
