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: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: AbsActionBarView.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class a extends ViewGroup {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    protected final C0005a f764e;

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

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

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    protected int f768i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    protected androidx.core.view.e0 f769j;

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

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

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

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

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

        protected C0005a() {
        }

        @Override // androidx.core.view.f0
        public void a(View view) {
            if (this.f772a) {
                return;
            }
            a aVar = a.this;
            aVar.f769j = null;
            a.super.setVisibility(this.f773b);
        }

        @Override // androidx.core.view.f0
        public void b(View view) {
            a.super.setVisibility(0);
            this.f772a = false;
        }

        @Override // androidx.core.view.f0
        public void c(View view) {
            this.f772a = true;
        }

        public C0005a d(androidx.core.view.e0 e0Var, int i3) {
            a.this.f769j = e0Var;
            this.f773b = i3;
            return this;
        }
    }

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

    protected static int d(int i3, int i4, boolean z2) {
        return z2 ? i3 - i4 : i3 + i4;
    }

    protected int c(View view, int i3, int i4, int i5) {
        view.measure(View.MeasureSpec.makeMeasureSpec(i3, Integer.MIN_VALUE), i4);
        return Math.max(0, (i3 - view.getMeasuredWidth()) - i5);
    }

    protected int e(View view, int i3, int i4, int i5, boolean z2) {
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        int i6 = i4 + ((i5 - measuredHeight) / 2);
        if (z2) {
            view.layout(i3 - measuredWidth, i6, i3, measuredHeight + i6);
        } else {
            view.layout(i3, i6, i3 + measuredWidth, measuredHeight + i6);
        }
        return z2 ? -measuredWidth : measuredWidth;
    }

    public androidx.core.view.e0 f(int i3, long j3) {
        androidx.core.view.e0 e0Var = this.f769j;
        if (e0Var != null) {
            e0Var.c();
        }
        if (i3 != 0) {
            androidx.core.view.e0 e0VarB = androidx.core.view.y.e(this).b(0.0f);
            e0VarB.f(j3);
            e0VarB.h(this.f764e.d(e0VarB, i3));
            return e0VarB;
        }
        if (getVisibility() != 0) {
            setAlpha(0.0f);
        }
        androidx.core.view.e0 e0VarB2 = androidx.core.view.y.e(this).b(1.0f);
        e0VarB2.f(j3);
        e0VarB2.h(this.f764e.d(e0VarB2, i3));
        return e0VarB2;
    }

    public int getAnimatedVisibility() {
        return this.f769j != null ? this.f764e.f773b : getVisibility();
    }

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

    @Override // android.view.View
    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, c.j.f3288a, c.a.f3152c, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(c.j.f3324j, 0));
        typedArrayObtainStyledAttributes.recycle();
        c cVar = this.f767h;
        if (cVar != null) {
            cVar.F(configuration);
        }
    }

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

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

    public abstract void setContentHeight(int i3);

    @Override // android.view.View
    public void setVisibility(int i3) {
        if (i3 != getVisibility()) {
            androidx.core.view.e0 e0Var = this.f769j;
            if (e0Var != null) {
                e0Var.c();
            }
            super.setVisibility(i3);
        }
    }

    a(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        this.f764e = new C0005a();
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(c.a.f3150a, typedValue, true) || typedValue.resourceId == 0) {
            this.f765f = context;
        } else {
            this.f765f = new ContextThemeWrapper(context, typedValue.resourceId);
        }
    }
}
