content: package androidx.appcompat.app;
  
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.res.TypedArray;
  import android.database.Cursor;
  import android.graphics.drawable.Drawable;
  import android.os.Build;
  import android.os.Handler;
  import android.os.Message;
  import android.text.TextUtils;
  import android.util.AttributeSet;
  import android.util.TypedValue;
  import android.view.KeyEvent;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.ViewParent;
  import android.view.ViewStub;
  import android.view.Window;
  import android.widget.AbsListView;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.CheckedTextView;
  import android.widget.CursorAdapter;
  import android.widget.FrameLayout;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
  import android.widget.TextView;
  import androidx.appcompat.R;
  import androidx.appcompat.widget.LinearLayoutCompat;
  import androidx.core.view.ViewCompat;
  import androidx.core.widget.NestedScrollView;
  import java.lang.ref.WeakReference;
  
  class AlertController {
      ListAdapter mAdapter;
      private int mAlertDialogLayout;
      private final View.OnClickListener mButtonHandler = new View.OnClickListener() {
          public void onClick(View v) {
              Message obtain = (v != AlertController.this.mButtonPositive || AlertController.this.mButtonPositiveMessage == null) ? (v != AlertController.this.mButtonNegative || AlertController.this.mButtonNegativeMessage == null) ? (v != AlertController.this.mButtonNeutral || AlertController.this.mButtonNeutralMessage == null) ? null : Message.obtain(AlertController.this.mButtonNeutralMessage) : Message.obtain(AlertController.this.mButtonNegativeMessage) : Message.obtain(AlertController.this.mButtonPositiveMessage);
              if (obtain != null) {
                  obtain.sendToTarget();
              }
              AlertController.this.mHandler.obtainMessage(1, AlertController.this.mDialog).sendToTarget();
          }
      };
      private final int mButtonIconDimen;
      Button mButtonNegative;
      private Drawable mButtonNegativeIcon;
      Message mButtonNegativeMessage;
      private CharSequence mButtonNegativeText;
      Button mButtonNeutral;
      private Drawable mButtonNeutralIcon;
      Message mButtonNeutralMessage;
      private CharSequence mButtonNeutralText;
      private int mButtonPanelLayoutHint = 0;
      private int mButtonPanelSideLayout;
      Button mButtonPositive;
      private Drawable mButtonPositiveIcon;
      Message mButtonPositiveMessage;
      private CharSequence mButtonPositiveText;
      int mCheckedItem = -1;
      private final Context mContext;
      private View mCustomTitleView;
      final AppCompatDialog mDialog;
      Handler mHandler;
      private Drawable mIcon;
      private int mIconId = 0;
      private ImageView mIconView;
      int mListItemLayout;
      int mListLayout;
      ListView mListView;
      private CharSequence mMessage;
      private TextView mMessageView;
      int mMultiChoiceItemLayout;
      NestedScrollView mScrollView;
      private boolean mShowTitle;
      int mSingleChoiceItemLayout;
      private CharSequence mTitle;
      private TextView mTitleView;
      private View mView;
      private int mViewLayoutResId;
      private int mViewSpacingBottom;
      private int mViewSpacingLeft;
      private int mViewSpacingRight;
      private boolean mViewSpacingSpecified = false;
      private int mViewSpacingTop;
      private final Window mWindow;
  
      public static class AlertParams {
          public ListAdapter mAdapter;
          public boolean mCancelable;
          public int mCheckedItem = -1;
          public boolean[] mCheckedItems;
          public final Context mContext;
          public Cursor mCursor;
          public View mCustomTitleView;
          public boolean mForceInverseBackground;
          public Drawable mIcon;
          public int mIconAttrId = 0;
          public int mIconId = 0;
          public final LayoutInflater mInflater;
          public String mIsCheckedColumn;
          public boolean mIsMultiChoice;
          public boolean mIsSingleChoice;
          public CharSequence[] mItems;
          public String mLabelColumn;
          public CharSequence mMessage;
          public Drawable mNegativeButtonIcon;
          public DialogInterface.OnClickListener mNegativeButtonListener;
          public CharSequence mNegativeButtonText;
          public Drawable mNeutralButtonIcon;
          public DialogInterface.OnClickListener mNeutralButtonListener;
          public CharSequence mNeutralButtonText;
          public DialogInterface.OnCancelListener mOnCancelListener;
          public DialogInterface.OnMultiChoiceClickListener mOnCheckboxClickListener;
          public DialogInterface.OnClickListener mOnClickListener;
          public DialogInterface.OnDismissListener mOnDismissListener;
          public AdapterView.OnItemSelectedListener mOnItemSelectedListener;
          public DialogInterface.OnKeyListener mOnKeyListener;
          public OnPrepareListViewListener mOnPrepareListViewListener;
          public Drawable mPositiveButtonIcon;
          public DialogInterface.OnClickListener mPositiveButtonListener;
          public CharSequence mPositiveButtonText;
          public boolean mRecycleOnMeasure = true;
          public CharSequence mTitle;
          public View mView;
          public int mViewLayoutResId;
          public int mViewSpacingBottom;
          public int mViewSpacingLeft;
          public int mViewSpacingRight;
          public boolean mViewSpacingSpecified = false;
          public int mViewSpacingTop;
  
          public interface OnPrepareListViewListener {
              void onPrepareListView(ListView listView);
          }
  
          public AlertParams(Context context) {
              this.mContext = context;
              this.mCancelable = true;
              this.mInflater = (LayoutInflater) context.getSystemService("layout_inflater");
          }
  
          private void createListView(final AlertController dialog) {
              ListAdapter listAdapter;
              final RecycleListView recycleListView = (RecycleListView) this.mInflater.inflate(dialog.mListLayout, (ViewGroup) null);
              if (!this.mIsMultiChoice) {
                  int i = this.mIsSingleChoice ? dialog.mSingleChoiceItemLayout : dialog.mListItemLayout;
                  listAdapter = this.mCursor != null ? new SimpleCursorAdapter(this.mContext, i, this.mCursor, new String[]{this.mLabelColumn}, new int[]{16908308}) : this.mAdapter != null ? this.mAdapter : new CheckedItemAdapter(this.mContext, i, 16908308, this.mItems);
              } else if (this.mCursor == null) {
                  final RecycleListView recycleListView2 = recycleListView;
                  listAdapter = new ArrayAdapter<CharSequence>(this.mContext, dialog.mMultiChoiceItemLayout, 16908308, this.mItems) {
                      public View getView(int position, View convertView, ViewGroup parent) {
                          View view = super.getView(position, convertView, parent);
                          if (AlertParams.this.mCheckedItems != null && AlertParams.this.mCheckedItems[position]) {
                              recycleListView2.setItemChecked(position, true);
                          }
                          return view;
                      }
                  };
              } else {
                  final RecycleListView recycleListView3 = recycleListView;
                  final AlertController alertController = dialog;
                  listAdapter = new CursorAdapter(this.mContext, this.mCursor, false) {
                      private final int mIsCheckedIndex;
                      private final int mLabelIndex;
  
                      {
                          Cursor cursor = getCursor();
                          this.mLabelIndex = cursor.getColumnIndexOrThrow(AlertParams.this.mLabelColumn);
                          this.mIsCheckedIndex = cursor.getColumnIndexOrThrow(AlertParams.this.mIsCheckedColumn);
                      }
  
                      public void bindView(View view, Context context, Cursor cursor) {
                          ((CheckedTextView) view.findViewById(16908308)).setText(cursor.getString(this.mLabelIndex));
                          RecycleListView recycleListView = recycleListView3;
                          int position = cursor.getPosition();
                          boolean z = true;
                          if (cursor.getInt(this.mIsCheckedIndex) != 1) {
                              z = false;
                          }
                          recycleListView.setItemChecked(position, z);
                      }
  
                      public View newView(Context context, Cursor cursor, ViewGroup parent) {
                          return AlertParams.this.mInflater.inflate(alertController.mMultiChoiceItemLayout, parent, false);
                      }
                  };
              }
              OnPrepareListViewListener onPrepareListViewListener = this.mOnPrepareListViewListener;
              if (onPrepareListViewListener != null) {
                  onPrepareListViewListener.onPrepareListView(recycleListView);
              }
              dialog.mAdapter = listAdapter;
              dialog.mCheckedItem = this.mCheckedItem;
              if (this.mOnClickListener != null) {
                  recycleListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {
                          AlertParams.this.mOnClickListener.onClick(dialog.mDialog, position);
                          if (!AlertParams.this.mIsSingleChoice) {
                              dialog.mDialog.dismiss();
                          }
                      }
                  });
              } else if (this.mOnCheckboxClickListener != null) {
                  recycleListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {
                          if (AlertParams.this.mCheckedItems != null) {
                              AlertParams.this.mCheckedItems[position] = recycleListView.isItemChecked(position);
                          }
                          AlertParams.this.mOnCheckboxClickListener.onClick(dialog.mDialog, position, recycleListView.isItemChecked(position));
                      }
                  });
              }
              AdapterView.OnItemSelectedListener onItemSelectedListener = this.mOnItemSelectedListener;
              if (onItemSelectedListener != null) {
                  recycleListView.setOnItemSelectedListener(onItemSelectedListener);
              }
              if (this.mIsSingleChoice) {
                  recycleListView.setChoiceMode(1);
              } else if (this.mIsMultiChoice) {
                  recycleListView.setChoiceMode(2);
              }
              dialog.mListView = recycleListView;
          }
  
          public void apply(AlertController dialog) {
              View view = this.mCustomTitleView;
              if (view != null) {
                  dialog.setCustomTitle(view);
              } else {
                  CharSequence charSequence = this.mTitle;
                  if (charSequence != null) {
                      dialog.setTitle(charSequence);
                  }
                  Drawable drawable = this.mIcon;
                  if (drawable != null) {
                      dialog.setIcon(drawable);
                  }
                  int i = this.mIconId;
                  if (i != 0) {
                      dialog.setIcon(i);
                  }
                  int i2 = this.mIconAttrId;
                  if (i2 != 0) {
                      dialog.setIcon(dialog.getIconAttributeResId(i2));
                  }
              }
              CharSequence charSequence2 = this.mMessage;
              if (charSequence2 != null) {
                  dialog.setMessage(charSequence2);
              }
              CharSequence charSequence3 = this.mPositiveButtonText;
              if (!(charSequence3 == null && this.mPositiveButtonIcon == null)) {
                  dialog.setButton(-1, charSequence3, this.mPositiveButtonListener, (Message) null, this.mPositiveButtonIcon);
              }
              CharSequence charSequence4 = this.mNegativeButtonText;
              if (!(charSequence4 == null && this.mNegativeButtonIcon == null)) {
                  dialog.setButton(-2, charSequence4, this.mNegativeButtonListener, (Message) null, this.mNegativeButtonIcon);
              }
              CharSequence charSequence5 = this.mNeutralButtonText;
              if (!(charSequence5 == null && this.mNeutralButtonIcon == null)) {
                  dialog.setButton(-3, charSequence5, this.mNeutralButtonListener, (Message) null, this.mNeutralButtonIcon);
              }
              if (!(this.mItems == null && this.mCursor == null && this.mAdapter == null)) {
                  createListView(dialog);
              }
              View view2 = this.mView;
              if (view2 == null) {
                  int i3 = this.mViewLayoutResId;
                  if (i3 != 0) {
                      dialog.setView(i3);
                  }
              } else if (this.mViewSpacingSpecified) {
                  dialog.setView(view2, this.mViewSpacingLeft, this.mViewSpacingTop, this.mViewSpacingRight, this.mViewSpacingBottom);
              } else {
                  dialog.setView(view2);
              }
          }
      }
  
      private static final class ButtonHandler extends Handler {
          private static final int MSG_DISMISS_DIALOG = 1;
          private WeakReference<DialogInterface> mDialog;
  
          public ButtonHandler(DialogInterface dialog) {
              this.mDialog = new WeakReference<>(dialog);
          }
  
          public void handleMessage(Message msg) {
              switch (msg.what) {
                  case -3:
                  case -2:
                  case -1:
                      ((DialogInterface.OnClickListener) msg.obj).onClick((DialogInterface) this.mDialog.get(), msg.what);
                      return;
                  case 1:
                      ((DialogInterface) msg.obj).dismiss();
                      return;
                  default:
                      return;
              }
          }
      }
  
      private static class CheckedItemAdapter extends ArrayAdapter<CharSequence> {
          public CheckedItemAdapter(Context context, int resource, int textViewResourceId, CharSequence[] objects) {
              super(context, resource, textViewResourceId, objects);
          }
  
          public long getItemId(int position) {
              return (long) position;
          }
  
          public boolean hasStableIds() {
              return true;
          }
      }
  
      public static class RecycleListView extends ListView {
          private final int mPaddingBottomNoButtons;
          private final int mPaddingTopNoTitle;
  
          public RecycleListView(Context context) {
              this(context, (AttributeSet) null);
          }
  
          public RecycleListView(Context context, AttributeSet attrs) {
              super(context, attrs);
              TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attrs, R.styleable.RecycleListView);
              this.mPaddingBottomNoButtons = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.RecycleListView_paddingBottomNoButtons, -1);
              this.mPaddingTopNoTitle = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.RecycleListView_paddingTopNoTitle, -1);
          }
  
          public void setHasDecor(boolean hasTitle, boolean hasButtons) {
              if (!hasButtons || !hasTitle) {
                  setPadding(getPaddingLeft(), hasTitle ? getPaddingTop() : this.mPaddingTopNoTitle, getPaddingRight(), hasButtons ? getPaddingBottom() : this.mPaddingBottomNoButtons);
              }
          }
      }
  
      public AlertController(Context context, AppCompatDialog di, Window window) {
          this.mContext = context;
          this.mDialog = di;
          this.mWindow = window;
          this.mHandler = new ButtonHandler(di);
          TypedArray obtainStyledAttributes = context.obtainStyledAttributes((AttributeSet) null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0);
          this.mAlertDialogLayout = obtainStyledAttributes.getResourceId(R.styleable.AlertDialog_android_layout, 0);
          this.mButtonPanelSideLayout = obtainStyledAttributes.getResourceId(R.styleable.AlertDialog_buttonPanelSideLayout, 0);
          this.mListLayout = obtainStyledAttributes.getResourceId(R.styleable.AlertDialog_listLayout, 0);
          this.mMultiChoiceItemLayout = obtainStyledAttributes.getResourceId(R.styleable.AlertDialog_multiChoiceItemLayout, 0);
          this.mSingleChoiceItemLayout = obtainStyledAttributes.getResourceId(R.styleable.AlertDialog_singleChoiceItemLayout, 0);
          this.mListItemLayout = obtainStyledAttributes.getResourceId(R.styleable.AlertDialog_listItemLayout, 0);
          this.mShowTitle = obtainStyledAttributes.getBoolean(R.styleable.AlertDialog_showTitle, true);
          this.mButtonIconDimen = obtainStyledAttributes.getDimensionPixelSize(R.styleable.AlertDialog_buttonIconDimen, 0);
          obtainStyledAttributes.recycle();
          di.supportRequestWindowFeature(1);
      }
  
      static boolean canTextInput(View v) {
          if (v.onCheckIsTextEditor()) {
              return true;
          }
          if (!(v instanceof ViewGroup)) {
              return false;
          }
          ViewGroup viewGroup = (ViewGroup) v;
          int childCount = viewGroup.getChildCount();
          while (childCount > 0) {
              childCount--;
              if (canTextInput(viewGroup.getChildAt(childCount))) {
                  return true;
              }
          }
          return false;
      }
  
      private void centerButton(Button button) {
          LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button.getLayoutParams();
          layoutParams.gravity = 1;
          layoutParams.weight = 0.5f;
          button.setLayoutParams(layoutParams);
      }
  
      static void manageScrollIndicators(View v, View upIndicator, View downIndicator) {
          int i = 0;
          if (upIndicator != null) {
              upIndicator.setVisibility(v.canScrollVertically(-1) ? 0 : 4);
          }
          if (downIndicator != null) {
              if (!v.canScrollVertically(1)) {
                  i = 4;
              }
              downIndicator.setVisibility(i);
          }
      }
  
      private ViewGroup resolvePanel(View customPanel, View defaultPanel) {
          if (customPanel == null) {
              if (defaultPanel instanceof ViewStub) {
                  defaultPanel = ((ViewStub) defaultPanel).inflate();
              }
              return (ViewGroup) defaultPanel;
          }
          if (defaultPanel != null) {
              ViewParent parent = defaultPanel.getParent();
              if (parent instanceof ViewGroup) {
                  ((ViewGroup) parent).removeView(defaultPanel);
              }
          }
          if (customPanel instanceof ViewStub) {
              customPanel = ((ViewStub) customPanel).inflate();
          }
          return (ViewGroup) customPanel;
      }
  
      private int selectContentView() {
          int i = this.mButtonPanelSideLayout;
          return i == 0 ? this.mAlertDialogLayout : this.mButtonPanelLayoutHint == 1 ? i : this.mAlertDialogLayout;
      }
  
      private void setScrollIndicators(ViewGroup contentPanel, View content, int indicators, int mask) {
          View findViewById = this.mWindow.findViewById(R.id.scrollIndicatorUp);
          View findViewById2 = this.mWindow.findViewById(R.id.scrollIndicatorDown);
          if (Build.VERSION.SDK_INT >= 23) {
              ViewCompat.setScrollIndicators(content, indicators, mask);
              if (findViewById != null) {
                  contentPanel.removeView(findViewById);
              }
              if (findViewById2 != null) {
                  contentPanel.removeView(findViewById2);
                  return;
              }
              return;
          }
          if (findViewById != null && (indicators & 1) == 0) {
              contentPanel.removeView(findViewById);
              findViewById = null;
          }
          if (findViewById2 != null && (indicators & 2) == 0) {
              contentPanel.removeView(findViewById2);
              findViewById2 = null;
          }
          if (findViewById != null || findViewById2 != null) {
              final View view = findViewById;
              final View view2 = findViewById2;
              if (this.mMessage != null) {
                  this.mScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
                      public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                          AlertController.manageScrollIndicators(v, view, view2);
                      }
                  });
                  this.mScrollView.post(new Runnable() {
                      public void run() {
                          AlertController.manageScrollIndicators(AlertController.this.mScrollView, view, view2);
                      }
                  });
                  return;
              }
              ListView listView = this.mListView;
              if (listView != null) {
                  listView.setOnScrollListener(new AbsListView.OnScrollListener() {
                      public void onScroll(AbsListView v, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                          AlertController.manageScrollIndicators(v, view, view2);
                      }
  
                      public void onScrollStateChanged(AbsListView view, int scrollState) {
                      }
                  });
                  this.mListView.post(new Runnable() {
                      public void run() {
                          AlertController.manageScrollIndicators(AlertController.this.mListView, view, view2);
                      }
                  });
                  return;
              }
              if (view != null) {
                  contentPanel.removeView(view);
              }
              if (view2 != null) {
                  contentPanel.removeView(view2);
              }
          }
      }
  
      private void setupButtons(ViewGroup buttonPanel) {
          boolean z = false;
          Button button = (Button) buttonPanel.findViewById(16908313);
          this.mButtonPositive = button;
          button.setOnClickListener(this.mButtonHandler);
          boolean z2 = false;
          if (!TextUtils.isEmpty(this.mButtonPositiveText) || this.mButtonPositiveIcon != null) {
              this.mButtonPositive.setText(this.mButtonPositiveText);
              Drawable drawable = this.mButtonPositiveIcon;
              if (drawable != null) {
                  int i = this.mButtonIconDimen;
                  drawable.setBounds(0, 0, i, i);
                  this.mButtonPositive.setCompoundDrawables(this.mButtonPositiveIcon, (Drawable) null, (Drawable) null, (Drawable) null);
              }
              this.mButtonPositive.setVisibility(0);
              z = false | true;
          } else {
              this.mButtonPositive.setVisibility(8);
          }
          Button button2 = (Button) buttonPanel.findViewById(16908314);
          this.mButtonNegative = button2;
          button2.setOnClickListener(this.mButtonHandler);
          if (!TextUtils.isEmpty(this.mButtonNegativeText) || this.mButtonNegativeIcon != null) {
              this.mButtonNegative.setText(this.mButtonNegativeText);
              Drawable drawable2 = this.mButtonNegativeIcon;
              if (drawable2 != null) {
                  int i2 = this.mButtonIconDimen;
                  drawable2.setBounds(0, 0, i2, i2);
                  this.mButtonNegative.setCompoundDrawables(this.mButtonNegativeIcon, (Drawable) null, (Drawable) null, (Drawable) null);
              }
              this.mButtonNegative.setVisibility(0);
              z |= true;
          } else {
              this.mButtonNegative.setVisibility(8);
          }
          Button button3 = (Button) buttonPanel.findViewById(16908315);
          this.mButtonNeutral = button3;
          button3.setOnClickListener(this.mButtonHandler);
          if (!TextUtils.isEmpty(this.mButtonNeutralText) || this.mButtonNeutralIcon != null) {
              this.mButtonNeutral.setText(this.mButtonNeutralText);
              Drawable drawable3 = this.mButtonNeutralIcon;
              if (drawable3 != null) {
                  int i3 = this.mButtonIconDimen;
                  drawable3.setBounds(0, 0, i3, i3);
                  this.mButtonNeutral.setCompoundDrawables(this.mButtonNeutralIcon, (Drawable) null, (Drawable) null, (Drawable) null);
              }
              this.mButtonNeutral.setVisibility(0);
              z |= true;
          } else {
              this.mButtonNeutral.setVisibility(8);
          }
          if (shouldCenterSingleButton(this.mContext)) {
              if (z) {
                  centerButton(this.mButtonPositive);
              } else if (z) {
                  centerButton(this.mButtonNegative);
              } else if (z) {
                  centerButton(this.mButtonNeutral);
              }
          }
          if (z) {
              z2 = true;
          }
          if (!z2) {
              buttonPanel.setVisibility(8);
          }
      }
  
      private void setupContent(ViewGroup contentPanel) {
          NestedScrollView nestedScrollView = (NestedScrollView) this.mWindow.findViewById(R.id.scrollView);
          this.mScrollView = nestedScrollView;
          nestedScrollView.setFocusable(false);
          this.mScrollView.setNestedScrollingEnabled(false);
          TextView textView = (TextView) contentPanel.findViewById(16908299);
          this.mMessageView = textView;
          if (textView != null) {
              CharSequence charSequence = this.mMessage;
              if (charSequence != null) {
                  textView.setText(charSequence);
                  return;
              }
              textView.setVisibility(8);
              this.mScrollView.removeView(this.mMessageView);
              if (this.mListView != null) {
                  ViewGroup viewGroup = (ViewGroup) this.mScrollView.getParent();
                  int indexOfChild = viewGroup.indexOfChild(this.mScrollView);
                  viewGroup.removeViewAt(indexOfChild);
                  viewGroup.addView(this.mListView, indexOfChild, new ViewGroup.LayoutParams(-1, -1));
                  return;
              }
              contentPanel.setVisibility(8);
          }
      }
  
      private void setupCustomContent(ViewGroup customPanel) {
          boolean z = false;
          View inflate = this.mView != null ? this.mView : this.mViewLayoutResId != 0 ? LayoutInflater.from(this.mContext).inflate(this.mViewLayoutResId, customPanel, false) : null;
          if (inflate != null) {
              z = true;
          }
          if (!z || !canTextInput(inflate)) {
              this.mWindow.setFlags(131072, 131072);
          }
          if (z) {
              FrameLayout frameLayout = (FrameLayout) this.mWindow.findViewById(R.id.custom);
              frameLayout.addView(inflate, new ViewGroup.LayoutParams(-1, -1));
              if (this.mViewSpacingSpecified) {
                  frameLayout.setPadding(this.mViewSpacingLeft, this.mViewSpacingTop, this.mViewSpacingRight, this.mViewSpacingBottom);
              }
              if (this.mListView != null) {
                  ((LinearLayoutCompat.LayoutParams) customPanel.getLayoutParams()).weight = 0.0f;
                  return;
              }
              return;
          }
          customPanel.setVisibility(8);
      }
  
      private void setupTitle(ViewGroup topPanel) {
          if (this.mCustomTitleView != null) {
              topPanel.addView(this.mCustomTitleView, 0, new ViewGroup.LayoutParams(-1, -2));
              this.mWindow.findViewById(R.id.title_template).setVisibility(8);
              return;
          }
          this.mIconView = (ImageView) this.mWindow.findViewById(16908294);
          if (!(!TextUtils.isEmpty(this.mTitle)) || !this.mShowTitle) {
              this.mWindow.findViewById(R.id.title_template).setVisibility(8);
              this.mIconView.setVisibility(8);
              topPanel.setVisibility(8);
              return;
          }
          TextView textView = (TextView) this.mWindow.findViewById(R.id.alertTitle);
          this.mTitleView = textView;
          textView.setText(this.mTitle);
          int i = this.mIconId;
          if (i != 0) {
              this.mIconView.setImageResource(i);
              return;
          }
          Drawable drawable = this.mIcon;
          if (drawable != null) {
              this.mIconView.setImageDrawable(drawable);
              return;
          }
          this.mTitleView.setPadding(this.mIconView.getPaddingLeft(), this.mIconView.getPaddingTop(), this.mIconView.getPaddingRight(), this.mIconView.getPaddingBottom());
          this.mIconView.setVisibility(8);
      }
  
      private void setupView() {
          ListAdapter listAdapter;
          View findViewById = this.mWindow.findViewById(R.id.parentPanel);
          View findViewById2 = findViewById.findViewById(R.id.topPanel);
          View findViewById3 = findViewById.findViewById(R.id.contentPanel);
          View findViewById4 = findViewById.findViewById(R.id.buttonPanel);
          ViewGroup viewGroup = (ViewGroup) findViewById.findViewById(R.id.customPanel);
          setupCustomContent(viewGroup);
          View findViewById5 = viewGroup.findViewById(R.id.topPanel);
          View findViewById6 = viewGroup.findViewById(R.id.contentPanel);
          View findViewById7 = viewGroup.findViewById(R.id.buttonPanel);
          ViewGroup resolvePanel = resolvePanel(findViewById5, findViewById2);
          ViewGroup resolvePanel2 = resolvePanel(findViewById6, findViewById3);
          ViewGroup resolvePanel3 = resolvePanel(findViewById7, findViewById4);
          setupContent(resolvePanel2);
          setupButtons(resolvePanel3);
          setupTitle(resolvePanel);
          boolean z = (viewGroup == null || viewGroup.getVisibility() == 8) ? false : true;
          boolean z2 = (resolvePanel == null || resolvePanel.getVisibility() == 8) ? false : true;
          boolean z3 = (resolvePanel3 == null || resolvePanel3.getVisibility() == 8) ? false : true;
          if (z3) {
              View view = findViewById;
          } else if (resolvePanel2 != null) {
              View findViewById8 = resolvePanel2.findViewById(R.id.textSpacerNoButtons);
              if (findViewById8 != null) {
                  View view2 = findViewById;
                  findViewById8.setVisibility(0);
              } else {
                  View view3 = findViewById;
              }
          } else {
              View view4 = findViewById;
          }
          if (z2) {
              NestedScrollView nestedScrollView = this.mScrollView;
              if (nestedScrollView != null) {
                  nestedScrollView.setClipToPadding(true);
              }
              View view5 = null;
              if (!(this.mMessage == null && this.mListView == null)) {
                  view5 = resolvePanel.findViewById(R.id.titleDividerNoCustom);
              }
              if (view5 != null) {
                  view5.setVisibility(0);
              }
          } else if (resolvePanel2 != null) {
              View findViewById9 = resolvePanel2.findViewById(R.id.textSpacerNoTitle);
              if (findViewById9 != null) {
                  findViewById9.setVisibility(0);
              }
          }
          ListView listView = this.mListView;
          if (listView instanceof RecycleListView) {
              ((RecycleListView) listView).setHasDecor(z2, z3);
          }
          if (!z) {
              View view6 = this.mListView;
              if (view6 == null) {
                  view6 = this.mScrollView;
              }
              if (view6 != null) {
                  View view7 = findViewById2;
                  setScrollIndicators(resolvePanel2, view6, (z2 ? 1 : 0) | (z3 ? 2 : 0), 3);
              } else {
                  View view8 = findViewById2;
              }
          } else {
              View view9 = findViewById2;
          }
          ListView listView2 = this.mListView;
          if (listView2 != null && (listAdapter = this.mAdapter) != null) {
              listView2.setAdapter(listAdapter);
              int i = this.mCheckedItem;
              if (i > -1) {
                  listView2.setItemChecked(i, true);
                  listView2.setSelection(i);
              }
          }
      }
  
      private static boolean shouldCenterSingleButton(Context context) {
          TypedValue typedValue = new TypedValue();
          context.getTheme().resolveAttribute(R.attr.alertDialogCenterButtons, typedValue, true);
          return typedValue.data != 0;
      }
  
      public Button getButton(int whichButton) {
          switch (whichButton) {
              case -3:
                  return this.mButtonNeutral;
              case -2:
                  return this.mButtonNegative;
              case -1:
                  return this.mButtonPositive;
              default:
                  return null;
          }
      }
  
      public int getIconAttributeResId(int attrId) {
          TypedValue typedValue = new TypedValue();
          this.mContext.getTheme().resolveAttribute(attrId, typedValue, true);
          return typedValue.resourceId;
      }
  
      public ListView getListView() {
          return this.mListView;
      }
  
      public void installContent() {
          this.mDialog.setContentView(selectContentView());
          setupView();
      }
  
      public boolean onKeyDown(int keyCode, KeyEvent event) {
          NestedScrollView nestedScrollView = this.mScrollView;
          return nestedScrollView != null && nestedScrollView.executeKeyEvent(event);
      }
  
      public boolean onKeyUp(int keyCode, KeyEvent event) {
          NestedScrollView nestedScrollView = this.mScrollView;
          return nestedScrollView != null && nestedScrollView.executeKeyEvent(event);
      }
  
      public void setButton(int whichButton, CharSequence text, DialogInterface.OnClickListener listener, Message msg, Drawable icon) {
          if (msg == null && listener != null) {
              msg = this.mHandler.obtainMessage(whichButton, listener);
          }
          switch (whichButton) {
              case -3:
                  this.mButtonNeutralText = text;
                  this.mButtonNeutralMessage = msg;
                  this.mButtonNeutralIcon = icon;
                  return;
              case -2:
                  this.mButtonNegativeText = text;
                  this.mButtonNegativeMessage = msg;
                  this.mButtonNegativeIcon = icon;
                  return;
              case -1:
                  this.mButtonPositiveText = text;
                  this.mButtonPositiveMessage = msg;
                  this.mButtonPositiveIcon = icon;
                  return;
              default:
                  throw new IllegalArgumentException("Button does not exist");
          }
      }
  
      public void setButtonPanelLayoutHint(int layoutHint) {
          this.mButtonPanelLayoutHint = layoutHint;
      }
  
      public void setCustomTitle(View customTitleView) {
          this.mCustomTitleView = customTitleView;
      }
  
      public void setIcon(int resId) {
          this.mIcon = null;
          this.mIconId = resId;
          ImageView imageView = this.mIconView;
          if (imageView == null) {
              return;
          }
          if (resId != 0) {
              imageView.setVisibility(0);
              this.mIconView.setImageResource(this.mIconId);
              return;
          }
          imageView.setVisibility(8);
      }
  
      public void setIcon(Drawable icon) {
          this.mIcon = icon;
          this.mIconId = 0;
          ImageView imageView = this.mIconView;
          if (imageView == null) {
              return;
          }
          if (icon != null) {
              imageView.setVisibility(0);
              this.mIconView.setImageDrawable(icon);
              return;
          }
          imageView.setVisibility(8);
      }
  
      public void setMessage(CharSequence message) {
          this.mMessage = message;
          TextView textView = this.mMessageView;
          if (textView != null) {
              textView.setText(message);
          }
      }
  
      public void setTitle(CharSequence title) {
          this.mTitle = title;
          TextView textView = this.mTitleView;
          if (textView != null) {
              textView.setText(title);
          }
      }
  
      public void setView(int layoutResId) {
          this.mView = null;
          this.mViewLayoutResId = layoutResId;
          this.mViewSpacingSpecified = false;
      }
  
      public void setView(View view) {
          this.mView = view;
          this.mViewLayoutResId = 0;
          this.mViewSpacingSpecified = false;
      }
  
      public void setView(View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom) {
          this.mView = view;
          this.mViewLayoutResId = 0;
          this.mViewSpacingSpecified = true;
          this.mViewSpacingLeft = viewSpacingLeft;
          this.mViewSpacingTop = viewSpacingTop;
          this.mViewSpacingRight = viewSpacingRight;
          this.mViewSpacingBottom = viewSpacingBottom;
      }
  }
  