package androidx.appcompat.app;

import X.AnonymousClass029;
import X.AnonymousClass18Q;
import X.C43931od;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewStub;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;

public final class AlertController {
    public final Context LIZ;
    public final AnonymousClass18Q LIZIZ;
    public final Window LIZJ;
    public final int LIZLLL;
    public CharSequence LJ;
    public CharSequence LJFF;
    public ListView LJI;
    public View LJII;
    public int LJIIIIZZ;
    public int LJIIIZ;
    public int LJIIJ;
    public int LJIIJJI;
    public int LJIIL;
    public boolean LJIILIIL;
    public Button LJIILJJIL;
    public CharSequence LJIILL;
    public Message LJIILLIIL;
    public Drawable LJIIZILJ;
    public Button LJIJ;
    public CharSequence LJIJI;
    public Message LJIJJ;
    public Drawable LJIJJLI;
    public Button LJIL;
    public CharSequence LJJ;
    public Message LJJI;
    public Drawable LJJIFFI;
    public C43931od LJJII;
    public int LJJIII;
    public Drawable LJJIIJ;
    public ImageView LJJIIJZLJL;
    public TextView LJJIIZ;
    public TextView LJJIIZI;
    public View LJJIJ;
    public ListAdapter LJJIJIIJI;
    public int LJJIJIIJIL = -1;
    public int LJJIJIL;
    public int LJJIJL;
    public int LJJIJLIJ;
    public int LJJIL;
    public int LJJIZ;
    public int LJJJ;
    public boolean LJJJI;
    public int LJJJIL;
    public Handler LJJJJ;
    public final View.OnClickListener LJJJJI = new View.OnClickListener() {
        static {
            Covode.recordClassIndex(252);
        }

        public final void onClick(View view) {
            Message obtain;
            if (view == AlertController.this.LJIILJJIL && AlertController.this.LJIILLIIL != null) {
                obtain = Message.obtain(AlertController.this.LJIILLIIL);
            } else if (view != AlertController.this.LJIJ || AlertController.this.LJIJJ == null) {
                if (view == AlertController.this.LJIL && AlertController.this.LJJI != null) {
                    obtain = Message.obtain(AlertController.this.LJJI);
                }
                AlertController.this.LJJJJ.obtainMessage(1, AlertController.this.LIZIZ).sendToTarget();
            } else {
                obtain = Message.obtain(AlertController.this.LJIJJ);
            }
            if (obtain != null) {
                obtain.sendToTarget();
            }
            AlertController.this.LJJJJ.obtainMessage(1, AlertController.this.LIZIZ).sendToTarget();
        }
    };

    static {
        Covode.recordClassIndex(251);
    }

    public final void LIZ(CharSequence charSequence) {
        this.LJ = charSequence;
        TextView textView = this.LJJIIZ;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    public static boolean LIZ(View view) {
        if (view.onCheckIsTextEditor()) {
            return true;
        }
        if (!(view instanceof ViewGroup)) {
            return false;
        }
        ViewGroup viewGroup = (ViewGroup) view;
        int childCount = viewGroup.getChildCount();
        while (childCount > 0) {
            childCount--;
            if (LIZ(viewGroup.getChildAt(childCount))) {
                return true;
            }
        }
        return false;
    }

    public final void LIZ(int i) {
        this.LJJIIJ = null;
        this.LJJIII = i;
        ImageView imageView = this.LJJIIJZLJL;
        if (imageView == null) {
            return;
        }
        if (i != 0) {
            imageView.setVisibility(0);
            this.LJJIIJZLJL.setImageResource(this.LJJIII);
            return;
        }
        imageView.setVisibility(8);
    }

    public final void LIZ(Button button) {
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button.getLayoutParams();
        layoutParams.gravity = 1;
        layoutParams.weight = 0.5f;
        button.setLayoutParams(layoutParams);
    }

    public final ViewGroup LIZ(View view, View view2) {
        if (view == null) {
            if (view2 instanceof ViewStub) {
                view2 = ((ViewStub) view2).inflate();
            }
            return (ViewGroup) view2;
        }
        if (view2 != null) {
            ViewParent parent = view2.getParent();
            if (parent instanceof ViewGroup) {
                ((ViewGroup) parent).removeView(view2);
            }
        }
        if (view instanceof ViewStub) {
            view = ((ViewStub) view).inflate();
        }
        return (ViewGroup) view;
    }

    public static void LIZ(View view, View view2, View view3) {
        int i;
        int i2 = 0;
        if (view2 != null) {
            if (view.canScrollVertically(-1)) {
                i = 0;
            } else {
                i = 4;
            }
            view2.setVisibility(i);
        }
        if (view3 != null) {
            if (!view.canScrollVertically(1)) {
                i2 = 4;
            }
            view3.setVisibility(i2);
        }
    }

    public AlertController(Context context, AnonymousClass18Q r6, Window window) {
        this.LIZ = context;
        this.LIZIZ = r6;
        this.LIZJ = window;
        this.LJJJJ = new AnonymousClass029(r6);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes((AttributeSet) null, new int[]{16842994, 2130969147, 2130969149, 2130969856, 2130969857, 2130970613, 2130970920, 2130970939}, 2130968992, 0);
        this.LJJIJIL = obtainStyledAttributes.getResourceId(0, 0);
        this.LJJIJL = obtainStyledAttributes.getResourceId(2, 0);
        this.LJJIJLIJ = obtainStyledAttributes.getResourceId(4, 0);
        this.LJJIL = obtainStyledAttributes.getResourceId(5, 0);
        this.LJJIZ = obtainStyledAttributes.getResourceId(7, 0);
        this.LJJJ = obtainStyledAttributes.getResourceId(3, 0);
        this.LJJJI = obtainStyledAttributes.getBoolean(6, true);
        this.LIZLLL = obtainStyledAttributes.getDimensionPixelSize(1, 0);
        obtainStyledAttributes.recycle();
        r6.dA_();
    }

    public final void LIZ(int i, CharSequence charSequence, DialogInterface.OnClickListener onClickListener, Message message, Drawable drawable) {
        if (onClickListener != null) {
            message = this.LJJJJ.obtainMessage(i, onClickListener);
        }
        if (i == -3) {
            this.LJJ = charSequence;
            this.LJJI = message;
            this.LJJIFFI = drawable;
        } else if (i == -2) {
            this.LJIJI = charSequence;
            this.LJIJJ = message;
            this.LJIJJLI = drawable;
        } else if (i == -1) {
            this.LJIILL = charSequence;
            this.LJIILLIIL = message;
            this.LJIIZILJ = drawable;
        } else {
            throw new IllegalArgumentException("Button does not exist");
        }
    }
}
