content: package androidx.appcompat.widget;
  
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.res.ColorStateList;
  import android.content.res.Resources;
  import android.database.DataSetObserver;
  import android.graphics.PorterDuff;
  import android.graphics.Rect;
  import android.graphics.drawable.Drawable;
  import android.os.Build;
  import android.os.Parcel;
  import android.os.Parcelable;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.ViewTreeObserver;
  import android.widget.AdapterView;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.PopupWindow;
  import android.widget.Spinner;
  import android.widget.SpinnerAdapter;
  import android.widget.ThemedSpinnerAdapter;
  import androidx.appcompat.R;
  import androidx.appcompat.app.AlertDialog;
  import androidx.appcompat.content.res.AppCompatResources;
  import androidx.core.view.TintableBackgroundView;
  import androidx.core.view.ViewCompat;
  
  public class AppCompatSpinner extends Spinner implements TintableBackgroundView {
      private static final int[] ATTRS_ANDROID_SPINNERMODE = {16843505};
      private static final int MAX_ITEMS_MEASURED = 15;
      private static final int MODE_DIALOG = 0;
      private static final int MODE_DROPDOWN = 1;
      private static final int MODE_THEME = -1;
      private static final String TAG = "AppCompatSpinner";
      private final AppCompatBackgroundHelper mBackgroundTintHelper;
      int mDropDownWidth;
      private ForwardingListener mForwardingListener;
      private SpinnerPopup mPopup;
      private final Context mPopupContext;
      private final boolean mPopupSet;
      private SpinnerAdapter mTempAdapter;
      final Rect mTempRect;
  
      private static final class Api16Impl {
          private Api16Impl() {
          }
  
          static void removeOnGlobalLayoutListener(ViewTreeObserver viewTreeObserver, ViewTreeObserver.OnGlobalLayoutListener victim) {
              viewTreeObserver.removeOnGlobalLayoutListener(victim);
          }
      }
  
      private static final class Api17Impl {
          private Api17Impl() {
          }
  
          static int getTextAlignment(View view) {
              return view.getTextAlignment();
          }
  
          static int getTextDirection(View view) {
              return view.getTextDirection();
          }
  
          static void setTextAlignment(View view, int textAlignment) {
              view.setTextAlignment(textAlignment);
          }
  
          static void setTextDirection(View view, int textDirection) {
              view.setTextDirection(textDirection);
          }
      }
  
      private static final class Api23Impl {
          private Api23Impl() {
          }
  
          static void setDropDownViewTheme(ThemedSpinnerAdapter themedSpinnerAdapter, Resources.Theme theme) {
              if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
                  themedSpinnerAdapter.setDropDownViewTheme(theme);
              }
          }
      }
  
      class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener {
          private ListAdapter mListAdapter;
          AlertDialog mPopup;
          private CharSequence mPrompt;
  
          DialogPopup() {
          }
  
          public void dismiss() {
              AlertDialog alertDialog = this.mPopup;
              if (alertDialog != null) {
                  alertDialog.dismiss();
                  this.mPopup = null;
              }
          }
  
          public Drawable getBackground() {
              return null;
          }
  
          public CharSequence getHintText() {
              return this.mPrompt;
          }
  
          public int getHorizontalOffset() {
              return 0;
          }
  
          public int getHorizontalOriginalOffset() {
              return 0;
          }
  
          public int getVerticalOffset() {
              return 0;
          }
  
          public boolean isShowing() {
              AlertDialog alertDialog = this.mPopup;
              if (alertDialog != null) {
                  return alertDialog.isShowing();
              }
              return false;
          }
  
          public void onClick(DialogInterface dialog, int which) {
              AppCompatSpinner.this.setSelection(which);
              if (AppCompatSpinner.this.getOnItemClickListener() != null) {
                  AppCompatSpinner.this.performItemClick((View) null, which, this.mListAdapter.getItemId(which));
              }
              dismiss();
          }
  
          public void setAdapter(ListAdapter adapter) {
              this.mListAdapter = adapter;
          }
  
          public void setBackgroundDrawable(Drawable bg) {
              Log.e(AppCompatSpinner.TAG, "Cannot set popup background for MODE_DIALOG, ignoring");
          }
  
          public void setHorizontalOffset(int px) {
              Log.e(AppCompatSpinner.TAG, "Cannot set horizontal offset for MODE_DIALOG, ignoring");
          }
  
          public void setHorizontalOriginalOffset(int px) {
              Log.e(AppCompatSpinner.TAG, "Cannot set horizontal (original) offset for MODE_DIALOG, ignoring");
          }
  
          public void setPromptText(CharSequence hintText) {
              this.mPrompt = hintText;
          }
  
          public void setVerticalOffset(int px) {
              Log.e(AppCompatSpinner.TAG, "Cannot set vertical offset for MODE_DIALOG, ignoring");
          }
  
          public void show(int textDirection, int textAlignment) {
              if (this.mListAdapter != null) {
                  AlertDialog.Builder builder = new AlertDialog.Builder(AppCompatSpinner.this.getPopupContext());
                  CharSequence charSequence = this.mPrompt;
                  if (charSequence != null) {
                      builder.setTitle(charSequence);
                  }
                  AlertDialog create = builder.setSingleChoiceItems(this.mListAdapter, AppCompatSpinner.this.getSelectedItemPosition(), (DialogInterface.OnClickListener) this).create();
                  this.mPopup = create;
                  ListView listView = create.getListView();
                  if (Build.VERSION.SDK_INT >= 17) {
                      Api17Impl.setTextDirection(listView, textDirection);
                      Api17Impl.setTextAlignment(listView, textAlignment);
                  }
                  this.mPopup.show();
              }
          }
      }
  
      private static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
          private SpinnerAdapter mAdapter;
          private ListAdapter mListAdapter;
  
          public DropDownAdapter(SpinnerAdapter adapter, Resources.Theme dropDownTheme) {
              this.mAdapter = adapter;
              if (adapter instanceof ListAdapter) {
                  this.mListAdapter = (ListAdapter) adapter;
              }
              if (dropDownTheme == null) {
                  return;
              }
              if (Build.VERSION.SDK_INT >= 23 && (adapter instanceof ThemedSpinnerAdapter)) {
                  Api23Impl.setDropDownViewTheme((ThemedSpinnerAdapter) adapter, dropDownTheme);
              } else if (adapter instanceof ThemedSpinnerAdapter) {
                  ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) adapter;
                  if (themedSpinnerAdapter.getDropDownViewTheme() == null) {
                      themedSpinnerAdapter.setDropDownViewTheme(dropDownTheme);
                  }
              }
          }
  
          public boolean areAllItemsEnabled() {
              ListAdapter listAdapter = this.mListAdapter;
              if (listAdapter != null) {
                  return listAdapter.areAllItemsEnabled();
              }
              return true;
          }
  
          public int getCount() {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              if (spinnerAdapter == null) {
                  return 0;
              }
              return spinnerAdapter.getCount();
          }
  
          public View getDropDownView(int position, View convertView, ViewGroup parent) {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              if (spinnerAdapter == null) {
                  return null;
              }
              return spinnerAdapter.getDropDownView(position, convertView, parent);
          }
  
          public Object getItem(int position) {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              if (spinnerAdapter == null) {
                  return null;
              }
              return spinnerAdapter.getItem(position);
          }
  
          public long getItemId(int position) {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              if (spinnerAdapter == null) {
                  return -1;
              }
              return spinnerAdapter.getItemId(position);
          }
  
          public int getItemViewType(int position) {
              return 0;
          }
  
          public View getView(int position, View convertView, ViewGroup parent) {
              return getDropDownView(position, convertView, parent);
          }
  
          public int getViewTypeCount() {
              return 1;
          }
  
          public boolean hasStableIds() {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              return spinnerAdapter != null && spinnerAdapter.hasStableIds();
          }
  
          public boolean isEmpty() {
              return getCount() == 0;
          }
  
          public boolean isEnabled(int position) {
              ListAdapter listAdapter = this.mListAdapter;
              if (listAdapter != null) {
                  return listAdapter.isEnabled(position);
              }
              return true;
          }
  
          public void registerDataSetObserver(DataSetObserver observer) {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              if (spinnerAdapter != null) {
                  spinnerAdapter.registerDataSetObserver(observer);
              }
          }
  
          public void unregisterDataSetObserver(DataSetObserver observer) {
              SpinnerAdapter spinnerAdapter = this.mAdapter;
              if (spinnerAdapter != null) {
                  spinnerAdapter.unregisterDataSetObserver(observer);
              }
          }
      }
  
      class DropdownPopup extends ListPopupWindow implements SpinnerPopup {
          ListAdapter mAdapter;
          private CharSequence mHintText;
          private int mOriginalHorizontalOffset;
          private final Rect mVisibleRect = new Rect();
  
          public DropdownPopup(Context context, AttributeSet attrs, int defStyleAttr) {
              super(context, attrs, defStyleAttr);
              setAnchorView(AppCompatSpinner.this);
              setModal(true);
              setPromptPosition(0);
              setOnItemClickListener(new AdapterView.OnItemClickListener(AppCompatSpinner.this) {
                  public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {
                      AppCompatSpinner.this.setSelection(position);
                      if (AppCompatSpinner.this.getOnItemClickListener() != null) {
                          AppCompatSpinner.this.performItemClick(v, position, DropdownPopup.this.mAdapter.getItemId(position));
                      }
                      DropdownPopup.this.dismiss();
                  }
              });
          }
  
          /* access modifiers changed from: package-private */
          public void computeContentWidth() {
              Drawable background = getBackground();
              int i = 0;
              if (background != null) {
                  background.getPadding(AppCompatSpinner.this.mTempRect);
                  i = ViewUtils.isLayoutRtl(AppCompatSpinner.this) ? AppCompatSpinner.this.mTempRect.right : -AppCompatSpinner.this.mTempRect.left;
              } else {
                  Rect rect = AppCompatSpinner.this.mTempRect;
                  AppCompatSpinner.this.mTempRect.right = 0;
                  rect.left = 0;
              }
              int paddingLeft = AppCompatSpinner.this.getPaddingLeft();
              int paddingRight = AppCompatSpinner.this.getPaddingRight();
              int width = AppCompatSpinner.this.getWidth();
              if (AppCompatSpinner.this.mDropDownWidth == -2) {
                  int compatMeasureContentWidth = AppCompatSpinner.this.compatMeasureContentWidth((SpinnerAdapter) this.mAdapter, getBackground());
                  int i2 = (AppCompatSpinner.this.getContext().getResources().getDisplayMetrics().widthPixels - AppCompatSpinner.this.mTempRect.left) - AppCompatSpinner.this.mTempRect.right;
                  if (compatMeasureContentWidth > i2) {
                      compatMeasureContentWidth = i2;
                  }
                  setContentWidth(Math.max(compatMeasureContentWidth, (width - paddingLeft) - paddingRight));
              } else if (AppCompatSpinner.this.mDropDownWidth == -1) {
                  setContentWidth((width - paddingLeft) - paddingRight);
              } else {
                  setContentWidth(AppCompatSpinner.this.mDropDownWidth);
              }
              setHorizontalOffset(ViewUtils.isLayoutRtl(AppCompatSpinner.this) ? i + (((width - paddingRight) - getWidth()) - getHorizontalOriginalOffset()) : i + getHorizontalOriginalOffset() + paddingLeft);
          }
  
          public CharSequence getHintText() {
              return this.mHintText;
          }
  
          public int getHorizontalOriginalOffset() {
              return this.mOriginalHorizontalOffset;
          }
  
          /* access modifiers changed from: package-private */
          public boolean isVisibleToUser(View view) {
              return ViewCompat.isAttachedToWindow(view) && view.getGlobalVisibleRect(this.mVisibleRect);
          }
  
          public void setAdapter(ListAdapter adapter) {
              super.setAdapter(adapter);
              this.mAdapter = adapter;
          }
  
          public void setHorizontalOriginalOffset(int px) {
              this.mOriginalHorizontalOffset = px;
          }
  
          public void setPromptText(CharSequence hintText) {
              this.mHintText = hintText;
          }
  
          public void show(int textDirection, int textAlignment) {
              ViewTreeObserver viewTreeObserver;
              boolean isShowing = isShowing();
              computeContentWidth();
              setInputMethodMode(2);
              super.show();
              ListView listView = getListView();
              listView.setChoiceMode(1);
              if (Build.VERSION.SDK_INT >= 17) {
                  Api17Impl.setTextDirection(listView, textDirection);
                  Api17Impl.setTextAlignment(listView, textAlignment);
              }
              setSelection(AppCompatSpinner.this.getSelectedItemPosition());
              if (!isShowing && (viewTreeObserver = AppCompatSpinner.this.getViewTreeObserver()) != null) {
                  final AnonymousClass2 r3 = new ViewTreeObserver.OnGlobalLayoutListener() {
                      public void onGlobalLayout() {
                          DropdownPopup dropdownPopup = DropdownPopup.this;
                          if (!dropdownPopup.isVisibleToUser(AppCompatSpinner.this)) {
                              DropdownPopup.this.dismiss();
                              return;
                          }
                          DropdownPopup.this.computeContentWidth();
                          DropdownPopup.super.show();
                      }
                  };
                  viewTreeObserver.addOnGlobalLayoutListener(r3);
                  setOnDismissListener(new PopupWindow.OnDismissListener() {
                      public void onDismiss() {
                          ViewTreeObserver viewTreeObserver = AppCompatSpinner.this.getViewTreeObserver();
                          if (viewTreeObserver != null) {
                              viewTreeObserver.removeGlobalOnLayoutListener(r3);
                          }
                      }
                  });
              }
          }
      }
  
      static class SavedState extends View.BaseSavedState {
          public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
              public SavedState createFromParcel(Parcel in) {
                  return new SavedState(in);
              }
  
              public SavedState[] newArray(int size) {
                  return new SavedState[size];
              }
          };
          boolean mShowDropdown;
  
          SavedState(Parcel in) {
              super(in);
              this.mShowDropdown = in.readByte() != 0;
          }
  
          SavedState(Parcelable superState) {
              super(superState);
          }
  
          public void writeToParcel(Parcel out, int flags) {
              super.writeToParcel(out, flags);
              out.writeByte(this.mShowDropdown ? (byte) 1 : 0);
          }
      }
  
      interface SpinnerPopup {
          void dismiss();
  
          Drawable getBackground();
  
          CharSequence getHintText();
  
          int getHorizontalOffset();
  
          int getHorizontalOriginalOffset();
  
          int getVerticalOffset();
  
          boolean isShowing();
  
          void setAdapter(ListAdapter listAdapter);
  
          void setBackgroundDrawable(Drawable drawable);
  
          void setHorizontalOffset(int i);
  
          void setHorizontalOriginalOffset(int i);
  
          void setPromptText(CharSequence charSequence);
  
          void setVerticalOffset(int i);
  
          void show(int i, int i2);
      }
  
      public AppCompatSpinner(Context context) {
          this(context, (AttributeSet) null);
      }
  
      public AppCompatSpinner(Context context, int mode) {
          this(context, (AttributeSet) null, R.attr.spinnerStyle, mode);
      }
  
      public AppCompatSpinner(Context context, AttributeSet attrs) {
          this(context, attrs, R.attr.spinnerStyle);
      }
  
      public AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
          this(context, attrs, defStyleAttr, -1);
      }
  
      public AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode) {
          this(context, attrs, defStyleAttr, mode, (Resources.Theme) null);
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:15:0x0051, code lost:
          if (r2 != null) goto L_0x0053;
       */
      /* JADX WARNING: Code restructure failed: missing block: B:16:0x0053, code lost:
          r2.recycle();
       */
      /* JADX WARNING: Code restructure failed: missing block: B:22:0x0062, code lost:
          if (r2 == null) goto L_0x006b;
       */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      public AppCompatSpinner(android.content.Context r7, android.util.AttributeSet r8, int r9, int r10, android.content.res.Resources.Theme r11) {
          /*
              r6 = this;
              r6.<init>(r7, r8, r9)
              android.graphics.Rect r0 = new android.graphics.Rect
              r0.<init>()
              r6.mTempRect = r0
              android.content.Context r0 = r6.getContext()
              androidx.appcompat.widget.ThemeUtils.checkAppCompatTheme(r6, r0)
              int[] r0 = androidx.appcompat.R.styleable.Spinner
              r1 = 0
              androidx.appcompat.widget.TintTypedArray r0 = androidx.appcompat.widget.TintTypedArray.obtainStyledAttributes(r7, r8, r0, r9, r1)
              androidx.appcompat.widget.AppCompatBackgroundHelper r2 = new androidx.appcompat.widget.AppCompatBackgroundHelper
              r2.<init>(r6)
              r6.mBackgroundTintHelper = r2
              if (r11 == 0) goto L_0x0029
              androidx.appcompat.view.ContextThemeWrapper r2 = new androidx.appcompat.view.ContextThemeWrapper
              r2.<init>((android.content.Context) r7, (android.content.res.Resources.Theme) r11)
              r6.mPopupContext = r2
              goto L_0x003b
          L_0x0029:
              int r2 = androidx.appcompat.R.styleable.Spinner_popupTheme
              int r2 = r0.getResourceId(r2, r1)
              if (r2 == 0) goto L_0x0039
              androidx.appcompat.view.ContextThemeWrapper r3 = new androidx.appcompat.view.ContextThemeWrapper
              r3.<init>((android.content.Context) r7, (int) r2)
              r6.mPopupContext = r3
              goto L_0x003b
          L_0x0039:
              r6.mPopupContext = r7
          L_0x003b:
              r2 = -1
              if (r10 != r2) goto L_0x006b
              r2 = 0
              int[] r3 = ATTRS_ANDROID_SPINNERMODE     // Catch:{ Exception -> 0x0059 }
              android.content.res.TypedArray r3 = r7.obtainStyledAttributes(r8, r3, r9, r1)     // Catch:{ Exception -> 0x0059 }
              r2 = r3
              boolean r3 = r2.hasValue(r1)     // Catch:{ Exception -> 0x0059 }
              if (r3 == 0) goto L_0x0051
              int r3 = r2.getInt(r1, r1)     // Catch:{ Exception -> 0x0059 }
              r10 = r3
          L_0x0051:
              if (r2 == 0) goto L_0x006b
          L_0x0053:
              r2.recycle()
              goto L_0x006b
          L_0x0057:
              r1 = move-exception
              goto L_0x0065
          L_0x0059:
              r3 = move-exception
              java.lang.String r4 = "AppCompatSpinner"
              java.lang.String r5 = "Could not read android:spinnerMode"
              android.util.Log.i(r4, r5, r3)     // Catch:{ all -> 0x0057 }
              if (r2 == 0) goto L_0x006b
              goto L_0x0053
          L_0x0065:
              if (r2 == 0) goto L_0x006a
              r2.recycle()
          L_0x006a:
              throw r1
          L_0x006b:
              switch(r10) {
                  case 0: goto L_0x00a6;
                  case 1: goto L_0x006f;
                  default: goto L_0x006e;
              }
          L_0x006e:
              goto L_0x00b7
          L_0x006f:
              androidx.appcompat.widget.AppCompatSpinner$DropdownPopup r2 = new androidx.appcompat.widget.AppCompatSpinner$DropdownPopup
              android.content.Context r3 = r6.mPopupContext
              r2.<init>(r3, r8, r9)
              android.content.Context r3 = r6.mPopupContext
              int[] r4 = androidx.appcompat.R.styleable.Spinner
              androidx.appcompat.widget.TintTypedArray r1 = androidx.appcompat.widget.TintTypedArray.obtainStyledAttributes(r3, r8, r4, r9, r1)
              int r3 = androidx.appcompat.R.styleable.Spinner_android_dropDownWidth
              r4 = -2
              int r3 = r1.getLayoutDimension((int) r3, (int) r4)
              r6.mDropDownWidth = r3
              int r3 = androidx.appcompat.R.styleable.Spinner_android_popupBackground
              android.graphics.drawable.Drawable r3 = r1.getDrawable(r3)
              r2.setBackgroundDrawable(r3)
              int r3 = androidx.appcompat.R.styleable.Spinner_android_prompt
              java.lang.String r3 = r0.getString(r3)
              r2.setPromptText(r3)
              r1.recycle()
              r6.mPopup = r2
              androidx.appcompat.widget.AppCompatSpinner$1 r3 = new androidx.appcompat.widget.AppCompatSpinner$1
              r3.<init>(r6, r2)
              r6.mForwardingListener = r3
              goto L_0x00b7
          L_0x00a6:
              androidx.appcompat.widget.AppCompatSpinner$DialogPopup r1 = new androidx.appcompat.widget.AppCompatSpinner$DialogPopup
              r1.<init>()
              r6.mPopup = r1
              int r2 = androidx.appcompat.R.styleable.Spinner_android_prompt
              java.lang.String r2 = r0.getString(r2)
              r1.setPromptText(r2)
          L_0x00b7:
              int r1 = androidx.appcompat.R.styleable.Spinner_android_entries
              java.lang.CharSequence[] r1 = r0.getTextArray(r1)
              if (r1 == 0) goto L_0x00cf
              android.widget.ArrayAdapter r2 = new android.widget.ArrayAdapter
              r3 = 17367048(0x1090008, float:2.5162948E-38)
              r2.<init>(r7, r3, r1)
              int r3 = androidx.appcompat.R.layout.support_simple_spinner_dropdown_item
              r2.setDropDownViewResource(r3)
              r6.setAdapter((android.widget.SpinnerAdapter) r2)
          L_0x00cf:
              r0.recycle()
              r2 = 1
              r6.mPopupSet = r2
              android.widget.SpinnerAdapter r2 = r6.mTempAdapter
              if (r2 == 0) goto L_0x00df
              r6.setAdapter((android.widget.SpinnerAdapter) r2)
              r2 = 0
              r6.mTempAdapter = r2
          L_0x00df:
              androidx.appcompat.widget.AppCompatBackgroundHelper r2 = r6.mBackgroundTintHelper
              r2.loadFromAttributes(r8, r9)
              return
          */
          throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.AppCompatSpinner.<init>(android.content.Context, android.util.AttributeSet, int, int, android.content.res.Resources$Theme):void");
      }
  
      /* access modifiers changed from: package-private */
      public int compatMeasureContentWidth(SpinnerAdapter adapter, Drawable background) {
          if (adapter == null) {
              return 0;
          }
          int i = 0;
          View view = null;
          int i2 = 0;
          int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
          int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
          int max = Math.max(0, getSelectedItemPosition());
          int min = Math.min(adapter.getCount(), max + 15);
          for (int max2 = Math.max(0, max - (15 - (min - max))); max2 < min; max2++) {
              int itemViewType = adapter.getItemViewType(max2);
              if (itemViewType != i2) {
                  i2 = itemViewType;
                  view = null;
              }
              view = adapter.getView(max2, view, this);
              if (view.getLayoutParams() == null) {
                  view.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
              }
              view.measure(makeMeasureSpec, makeMeasureSpec2);
              i = Math.max(i, view.getMeasuredWidth());
          }
          if (background == null) {
              return i;
          }
          background.getPadding(this.mTempRect);
          return i + this.mTempRect.left + this.mTempRect.right;
      }
  
      /* access modifiers changed from: protected */
      public void drawableStateChanged() {
          super.drawableStateChanged();
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              appCompatBackgroundHelper.applySupportBackgroundTint();
          }
      }
  
      public int getDropDownHorizontalOffset() {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              return spinnerPopup.getHorizontalOffset();
          }
          if (Build.VERSION.SDK_INT >= 16) {
              return super.getDropDownHorizontalOffset();
          }
          return 0;
      }
  
      public int getDropDownVerticalOffset() {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              return spinnerPopup.getVerticalOffset();
          }
          if (Build.VERSION.SDK_INT >= 16) {
              return super.getDropDownVerticalOffset();
          }
          return 0;
      }
  
      public int getDropDownWidth() {
          if (this.mPopup != null) {
              return this.mDropDownWidth;
          }
          if (Build.VERSION.SDK_INT >= 16) {
              return super.getDropDownWidth();
          }
          return 0;
      }
  
      /* access modifiers changed from: package-private */
      public final SpinnerPopup getInternalPopup() {
          return this.mPopup;
      }
  
      public Drawable getPopupBackground() {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              return spinnerPopup.getBackground();
          }
          if (Build.VERSION.SDK_INT >= 16) {
              return super.getPopupBackground();
          }
          return null;
      }
  
      public Context getPopupContext() {
          return this.mPopupContext;
      }
  
      public CharSequence getPrompt() {
          SpinnerPopup spinnerPopup = this.mPopup;
          return spinnerPopup != null ? spinnerPopup.getHintText() : super.getPrompt();
      }
  
      public ColorStateList getSupportBackgroundTintList() {
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              return appCompatBackgroundHelper.getSupportBackgroundTintList();
          }
          return null;
      }
  
      public PorterDuff.Mode getSupportBackgroundTintMode() {
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              return appCompatBackgroundHelper.getSupportBackgroundTintMode();
          }
          return null;
      }
  
      /* access modifiers changed from: protected */
      public void onDetachedFromWindow() {
          super.onDetachedFromWindow();
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null && spinnerPopup.isShowing()) {
              this.mPopup.dismiss();
          }
      }
  
      /* access modifiers changed from: protected */
      public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          super.onMeasure(widthMeasureSpec, heightMeasureSpec);
          if (this.mPopup != null && View.MeasureSpec.getMode(widthMeasureSpec) == Integer.MIN_VALUE) {
              setMeasuredDimension(Math.min(Math.max(getMeasuredWidth(), compatMeasureContentWidth(getAdapter(), getBackground())), View.MeasureSpec.getSize(widthMeasureSpec)), getMeasuredHeight());
          }
      }
  
      public void onRestoreInstanceState(Parcelable state) {
          ViewTreeObserver viewTreeObserver;
          SavedState savedState = (SavedState) state;
          super.onRestoreInstanceState(savedState.getSuperState());
          if (savedState.mShowDropdown && (viewTreeObserver = getViewTreeObserver()) != null) {
              viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                  public void onGlobalLayout() {
                      if (!AppCompatSpinner.this.getInternalPopup().isShowing()) {
                          AppCompatSpinner.this.showPopup();
                      }
                      ViewTreeObserver viewTreeObserver = AppCompatSpinner.this.getViewTreeObserver();
                      if (viewTreeObserver == null) {
                          return;
                      }
                      if (Build.VERSION.SDK_INT >= 16) {
                          Api16Impl.removeOnGlobalLayoutListener(viewTreeObserver, this);
                      } else {
                          viewTreeObserver.removeGlobalOnLayoutListener(this);
                      }
                  }
              });
          }
      }
  
      public Parcelable onSaveInstanceState() {
          SavedState savedState = new SavedState(super.onSaveInstanceState());
          SpinnerPopup spinnerPopup = this.mPopup;
          savedState.mShowDropdown = spinnerPopup != null && spinnerPopup.isShowing();
          return savedState;
      }
  
      public boolean onTouchEvent(MotionEvent event) {
          ForwardingListener forwardingListener = this.mForwardingListener;
          if (forwardingListener == null || !forwardingListener.onTouch(this, event)) {
              return super.onTouchEvent(event);
          }
          return true;
      }
  
      public boolean performClick() {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup == null) {
              return super.performClick();
          }
          if (spinnerPopup.isShowing()) {
              return true;
          }
          showPopup();
          return true;
      }
  
      public void setAdapter(SpinnerAdapter adapter) {
          if (!this.mPopupSet) {
              this.mTempAdapter = adapter;
              return;
          }
          super.setAdapter(adapter);
          if (this.mPopup != null) {
              Context context = this.mPopupContext;
              if (context == null) {
                  context = getContext();
              }
              this.mPopup.setAdapter(new DropDownAdapter(adapter, context.getTheme()));
          }
      }
  
      public void setBackgroundDrawable(Drawable background) {
          super.setBackgroundDrawable(background);
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              appCompatBackgroundHelper.onSetBackgroundDrawable(background);
          }
      }
  
      public void setBackgroundResource(int resId) {
          super.setBackgroundResource(resId);
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              appCompatBackgroundHelper.onSetBackgroundResource(resId);
          }
      }
  
      public void setDropDownHorizontalOffset(int pixels) {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              spinnerPopup.setHorizontalOriginalOffset(pixels);
              this.mPopup.setHorizontalOffset(pixels);
          } else if (Build.VERSION.SDK_INT >= 16) {
              super.setDropDownHorizontalOffset(pixels);
          }
      }
  
      public void setDropDownVerticalOffset(int pixels) {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              spinnerPopup.setVerticalOffset(pixels);
          } else if (Build.VERSION.SDK_INT >= 16) {
              super.setDropDownVerticalOffset(pixels);
          }
      }
  
      public void setDropDownWidth(int pixels) {
          if (this.mPopup != null) {
              this.mDropDownWidth = pixels;
          } else if (Build.VERSION.SDK_INT >= 16) {
              super.setDropDownWidth(pixels);
          }
      }
  
      public void setPopupBackgroundDrawable(Drawable background) {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              spinnerPopup.setBackgroundDrawable(background);
          } else if (Build.VERSION.SDK_INT >= 16) {
              super.setPopupBackgroundDrawable(background);
          }
      }
  
      public void setPopupBackgroundResource(int resId) {
          setPopupBackgroundDrawable(AppCompatResources.getDrawable(getPopupContext(), resId));
      }
  
      public void setPrompt(CharSequence prompt) {
          SpinnerPopup spinnerPopup = this.mPopup;
          if (spinnerPopup != null) {
              spinnerPopup.setPromptText(prompt);
          } else {
              super.setPrompt(prompt);
          }
      }
  
      public void setSupportBackgroundTintList(ColorStateList tint) {
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              appCompatBackgroundHelper.setSupportBackgroundTintList(tint);
          }
      }
  
      public void setSupportBackgroundTintMode(PorterDuff.Mode tintMode) {
          AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
          if (appCompatBackgroundHelper != null) {
              appCompatBackgroundHelper.setSupportBackgroundTintMode(tintMode);
          }
      }
  
      /* access modifiers changed from: package-private */
      public void showPopup() {
          if (Build.VERSION.SDK_INT >= 17) {
              this.mPopup.show(Api17Impl.getTextDirection(this), Api17Impl.getTextAlignment(this));
          } else {
              this.mPopup.show(-1, -1);
          }
      }
  }
  