package androidx.appcompat.app;

import android.R;
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.widget.m0;
import androidx.core.view.y;
import androidx.core.widget.NestedScrollView;
import java.lang.ref.WeakReference;

/* JADX INFO: loaded from: classes.dex */
class AlertController {
    NestedScrollView A;
    private Drawable C;
    private ImageView D;
    private TextView E;
    private TextView F;
    private View G;
    ListAdapter H;
    private int J;
    private int K;
    int L;
    int M;
    int N;
    int O;
    private boolean P;
    Handler R;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final Context f85a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    final androidx.appcompat.app.h f86b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final Window f87c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private final int f88d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private CharSequence f89e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private CharSequence f90f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    ListView f91g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private View f92h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private int f93i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private int f94j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f95k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private int f96l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private int f97m;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    Button f99o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private CharSequence f100p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    Message f101q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private Drawable f102r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    Button f103s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    private CharSequence f104t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    Message f105u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    private Drawable f106v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    Button f107w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private CharSequence f108x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    Message f109y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    private Drawable f110z;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private boolean f98n = false;
    private int B = 0;
    int I = -1;
    private int Q = 0;
    private final View.OnClickListener S = new a();

    public static class RecycleListView extends ListView {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private final int f111e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private final int f112f;

        public RecycleListView(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, c.j.W1);
            this.f112f = typedArrayObtainStyledAttributes.getDimensionPixelOffset(c.j.X1, -1);
            this.f111e = typedArrayObtainStyledAttributes.getDimensionPixelOffset(c.j.Y1, -1);
        }

