content: 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;
  import androidx.appcompat.R;
  import androidx.core.view.ViewCompat;
  import androidx.core.view.ViewPropertyAnimatorCompat;
  import androidx.core.view.ViewPropertyAnimatorListener;
  
  abstract class AbsActionBarView extends ViewGroup {
      private static final int FADE_DURATION = 200;
      protected ActionMenuPresenter mActionMenuPresenter;
      protected int mContentHeight;
      private boolean mEatingHover;
      private boolean mEatingTouch;
      protected ActionMenuView mMenuView;
      protected final Context mPopupContext;
      protected final VisibilityAnimListener mVisAnimListener;
      protected ViewPropertyAnimatorCompat mVisibilityAnim;
  
      protected class VisibilityAnimListener implements ViewPropertyAnimatorListener {
          private boolean mCanceled = false;
          int mFinalVisibility;
  
          protected VisibilityAnimListener() {
          }
  
          public void onAnimationCancel(View view) {
              this.mCanceled = true;
          }
  
          public void onAnimationEnd(View view) {
              if (!this.mCanceled) {
                  AbsActionBarView.this.mVisibilityAnim = null;
                  AbsActionBarView.super.setVisibility(this.mFinalVisibility);
              }
          }
  
          public void onAnimationStart(View view) {
              AbsActionBarView.super.setVisibility(0);
              this.mCanceled = false;
          }
  
          public VisibilityAnimListener withFinalVisibility(ViewPropertyAnimatorCompat animation, int visibility) {
              AbsActionBarView.this.mVisibilityAnim = animation;
              this.mFinalVisibility = visibility;
              return this;
          }
      }
  
      AbsActionBarView(Context context) {
          this(context, (AttributeSet) null);
      }
  
      AbsActionBarView(Context context, AttributeSet attrs) {
          this(context, attrs, 0);
      }
  
      AbsActionBarView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          this.mVisAnimListener = new VisibilityAnimListener();
          TypedValue typedValue = new TypedValue();
          if (!context.getTheme().resolveAttribute(R.attr.actionBarPopupTheme, typedValue, true) || typedValue.resourceId == 0) {
              this.mPopupContext = context;
          } else {
              this.mPopupContext = new ContextThemeWrapper(context, typedValue.resourceId);
          }
      }
  
      protected static int next(int x, int val, boolean isRtl) {
          return isRtl ? x - val : x + val;
      }
  
      public void animateToVisibility(int visibility) {
          setupAnimatorToVisibility(visibility, 200).start();
      }
  
      public boolean canShowOverflowMenu() {
          return isOverflowReserved() && getVisibility() == 0;
      }
  
      public void dismissPopupMenus() {
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          if (actionMenuPresenter != null) {
              actionMenuPresenter.dismissPopupMenus();
          }
      }
  
      public int getAnimatedVisibility() {
          return this.mVisibilityAnim != null ? this.mVisAnimListener.mFinalVisibility : getVisibility();
      }
  
      public int getContentHeight() {
          return this.mContentHeight;
      }
  
      public boolean hideOverflowMenu() {
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          if (actionMenuPresenter != null) {
              return actionMenuPresenter.hideOverflowMenu();
          }
          return false;
      }
  
      public boolean isOverflowMenuShowPending() {
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          if (actionMenuPresenter != null) {
              return actionMenuPresenter.isOverflowMenuShowPending();
          }
          return false;
      }
  
      public boolean isOverflowMenuShowing() {
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          if (actionMenuPresenter != null) {
              return actionMenuPresenter.isOverflowMenuShowing();
          }
          return false;
      }
  
      public boolean isOverflowReserved() {
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          return actionMenuPresenter != null && actionMenuPresenter.isOverflowReserved();
      }
  
      /* access modifiers changed from: protected */
      public int measureChildView(View child, int availableWidth, int childSpecHeight, int spacing) {
          child.measure(View.MeasureSpec.makeMeasureSpec(availableWidth, Integer.MIN_VALUE), childSpecHeight);
          return Math.max(0, (availableWidth - child.getMeasuredWidth()) - spacing);
      }
  
      /* access modifiers changed from: protected */
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes((AttributeSet) null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
          setContentHeight(obtainStyledAttributes.getLayoutDimension(R.styleable.ActionBar_height, 0));
          obtainStyledAttributes.recycle();
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          if (actionMenuPresenter != null) {
              actionMenuPresenter.onConfigurationChanged(newConfig);
          }
      }
  
      public boolean onHoverEvent(MotionEvent ev) {
          int actionMasked = ev.getActionMasked();
          if (actionMasked == 9) {
              this.mEatingHover = false;
          }
          if (!this.mEatingHover) {
              boolean onHoverEvent = super.onHoverEvent(ev);
              if (actionMasked == 9 && !onHoverEvent) {
                  this.mEatingHover = true;
              }
          }
          if (actionMasked == 10 || actionMasked == 3) {
              this.mEatingHover = false;
          }
          return true;
      }
  
      public boolean onTouchEvent(MotionEvent ev) {
          int actionMasked = ev.getActionMasked();
          if (actionMasked == 0) {
              this.mEatingTouch = false;
          }
          if (!this.mEatingTouch) {
              boolean onTouchEvent = super.onTouchEvent(ev);
              if (actionMasked == 0 && !onTouchEvent) {
                  this.mEatingTouch = true;
              }
          }
          if (actionMasked == 1 || actionMasked == 3) {
              this.mEatingTouch = false;
          }
          return true;
      }
  
      /* access modifiers changed from: protected */
      public int positionChild(View child, int x, int y, int contentHeight, boolean reverse) {
          int measuredWidth = child.getMeasuredWidth();
          int measuredHeight = child.getMeasuredHeight();
          int i = ((contentHeight - measuredHeight) / 2) + y;
          if (reverse) {
              child.layout(x - measuredWidth, i, x, i + measuredHeight);
          } else {
              child.layout(x, i, x + measuredWidth, i + measuredHeight);
          }
          return reverse ? -measuredWidth : measuredWidth;
      }
  
      public void postShowOverflowMenu() {
          post(new Runnable() {
              public void run() {
                  AbsActionBarView.this.showOverflowMenu();
              }
          });
      }
  
      public void setContentHeight(int height) {
          this.mContentHeight = height;
          requestLayout();
      }
  
      public void setVisibility(int visibility) {
          if (visibility != getVisibility()) {
              ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = this.mVisibilityAnim;
              if (viewPropertyAnimatorCompat != null) {
                  viewPropertyAnimatorCompat.cancel();
              }
              super.setVisibility(visibility);
          }
      }
  
      public ViewPropertyAnimatorCompat setupAnimatorToVisibility(int visibility, long duration) {
          ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = this.mVisibilityAnim;
          if (viewPropertyAnimatorCompat != null) {
              viewPropertyAnimatorCompat.cancel();
          }
          if (visibility == 0) {
              if (getVisibility() != 0) {
                  setAlpha(0.0f);
              }
              ViewPropertyAnimatorCompat alpha = ViewCompat.animate(this).alpha(1.0f);
              alpha.setDuration(duration);
              alpha.setListener(this.mVisAnimListener.withFinalVisibility(alpha, visibility));
              return alpha;
          }
          ViewPropertyAnimatorCompat alpha2 = ViewCompat.animate(this).alpha(0.0f);
          alpha2.setDuration(duration);
          alpha2.setListener(this.mVisAnimListener.withFinalVisibility(alpha2, visibility));
          return alpha2;
      }
  
      public boolean showOverflowMenu() {
          ActionMenuPresenter actionMenuPresenter = this.mActionMenuPresenter;
          if (actionMenuPresenter != null) {
              return actionMenuPresenter.showOverflowMenu();
          }
          return false;
      }
  }
  