package d.b.g;

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;
import androidx.appcompat.widget.ActionMenuView;
import com.ifpdos.udi.service.core.pc.R;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final C0021a f1879f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final Context f1880m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public ActionMenuView f1881n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public c f1882o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f1883p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public d.h.j.d0 f1884q;

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

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

    /* JADX INFO: renamed from: d.b.g.a$a, reason: collision with other inner class name */
    public class C0021a implements d.h.j.e0 {
        public boolean a = false;

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

        public C0021a() {
        }

        @Override // d.h.j.e0
        public void a(View view) {
            this.a = true;
        }

        @Override // d.h.j.e0
        public void b(View view) {
            if (this.a) {
                return;
            }
            a aVar = a.this;
            aVar.f1884q = null;
            a.super.setVisibility(this.f1887b);
        }

        @Override // d.h.j.e0
        public void c(View view) {
            a.super.setVisibility(0);
            this.a = false;
        }
    }

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

    public a(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        this.f1879f = new C0021a();
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(R.attr.actionBarPopupTheme, typedValue, true) || typedValue.resourceId == 0) {
            this.f1880m = context;
        } else {
            this.f1880m = new ContextThemeWrapper(context, typedValue.resourceId);
        }
    }

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

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

    public d.h.j.d0 e(int i2, long j2) {
        d.h.j.d0 d0Var = this.f1884q;
        if (d0Var != null) {
            d0Var.b();
        }
        if (i2 != 0) {
            d.h.j.d0 d0VarB = d.h.j.y.b(this);
            d0VarB.a(0.0f);
            d0VarB.c(j2);
            C0021a c0021a = this.f1879f;
            a.this.f1884q = d0VarB;
            c0021a.f1887b = i2;
            View view = d0VarB.a.get();
            if (view != null) {
                d0VarB.e(view, c0021a);
            }
            return d0VarB;
        }
        if (getVisibility() != 0) {
            setAlpha(0.0f);
        }
        d.h.j.d0 d0VarB2 = d.h.j.y.b(this);
        d0VarB2.a(1.0f);
        d0VarB2.c(j2);
        C0021a c0021a2 = this.f1879f;
        a.this.f1884q = d0VarB2;
        c0021a2.f1887b = i2;
        View view2 = d0VarB2.a.get();
        if (view2 != null) {
            d0VarB2.e(view2, c0021a2);
        }
        return d0VarB2;
    }

    public int getAnimatedVisibility() {
        return this.f1884q != null ? this.f1879f.f1887b : getVisibility();
    }

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

    @Override // android.view.View
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, d.b.b.a, R.attr.actionBarStyle, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(13, 0));
        typedArrayObtainStyledAttributes.recycle();
        c cVar = this.f1882o;
        if (cVar != null) {
            Configuration configuration2 = cVar.f1741m.getResources().getConfiguration();
            int i2 = configuration2.screenWidthDp;
            int i3 = configuration2.screenHeightDp;
            cVar.A = (configuration2.smallestScreenWidthDp > 600 || i2 > 600 || (i2 > 960 && i3 > 720) || (i2 > 720 && i3 > 960)) ? 5 : (i2 >= 500 || (i2 > 640 && i3 > 480) || (i2 > 480 && i3 > 640)) ? 4 : i2 >= 360 ? 3 : 2;
            d.b.f.i.g gVar = cVar.f1742n;
            if (gVar != null) {
                gVar.q(true);
            }
        }
    }

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

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

    public abstract void setContentHeight(int i2);

    @Override // android.view.View
    public void setVisibility(int i2) {
        if (i2 != getVisibility()) {
            d.h.j.d0 d0Var = this.f1884q;
            if (d0Var != null) {
                d0Var.b();
            }
            super.setVisibility(i2);
        }
    }
}