        public void a(boolean z2, boolean z3) {
            if (z3 && z2) {
                return;
            }
            setPadding(getPaddingLeft(), z2 ? getPaddingTop() : this.f111e, getPaddingRight(), z3 ? getPaddingBottom() : this.f112f);
        }
    }

    class a implements View.OnClickListener {
        a() {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            Message message;
            Message message2;
            Message message3;
            AlertController alertController = AlertController.this;
            Message messageObtain = (view != alertController.f99o || (message3 = alertController.f101q) == null) ? (view != alertController.f103s || (message2 = alertController.f105u) == null) ? (view != alertController.f107w || (message = alertController.f109y) == null) ? null : Message.obtain(message) : Message.obtain(message2) : Message.obtain(message3);
            if (messageObtain != null) {
                messageObtain.sendToTarget();
            }
            AlertController alertController2 = AlertController.this;
            alertController2.R.obtainMessage(1, alertController2.f86b).sendToTarget();
        }
    }

    class b implements NestedScrollView.c {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ View f114a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ View f115b;

        b(AlertController alertController, View view, View view2) {
            this.f114a = view;
            this.f115b = view2;
        }

        @Override // androidx.core.widget.NestedScrollView.c
        public void a(NestedScrollView nestedScrollView, int i3, int i4, int i5, int i6) {
            AlertController.f(nestedScrollView, this.f114a, this.f115b);
        }
    }

    class c implements Runnable {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final /* synthetic */ View f116e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ View f117f;

        c(View view, View view2) {
            this.f116e = view;
            this.f117f = view2;
        }

        @Override // java.lang.Runnable
        public void run() {
            AlertController.f(AlertController.this.A, this.f116e, this.f117f);
        }
    }

    class d implements AbsListView.OnScrollListener {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ View f119a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ View f120b;

        d(AlertController alertController, View view, View view2) {
            this.f119a = view;
            this.f120b = view2;
        }

        @Override // android.widget.AbsListView.OnScrollListener
        public void onScroll(AbsListView absListView, int i3, int i4, int i5) {
            AlertController.f(absListView, this.f119a, this.f120b);
        }

        @Override // android.widget.AbsListView.OnScrollListener
        public void onScrollStateChanged(AbsListView absListView, int i3) {
        }
    }

    class e implements Runnable {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final /* synthetic */ View f121e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ View f122f;

        e(View view, View view2) {
            this.f121e = view;
            this.f122f = view2;
        }

        @Override // java.lang.Runnable
        public void run() {
            AlertController.f(AlertController.this.f91g, this.f121e, this.f122f);
        }
    }

    public static class f {
        public int A;
        public int B;
        public int C;
        public int D;
        public boolean[] F;
        public boolean G;
        public boolean H;
        public DialogInterface.OnMultiChoiceClickListener J;
        public Cursor K;
        public String L;
        public String M;
        public AdapterView.OnItemSelectedListener N;
        public e O;

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

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final LayoutInflater f125b;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public Drawable f127d;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public CharSequence f129f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public View f130g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public CharSequence f131h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public CharSequence f132i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public Drawable f133j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        public DialogInterface.OnClickListener f134k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        public CharSequence f135l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public Drawable f136m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        public DialogInterface.OnClickListener f137n;

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

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

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public DialogInterface.OnClickListener f140q;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        public DialogInterface.OnCancelListener f142s;

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        public DialogInterface.OnDismissListener f143t;

        /* JADX INFO: renamed from: u, reason: collision with root package name */
        public DialogInterface.OnKeyListener f144u;

        /* JADX INFO: renamed from: v, reason: collision with root package name */
        public CharSequence[] f145v;

        /* JADX INFO: renamed from: w, reason: collision with root package name */
        public ListAdapter f146w;

        /* JADX INFO: renamed from: x, reason: collision with root package name */
        public DialogInterface.OnClickListener f147x;

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

        /* JADX INFO: renamed from: z, reason: collision with root package name */
        public View f149z;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f126c = 0;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public int f128e = 0;
        public boolean E = false;
        public int I = -1;

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

        class a extends ArrayAdapter<CharSequence> {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            final /* synthetic */ RecycleListView f150e;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            a(Context context, int i3, int i4, CharSequence[] charSequenceArr, RecycleListView recycleListView) {
                super(context, i3, i4, charSequenceArr);
                this.f150e = recycleListView;
            }

            @Override // android.widget.ArrayAdapter, android.widget.Adapter
            public View getView(int i3, View view, ViewGroup viewGroup) {
                View view2 = super.getView(i3, view, viewGroup);
                boolean[] zArr = f.this.F;
                if (zArr != null && zArr[i3]) {
                    this.f150e.setItemChecked(i3, true);
                }
                return view2;
            }
        }

        class b extends CursorAdapter {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            private final int f152e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            private final int f153f;

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            final /* synthetic */ RecycleListView f154g;

            /* JADX INFO: renamed from: h, reason: collision with root package name */
            final /* synthetic */ AlertController f155h;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            b(Context context, Cursor cursor, boolean z2, RecycleListView recycleListView, AlertController alertController) {
                super(context, cursor, z2);
                this.f154g = recycleListView;
                this.f155h = alertController;
                Cursor cursor2 = getCursor();
                this.f152e = cursor2.getColumnIndexOrThrow(f.this.L);
                this.f153f = cursor2.getColumnIndexOrThrow(f.this.M);
            }

            @Override // android.widget.CursorAdapter
            public void bindView(View view, Context context, Cursor cursor) {
                ((CheckedTextView) view.findViewById(R.id.text1)).setText(cursor.getString(this.f152e));
                this.f154g.setItemChecked(cursor.getPosition(), cursor.getInt(this.f153f) == 1);
            }

            @Override // android.widget.CursorAdapter
            public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
                return f.this.f125b.inflate(this.f155h.M, viewGroup, false);
            }
        }

        class c implements AdapterView.OnItemClickListener {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            final /* synthetic */ AlertController f157e;

            c(AlertController alertController) {
                this.f157e = alertController;
            }

            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i3, long j3) {
                f.this.f147x.onClick(this.f157e.f86b, i3);
                if (f.this.H) {
                    return;
                }
                this.f157e.f86b.dismiss();
            }
        }

        class d implements AdapterView.OnItemClickListener {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            final /* synthetic */ RecycleListView f159e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            final /* synthetic */ AlertController f160f;

            d(RecycleListView recycleListView, AlertController alertController) {
                this.f159e = recycleListView;
                this.f160f = alertController;
            }

            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i3, long j3) {
                boolean[] zArr = f.this.F;
                if (zArr != null) {
                    zArr[i3] = this.f159e.isItemChecked(i3);
                }
                f.this.J.onClick(this.f160f.f86b, i3, this.f159e.isItemChecked(i3));
            }
        }

        public interface e {
            void a(ListView listView);
        }

        public f(Context context) {
            this.f124a = context;
            this.f125b = (LayoutInflater) context.getSystemService("layout_inflater");
        }

        private void b(AlertController alertController) {
            ListAdapter hVar;
            RecycleListView recycleListView = (RecycleListView) this.f125b.inflate(alertController.L, (ViewGroup) null);
            if (this.G) {
                hVar = this.K == null ? new a(this.f124a, alertController.M, R.id.text1, this.f145v, recycleListView) : new b(this.f124a, this.K, false, recycleListView, alertController);
            } else {
                int i3 = this.H ? alertController.N : alertController.O;
                if (this.K != null) {
                    hVar = new SimpleCursorAdapter(this.f124a, i3, this.K, new String[]{this.L}, new int[]{R.id.text1});
                } else {
                    hVar = this.f146w;
                    if (hVar == null) {
                        hVar = new h(this.f124a, i3, R.id.text1, this.f145v);
                    }
                }
            }
            e eVar = this.O;
            if (eVar != null) {
                eVar.a(recycleListView);
            }
            alertController.H = hVar;
            alertController.I = this.I;
            if (this.f147x != null) {
                recycleListView.setOnItemClickListener(new c(alertController));
            } else if (this.J != null) {
                recycleListView.setOnItemClickListener(new d(recycleListView, alertController));
            }
            AdapterView.OnItemSelectedListener onItemSelectedListener = this.N;
            if (onItemSelectedListener != null) {
                recycleListView.setOnItemSelectedListener(onItemSelectedListener);
            }
            if (this.H) {
                recycleListView.setChoiceMode(1);
            } else if (this.G) {
                recycleListView.setChoiceMode(2);
            }
            alertController.f91g = recycleListView;
        }

        public void a(AlertController alertController) {
            View view = this.f130g;
            if (view != null) {
                alertController.l(view);
            } else {
                CharSequence charSequence = this.f129f;
                if (charSequence != null) {
                    alertController.q(charSequence);
                }
                Drawable drawable = this.f127d;
                if (drawable != null) {
                    alertController.n(drawable);
                }
                int i3 = this.f126c;
                if (i3 != 0) {
                    alertController.m(i3);
                }
                int i4 = this.f128e;
                if (i4 != 0) {
                    alertController.m(alertController.c(i4));
                }
            }
            CharSequence charSequence2 = this.f131h;
            if (charSequence2 != null) {
                alertController.o(charSequence2);
            }
            CharSequence charSequence3 = this.f132i;
            if (charSequence3 != null || this.f133j != null) {
                alertController.k(-1, charSequence3, this.f134k, null, this.f133j);
            }
            CharSequence charSequence4 = this.f135l;
            if (charSequence4 != null || this.f136m != null) {
                alertController.k(-2, charSequence4, this.f137n, null, this.f136m);
            }
            CharSequence charSequence5 = this.f138o;
            if (charSequence5 != null || this.f139p != null) {
                alertController.k(-3, charSequence5, this.f140q, null, this.f139p);
            }
            if (this.f145v != null || this.K != null || this.f146w != null) {
                b(alertController);
            }
            View view2 = this.f149z;
            if (view2 != null) {
                if (this.E) {
                    alertController.t(view2, this.A, this.B, this.C, this.D);
                    return;
                } else {
                    alertController.s(view2);
                    return;
                }
            }
            int i5 = this.f148y;
            if (i5 != 0) {
                alertController.r(i5);
            }
        }
    }

    private static final class g extends Handler {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private WeakReference<DialogInterface> f162a;

        public g(DialogInterface dialogInterface) {
            this.f162a = new WeakReference<>(dialogInterface);
        }

        @Override // android.os.Handler
        public void handleMessage(Message message) {
            int i3 = message.what;
            if (i3 == -3 || i3 == -2 || i3 == -1) {
                ((DialogInterface.OnClickListener) message.obj).onClick(this.f162a.get(), message.what);
            } else {
                if (i3 != 1) {
                    return;
                }
                ((DialogInterface) message.obj).dismiss();
            }
        }
    }

    private static class h extends ArrayAdapter<CharSequence> {
        public h(Context context, int i3, int i4, CharSequence[] charSequenceArr) {
            super(context, i3, i4, charSequenceArr);
        }

        @Override // android.widget.ArrayAdapter, android.widget.Adapter
        public long getItemId(int i3) {
            return i3;
        }

        @Override // android.widget.BaseAdapter, android.widget.Adapter
        public boolean hasStableIds() {
            return true;
        }
    }

    public AlertController(Context context, androidx.appcompat.app.h hVar, Window window) {
        this.f85a = context;
        this.f86b = hVar;
        this.f87c = window;
        this.R = new g(hVar);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(null, c.j.D, c.a.f3163n, 0);
        this.J = typedArrayObtainStyledAttributes.getResourceId(c.j.E, 0);
        this.K = typedArrayObtainStyledAttributes.getResourceId(c.j.G, 0);
        this.L = typedArrayObtainStyledAttributes.getResourceId(c.j.I, 0);
        this.M = typedArrayObtainStyledAttributes.getResourceId(c.j.J, 0);
        this.N = typedArrayObtainStyledAttributes.getResourceId(c.j.L, 0);
        this.O = typedArrayObtainStyledAttributes.getResourceId(c.j.H, 0);
        this.P = typedArrayObtainStyledAttributes.getBoolean(c.j.K, true);
        this.f88d = typedArrayObtainStyledAttributes.getDimensionPixelSize(c.j.F, 0);
        typedArrayObtainStyledAttributes.recycle();
        hVar.m(1);
    }

    static boolean a(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 (a(viewGroup.getChildAt(childCount))) {
                return true;
            }
        }
        return false;
    }

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

    static void f(View view, View view2, View view3) {
        if (view2 != null) {
            view2.setVisibility(view.canScrollVertically(-1) ? 0 : 4);
        }
        if (view3 != null) {
            view3.setVisibility(view.canScrollVertically(1) ? 0 : 4);
        }
    }

    private ViewGroup i(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;
    }

    private int j() {
        int i3 = this.K;
        return i3 == 0 ? this.J : this.Q == 1 ? i3 : this.J;
    }

    private void p(ViewGroup viewGroup, View view, int i3, int i4) {
        View viewFindViewById = this.f87c.findViewById(c.f.f3247v);
        View viewFindViewById2 = this.f87c.findViewById(c.f.f3246u);
        if (Build.VERSION.SDK_INT >= 23) {
            y.G0(view, i3, i4);
            if (viewFindViewById != null) {
                viewGroup.removeView(viewFindViewById);
            }
            if (viewFindViewById2 != null) {
                viewGroup.removeView(viewFindViewById2);
                return;
            }
            return;
        }
        if (viewFindViewById != null && (i3 & 1) == 0) {
            viewGroup.removeView(viewFindViewById);
            viewFindViewById = null;
        }
        if (viewFindViewById2 != null && (i3 & 2) == 0) {
            viewGroup.removeView(viewFindViewById2);
            viewFindViewById2 = null;
        }
        if (viewFindViewById == null && viewFindViewById2 == null) {
            return;
        }
        if (this.f90f != null) {
            this.A.setOnScrollChangeListener(new b(this, viewFindViewById, viewFindViewById2));
            this.A.post(new c(viewFindViewById, viewFindViewById2));
            return;
        }
        ListView listView = this.f91g;
        if (listView != null) {
            listView.setOnScrollListener(new d(this, viewFindViewById, viewFindViewById2));
            this.f91g.post(new e(viewFindViewById, viewFindViewById2));
            return;
        }
        if (viewFindViewById != null) {
            viewGroup.removeView(viewFindViewById);
        }
        if (viewFindViewById2 != null) {
            viewGroup.removeView(viewFindViewById2);
        }
    }

    private void u(ViewGroup viewGroup) {
        int i3;
        Button button = (Button) viewGroup.findViewById(R.id.button1);
        this.f99o = button;
        button.setOnClickListener(this.S);
        if (TextUtils.isEmpty(this.f100p) && this.f102r == null) {
            this.f99o.setVisibility(8);
            i3 = 0;
        } else {
            this.f99o.setText(this.f100p);
            Drawable drawable = this.f102r;
            if (drawable != null) {
                int i4 = this.f88d;
                drawable.setBounds(0, 0, i4, i4);
                this.f99o.setCompoundDrawables(this.f102r, null, null, null);
            }
            this.f99o.setVisibility(0);
            i3 = 1;
        }
        Button button2 = (Button) viewGroup.findViewById(R.id.button2);
        this.f103s = button2;
        button2.setOnClickListener(this.S);
        if (TextUtils.isEmpty(this.f104t) && this.f106v == null) {
            this.f103s.setVisibility(8);
        } else {
            this.f103s.setText(this.f104t);
            Drawable drawable2 = this.f106v;
            if (drawable2 != null) {
                int i5 = this.f88d;
                drawable2.setBounds(0, 0, i5, i5);
                this.f103s.setCompoundDrawables(this.f106v, null, null, null);
            }
            this.f103s.setVisibility(0);
            i3 |= 2;
        }
        Button button3 = (Button) viewGroup.findViewById(R.id.button3);
        this.f107w = button3;
        button3.setOnClickListener(this.S);
        if (TextUtils.isEmpty(this.f108x) && this.f110z == null) {
            this.f107w.setVisibility(8);
        } else {
            this.f107w.setText(this.f108x);
            Drawable drawable3 = this.f110z;
            if (drawable3 != null) {
                int i6 = this.f88d;
                drawable3.setBounds(0, 0, i6, i6);
                this.f107w.setCompoundDrawables(this.f110z, null, null, null);
            }
            this.f107w.setVisibility(0);
            i3 |= 4;
        }
        if (z(this.f85a)) {
            if (i3 == 1) {
                b(this.f99o);
            } else if (i3 == 2) {
                b(this.f103s);
            } else if (i3 == 4) {
                b(this.f107w);
            }
        }
        if (i3 != 0) {
            return;
        }
        viewGroup.setVisibility(8);
    }

    private void v(ViewGroup viewGroup) {
        NestedScrollView nestedScrollView = (NestedScrollView) this.f87c.findViewById(c.f.f3248w);
        this.A = nestedScrollView;
        nestedScrollView.setFocusable(false);
        this.A.setNestedScrollingEnabled(false);
        TextView textView = (TextView) viewGroup.findViewById(R.id.message);
        this.F = textView;
        if (textView == null) {
            return;
        }
        CharSequence charSequence = this.f90f;
        if (charSequence != null) {
            textView.setText(charSequence);
            return;
        }
        textView.setVisibility(8);
        this.A.removeView(this.F);
        if (this.f91g == null) {
            viewGroup.setVisibility(8);
            return;
        }
        ViewGroup viewGroup2 = (ViewGroup) this.A.getParent();
        int iIndexOfChild = viewGroup2.indexOfChild(this.A);
        viewGroup2.removeViewAt(iIndexOfChild);
        viewGroup2.addView(this.f91g, iIndexOfChild, new ViewGroup.LayoutParams(-1, -1));
    }

    private void w(ViewGroup viewGroup) {
        View viewInflate = this.f92h;
        if (viewInflate == null) {
            viewInflate = this.f93i != 0 ? LayoutInflater.from(this.f85a).inflate(this.f93i, viewGroup, false) : null;
        }
        boolean z2 = viewInflate != null;
        if (!z2 || !a(viewInflate)) {
            this.f87c.setFlags(131072, 131072);
        }
        if (!z2) {
            viewGroup.setVisibility(8);
            return;
        }
        FrameLayout frameLayout = (FrameLayout) this.f87c.findViewById(c.f.f3239n);
        frameLayout.addView(viewInflate, new ViewGroup.LayoutParams(-1, -1));
        if (this.f98n) {
            frameLayout.setPadding(this.f94j, this.f95k, this.f96l, this.f97m);
        }
        if (this.f91g != null) {
            ((LinearLayout.LayoutParams) ((m0.a) viewGroup.getLayoutParams())).weight = 0.0f;
        }
    }

    private void x(ViewGroup viewGroup) {
        if (this.G != null) {
            viewGroup.addView(this.G, 0, new ViewGroup.LayoutParams(-1, -2));
            this.f87c.findViewById(c.f.O).setVisibility(8);
            return;
        }
        this.D = (ImageView) this.f87c.findViewById(R.id.icon);
        if (!(!TextUtils.isEmpty(this.f89e)) || !this.P) {
            this.f87c.findViewById(c.f.O).setVisibility(8);
            this.D.setVisibility(8);
            viewGroup.setVisibility(8);
            return;
        }
        TextView textView = (TextView) this.f87c.findViewById(c.f.f3235j);
        this.E = textView;
        textView.setText(this.f89e);
        int i3 = this.B;
        if (i3 != 0) {
            this.D.setImageResource(i3);
            return;
        }
        Drawable drawable = this.C;
        if (drawable != null) {
            this.D.setImageDrawable(drawable);
        } else {
            this.E.setPadding(this.D.getPaddingLeft(), this.D.getPaddingTop(), this.D.getPaddingRight(), this.D.getPaddingBottom());
            this.D.setVisibility(8);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    private void y() {
        View viewFindViewById;
        ListAdapter listAdapter;
        View viewFindViewById2;
        View viewFindViewById3 = this.f87c.findViewById(c.f.f3245t);
        int i3 = c.f.P;
        View viewFindViewById4 = viewFindViewById3.findViewById(i3);
        int i4 = c.f.f3238m;
        View viewFindViewById5 = viewFindViewById3.findViewById(i4);
        int i5 = c.f.f3236k;
        View viewFindViewById6 = viewFindViewById3.findViewById(i5);
        ViewGroup viewGroup = (ViewGroup) viewFindViewById3.findViewById(c.f.f3240o);
        w(viewGroup);
        View viewFindViewById7 = viewGroup.findViewById(i3);
        View viewFindViewById8 = viewGroup.findViewById(i4);
        View viewFindViewById9 = viewGroup.findViewById(i5);
        ViewGroup viewGroupI = i(viewFindViewById7, viewFindViewById4);
        ViewGroup viewGroupI2 = i(viewFindViewById8, viewFindViewById5);
        ViewGroup viewGroupI3 = i(viewFindViewById9, viewFindViewById6);
        v(viewGroupI2);
        u(viewGroupI3);
        x(viewGroupI);
        boolean z2 = viewGroup.getVisibility() != 8;
        boolean z3 = (viewGroupI == null || viewGroupI.getVisibility() == 8) ? 0 : 1;
        boolean z4 = (viewGroupI3 == null || viewGroupI3.getVisibility() == 8) ? false : true;
        if (!z4 && viewGroupI2 != null && (viewFindViewById2 = viewGroupI2.findViewById(c.f.K)) != null) {
            viewFindViewById2.setVisibility(0);
        }
        if (z3 != 0) {
            NestedScrollView nestedScrollView = this.A;
            if (nestedScrollView != null) {
                nestedScrollView.setClipToPadding(true);
            }
            View viewFindViewById10 = (this.f90f == null && this.f91g == null) ? null : viewGroupI.findViewById(c.f.N);
            if (viewFindViewById10 != null) {
                viewFindViewById10.setVisibility(0);
            }
        } else if (viewGroupI2 != null && (viewFindViewById = viewGroupI2.findViewById(c.f.L)) != null) {
            viewFindViewById.setVisibility(0);
        }
        ListView listView = this.f91g;
        if (listView instanceof RecycleListView) {
            ((RecycleListView) listView).a(z3, z4);
        }
        if (!z2) {
            View view = this.f91g;
            if (view == null) {
                view = this.A;
            }
            if (view != null) {
                p(viewGroupI2, view, z3 | (z4 ? 2 : 0), 3);
            }
        }
        ListView listView2 = this.f91g;
        if (listView2 == null || (listAdapter = this.H) == null) {
            return;
        }
        listView2.setAdapter(listAdapter);
        int i6 = this.I;
        if (i6 > -1) {
            listView2.setItemChecked(i6, true);
            listView2.setSelection(i6);
        }
    }

    private static boolean z(Context context) {
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(c.a.f3162m, typedValue, true);
        return typedValue.data != 0;
    }

    public int c(int i3) {
        TypedValue typedValue = new TypedValue();
        this.f85a.getTheme().resolveAttribute(i3, typedValue, true);
        return typedValue.resourceId;
    }

    public ListView d() {
        return this.f91g;
    }

    public void e() {
        this.f86b.setContentView(j());
        y();
    }

    public boolean g(int i3, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.A;
        return nestedScrollView != null && nestedScrollView.r(keyEvent);
    }

    public boolean h(int i3, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.A;
        return nestedScrollView != null && nestedScrollView.r(keyEvent);
    }

    public void k(int i3, CharSequence charSequence, DialogInterface.OnClickListener onClickListener, Message message, Drawable drawable) {
        if (message == null && onClickListener != null) {
            message = this.R.obtainMessage(i3, onClickListener);
        }
        if (i3 == -3) {
            this.f108x = charSequence;
            this.f109y = message;
            this.f110z = drawable;
        } else if (i3 == -2) {
            this.f104t = charSequence;
            this.f105u = message;
            this.f106v = drawable;
        } else {
            if (i3 != -1) {
                throw new IllegalArgumentException("Button does not exist");
            }
            this.f100p = charSequence;
            this.f101q = message;
            this.f102r = drawable;
        }
    }

    public void l(View view) {
        this.G = view;
    }

    public void m(int i3) {
        this.C = null;
        this.B = i3;
        ImageView imageView = this.D;
        if (imageView != null) {
            if (i3 == 0) {
                imageView.setVisibility(8);
            } else {
                imageView.setVisibility(0);
                this.D.setImageResource(this.B);
            }
        }
    }

    public void n(Drawable drawable) {
        this.C = drawable;
        this.B = 0;
        ImageView imageView = this.D;
        if (imageView != null) {
            if (drawable == null) {
                imageView.setVisibility(8);
            } else {
                imageView.setVisibility(0);
                this.D.setImageDrawable(drawable);
            }
        }
    }

    public void o(CharSequence charSequence) {
        this.f90f = charSequence;
        TextView textView = this.F;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    public void q(CharSequence charSequence) {
        this.f89e = charSequence;
        TextView textView = this.E;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    public void r(int i3) {
        this.f92h = null;
        this.f93i = i3;
        this.f98n = false;
    }

    public void s(View view) {
        this.f92h = view;
        this.f93i = 0;
        this.f98n = false;
    }

    public void t(View view, int i3, int i4, int i5, int i6) {
        this.f92h = view;
        this.f93i = 0;
        this.f98n = true;
        this.f94j = i3;
        this.f95k = i4;
        this.f96l = i5;
        this.f97m = i6;
    }
}
