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.widget.C0173c;
import androidx.core.widget.NestedScrollView;
import java.lang.ref.WeakReference;
import p007c.C0485a;
import p007c.C0490f;
import p007c.C0494j;
import p010d.DialogC0595y;
import p023h0.C0829h1;

/* loaded from: classes.dex */
public class AlertController {

    /* renamed from: A */
    public NestedScrollView f94A;

    /* renamed from: C */
    public Drawable f96C;

    /* renamed from: D */
    public ImageView f97D;

    /* renamed from: E */
    public TextView f98E;

    /* renamed from: F */
    public TextView f99F;

    /* renamed from: G */
    public View f100G;

    /* renamed from: H */
    public ListAdapter f101H;

    /* renamed from: J */
    public int f103J;

    /* renamed from: K */
    public int f104K;

    /* renamed from: L */
    public int f105L;

    /* renamed from: M */
    public int f106M;

    /* renamed from: N */
    public int f107N;

    /* renamed from: O */
    public int f108O;

    /* renamed from: P */
    public boolean f109P;

    /* renamed from: R */
    public Handler f111R;

    /* renamed from: a */
    public final Context f113a;

    /* renamed from: b */
    public final DialogC0595y f114b;

    /* renamed from: c */
    public final Window f115c;

    /* renamed from: d */
    public final int f116d;

    /* renamed from: e */
    public CharSequence f117e;

    /* renamed from: f */
    public CharSequence f118f;

    /* renamed from: g */
    public ListView f119g;

    /* renamed from: h */
    public View f120h;

    /* renamed from: i */
    public int f121i;

    /* renamed from: j */
    public int f122j;

    /* renamed from: k */
    public int f123k;

    /* renamed from: l */
    public int f124l;

    /* renamed from: m */
    public int f125m;

    /* renamed from: o */
    public Button f127o;

    /* renamed from: p */
    public CharSequence f128p;

    /* renamed from: q */
    public Message f129q;

    /* renamed from: r */
    public Drawable f130r;

    /* renamed from: s */
    public Button f131s;

    /* renamed from: t */
    public CharSequence f132t;

    /* renamed from: u */
    public Message f133u;

    /* renamed from: v */
    public Drawable f134v;

    /* renamed from: w */
    public Button f135w;

    /* renamed from: x */
    public CharSequence f136x;

    /* renamed from: y */
    public Message f137y;

    /* renamed from: z */
    public Drawable f138z;

    /* renamed from: n */
    public boolean f126n = false;

    /* renamed from: B */
    public int f95B = 0;

    /* renamed from: I */
    public int f102I = -1;

    /* renamed from: Q */
    public int f110Q = 0;

    /* renamed from: S */
    public final View.OnClickListener f112S = new View$OnClickListenerC0077a();

    /* loaded from: classes.dex */
    public static class RecycleListView extends ListView {

        /* renamed from: d */
        public final int f139d;

        /* renamed from: e */
        public final int f140e;

        public RecycleListView(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C0494j.f1814c2);
            this.f140e = obtainStyledAttributes.getDimensionPixelOffset(C0494j.f1819d2, -1);
            this.f139d = obtainStyledAttributes.getDimensionPixelOffset(C0494j.f1824e2, -1);
        }

        /* renamed from: a */
        public void m4954a(boolean z, boolean z2) {
            if (z2 && z) {
                return;
            }
            setPadding(getPaddingLeft(), z ? getPaddingTop() : this.f139d, getPaddingRight(), z2 ? getPaddingBottom() : this.f140e);
        }
    }

    /* renamed from: androidx.appcompat.app.AlertController$a */
    /* loaded from: classes.dex */
    public class View$OnClickListenerC0077a implements View.OnClickListener {
        public View$OnClickListenerC0077a() {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            Message message;
            Message message2;
            AlertController alertController = AlertController.this;
            Message obtain = ((view != alertController.f127o || (message2 = alertController.f129q) == null) && (view != alertController.f131s || (message2 = alertController.f133u) == null)) ? (view != alertController.f135w || (message = alertController.f137y) == null) ? null : Message.obtain(message) : Message.obtain(message2);
            if (obtain != null) {
                obtain.sendToTarget();
            }
            AlertController alertController2 = AlertController.this;
            alertController2.f111R.obtainMessage(1, alertController2.f114b).sendToTarget();
        }
    }

    /* renamed from: androidx.appcompat.app.AlertController$b */
    /* loaded from: classes.dex */
    public class C0078b implements NestedScrollView.InterfaceC0210c {

        /* renamed from: a */
        public final /* synthetic */ View f142a;

        /* renamed from: b */
        public final /* synthetic */ View f143b;

        public C0078b(View view, View view2) {
            this.f142a = view;
            this.f143b = view2;
        }

        @Override // androidx.core.widget.NestedScrollView.InterfaceC0210c
        /* renamed from: a */
        public void mo4433a(NestedScrollView nestedScrollView, int i, int i2, int i3, int i4) {
            AlertController.m4975f(nestedScrollView, this.f142a, this.f143b);
        }
    }

    /* renamed from: androidx.appcompat.app.AlertController$c */
    /* loaded from: classes.dex */
    public class RunnableC0079c implements Runnable {

        /* renamed from: d */
        public final /* synthetic */ View f145d;

        /* renamed from: e */
        public final /* synthetic */ View f146e;

        public RunnableC0079c(View view, View view2) {
            this.f145d = view;
            this.f146e = view2;
        }

        @Override // java.lang.Runnable
        public void run() {
            AlertController.m4975f(AlertController.this.f94A, this.f145d, this.f146e);
        }
    }

    /* renamed from: androidx.appcompat.app.AlertController$d */
    /* loaded from: classes.dex */
    public class C0080d implements AbsListView.OnScrollListener {

        /* renamed from: a */
        public final /* synthetic */ View f148a;

        /* renamed from: b */
        public final /* synthetic */ View f149b;

        public C0080d(View view, View view2) {
            this.f148a = view;
            this.f149b = view2;
        }

        @Override // android.widget.AbsListView.OnScrollListener
        public void onScroll(AbsListView absListView, int i, int i2, int i3) {
            AlertController.m4975f(absListView, this.f148a, this.f149b);
        }

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

    /* renamed from: androidx.appcompat.app.AlertController$e */
    /* loaded from: classes.dex */
    public class RunnableC0081e implements Runnable {

        /* renamed from: d */
        public final /* synthetic */ View f151d;

        /* renamed from: e */
        public final /* synthetic */ View f152e;

        public RunnableC0081e(View view, View view2) {
            this.f151d = view;
            this.f152e = view2;
        }

        @Override // java.lang.Runnable
        public void run() {
            AlertController.m4975f(AlertController.this.f119g, this.f151d, this.f152e);
        }
    }

    /* renamed from: androidx.appcompat.app.AlertController$f */
    /* loaded from: classes.dex */
    public static class C0082f {

        /* renamed from: A */
        public int f154A;

        /* renamed from: B */
        public int f155B;

        /* renamed from: C */
        public int f156C;

        /* renamed from: D */
        public int f157D;

        /* renamed from: F */
        public boolean[] f159F;

        /* renamed from: G */
        public boolean f160G;

        /* renamed from: H */
        public boolean f161H;

        /* renamed from: J */
        public DialogInterface.OnMultiChoiceClickListener f163J;

        /* renamed from: K */
        public Cursor f164K;

        /* renamed from: L */
        public String f165L;

        /* renamed from: M */
        public String f166M;

        /* renamed from: N */
        public AdapterView.OnItemSelectedListener f167N;

        /* renamed from: a */
        public final Context f169a;

        /* renamed from: b */
        public final LayoutInflater f170b;

        /* renamed from: d */
        public Drawable f172d;

        /* renamed from: f */
        public CharSequence f174f;

        /* renamed from: g */
        public View f175g;

        /* renamed from: h */
        public CharSequence f176h;

        /* renamed from: i */
        public CharSequence f177i;

        /* renamed from: j */
        public Drawable f178j;

        /* renamed from: k */
        public DialogInterface.OnClickListener f179k;

        /* renamed from: l */
        public CharSequence f180l;

        /* renamed from: m */
        public Drawable f181m;

        /* renamed from: n */
        public DialogInterface.OnClickListener f182n;

        /* renamed from: o */
        public CharSequence f183o;

        /* renamed from: p */
        public Drawable f184p;

        /* renamed from: q */
        public DialogInterface.OnClickListener f185q;

        /* renamed from: s */
        public DialogInterface.OnCancelListener f187s;

        /* renamed from: t */
        public DialogInterface.OnDismissListener f188t;

        /* renamed from: u */
        public DialogInterface.OnKeyListener f189u;

        /* renamed from: v */
        public CharSequence[] f190v;

        /* renamed from: w */
        public ListAdapter f191w;

        /* renamed from: x */
        public DialogInterface.OnClickListener f192x;

        /* renamed from: y */
        public int f193y;

        /* renamed from: z */
        public View f194z;

        /* renamed from: c */
        public int f171c = 0;

        /* renamed from: e */
        public int f173e = 0;

        /* renamed from: E */
        public boolean f158E = false;

        /* renamed from: I */
        public int f162I = -1;

        /* renamed from: O */
        public boolean f168O = true;

        /* renamed from: r */
        public boolean f186r = true;

        /* renamed from: androidx.appcompat.app.AlertController$f$a */
        /* loaded from: classes.dex */
        public class C0083a extends ArrayAdapter<CharSequence> {

            /* renamed from: d */
            public final /* synthetic */ RecycleListView f195d;

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

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

        /* renamed from: androidx.appcompat.app.AlertController$f$b */
        /* loaded from: classes.dex */
        public class C0084b extends CursorAdapter {

            /* renamed from: d */
            public final int f197d;

            /* renamed from: e */
            public final int f198e;

            /* renamed from: f */
            public final /* synthetic */ RecycleListView f199f;

            /* renamed from: g */
            public final /* synthetic */ AlertController f200g;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C0084b(Context context, Cursor cursor, boolean z, RecycleListView recycleListView, AlertController alertController) {
                super(context, cursor, z);
                this.f199f = recycleListView;
                this.f200g = alertController;
                Cursor cursor2 = getCursor();
                this.f197d = cursor2.getColumnIndexOrThrow(C0082f.this.f165L);
                this.f198e = cursor2.getColumnIndexOrThrow(C0082f.this.f166M);
            }

            @Override // android.widget.CursorAdapter
            public void bindView(View view, Context context, Cursor cursor) {
                ((CheckedTextView) view.findViewById(16908308)).setText(cursor.getString(this.f197d));
                this.f199f.setItemChecked(cursor.getPosition(), cursor.getInt(this.f198e) == 1);
            }

            @Override // android.widget.CursorAdapter
            public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
                return C0082f.this.f170b.inflate(this.f200g.f106M, viewGroup, false);
            }
        }

        /* renamed from: androidx.appcompat.app.AlertController$f$c */
        /* loaded from: classes.dex */
        public class C0085c implements AdapterView.OnItemClickListener {

            /* renamed from: d */
            public final /* synthetic */ AlertController f202d;

            public C0085c(AlertController alertController) {
                this.f202d = alertController;
            }

            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                C0082f.this.f192x.onClick(this.f202d.f114b, i);
                if (C0082f.this.f161H) {
                    return;
                }
                this.f202d.f114b.dismiss();
            }
        }

        /* renamed from: androidx.appcompat.app.AlertController$f$d */
        /* loaded from: classes.dex */
        public class C0086d implements AdapterView.OnItemClickListener {

            /* renamed from: d */
            public final /* synthetic */ RecycleListView f204d;

            /* renamed from: e */
            public final /* synthetic */ AlertController f205e;

            public C0086d(RecycleListView recycleListView, AlertController alertController) {
                this.f204d = recycleListView;
                this.f205e = alertController;
            }

            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                boolean[] zArr = C0082f.this.f159F;
                if (zArr != null) {
                    zArr[i] = this.f204d.isItemChecked(i);
                }
                C0082f.this.f163J.onClick(this.f205e.f114b, i, this.f204d.isItemChecked(i));
            }
        }

        public C0082f(Context context) {
            this.f169a = context;
            this.f170b = (LayoutInflater) context.getSystemService("layout_inflater");
        }

        /* renamed from: a */
        public void m4953a(AlertController alertController) {
            View view = this.f175g;
            if (view != null) {
                alertController.m4969l(view);
            } else {
                CharSequence charSequence = this.f174f;
                if (charSequence != null) {
                    alertController.m4964q(charSequence);
                }
                Drawable drawable = this.f172d;
                if (drawable != null) {
                    alertController.m4967n(drawable);
                }
                int i = this.f171c;
                if (i != 0) {
                    alertController.m4968m(i);
                }
                int i2 = this.f173e;
                if (i2 != 0) {
                    alertController.m4968m(alertController.m4978c(i2));
                }
            }
            CharSequence charSequence2 = this.f176h;
            if (charSequence2 != null) {
                alertController.m4966o(charSequence2);
            }
            CharSequence charSequence3 = this.f177i;
            if (charSequence3 != null || this.f178j != null) {
                alertController.m4970k(-1, charSequence3, this.f179k, null, this.f178j);
            }
            CharSequence charSequence4 = this.f180l;
            if (charSequence4 != null || this.f181m != null) {
                alertController.m4970k(-2, charSequence4, this.f182n, null, this.f181m);
            }
            CharSequence charSequence5 = this.f183o;
            if (charSequence5 != null || this.f184p != null) {
                alertController.m4970k(-3, charSequence5, this.f185q, null, this.f184p);
            }
            if (this.f190v != null || this.f164K != null || this.f191w != null) {
                m4952b(alertController);
            }
            View view2 = this.f194z;
            if (view2 != null) {
                if (this.f158E) {
                    alertController.m4961t(view2, this.f154A, this.f155B, this.f156C, this.f157D);
                    return;
                } else {
                    alertController.m4962s(view2);
                    return;
                }
            }
            int i3 = this.f193y;
            if (i3 != 0) {
                alertController.m4963r(i3);
            }
        }

        /* JADX WARN: Removed duplicated region for block: B:28:0x008c  */
        /* JADX WARN: Removed duplicated region for block: B:31:0x0093  */
        /* JADX WARN: Removed duplicated region for block: B:32:0x0097  */
        /* renamed from: b */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void m4952b(AlertController alertController) {
            ListAdapter listAdapter;
            AdapterView.OnItemClickListener c0086d;
            AdapterView.OnItemSelectedListener onItemSelectedListener;
            RecycleListView recycleListView = (RecycleListView) this.f170b.inflate(alertController.f105L, (ViewGroup) null);
            if (this.f160G) {
                listAdapter = this.f164K == null ? new C0083a(this.f169a, alertController.f106M, 16908308, this.f190v, recycleListView) : new C0084b(this.f169a, this.f164K, false, recycleListView, alertController);
            } else {
                int i = this.f161H ? alertController.f107N : alertController.f108O;
                if (this.f164K != null) {
                    listAdapter = new SimpleCursorAdapter(this.f169a, i, this.f164K, new String[]{this.f165L}, new int[]{16908308});
                } else {
                    listAdapter = this.f191w;
                    if (listAdapter == null) {
                        listAdapter = new C0088h(this.f169a, i, 16908308, this.f190v);
                    }
                }
            }
            alertController.f101H = listAdapter;
            alertController.f102I = this.f162I;
            if (this.f192x == null) {
                if (this.f163J != null) {
                    c0086d = new C0086d(recycleListView, alertController);
                }
                onItemSelectedListener = this.f167N;
                if (onItemSelectedListener != null) {
                    recycleListView.setOnItemSelectedListener(onItemSelectedListener);
                }
                if (!this.f161H) {
                    recycleListView.setChoiceMode(1);
                } else if (this.f160G) {
                    recycleListView.setChoiceMode(2);
                }
                alertController.f119g = recycleListView;
            }
            c0086d = new C0085c(alertController);
            recycleListView.setOnItemClickListener(c0086d);
            onItemSelectedListener = this.f167N;
            if (onItemSelectedListener != null) {
            }
            if (!this.f161H) {
            }
            alertController.f119g = recycleListView;
        }
    }

    /* renamed from: androidx.appcompat.app.AlertController$g */
    /* loaded from: classes.dex */
    public static final class HandlerC0087g extends Handler {

        /* renamed from: a */
        public WeakReference<DialogInterface> f207a;

        public HandlerC0087g(DialogInterface dialogInterface) {
            this.f207a = new WeakReference<>(dialogInterface);
        }

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

    /* renamed from: androidx.appcompat.app.AlertController$h */
    /* loaded from: classes.dex */
    public static class C0088h extends ArrayAdapter<CharSequence> {
        public C0088h(Context context, int i, int i2, CharSequence[] charSequenceArr) {
            super(context, i, i2, charSequenceArr);
        }

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

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

    public AlertController(Context context, DialogC0595y dialogC0595y, Window window) {
        this.f113a = context;
        this.f114b = dialogC0595y;
        this.f115c = window;
        this.f111R = new HandlerC0087g(dialogC0595y);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(null, C0494j.f1716F, C0485a.alertDialogStyle, 0);
        this.f103J = obtainStyledAttributes.getResourceId(C0494j.f1721G, 0);
        this.f104K = obtainStyledAttributes.getResourceId(C0494j.f1729I, 0);
        this.f105L = obtainStyledAttributes.getResourceId(C0494j.f1737K, 0);
        this.f106M = obtainStyledAttributes.getResourceId(C0494j.f1741L, 0);
        this.f107N = obtainStyledAttributes.getResourceId(C0494j.f1749N, 0);
        this.f108O = obtainStyledAttributes.getResourceId(C0494j.f1733J, 0);
        this.f109P = obtainStyledAttributes.getBoolean(C0494j.f1745M, true);
        this.f116d = obtainStyledAttributes.getDimensionPixelSize(C0494j.f1725H, 0);
        obtainStyledAttributes.recycle();
        dialogC0595y.m3315m(1);
    }

    /* renamed from: a */
    public static boolean m4980a(View view) {
        if (view.onCheckIsTextEditor()) {
            return true;
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            int childCount = viewGroup.getChildCount();
            while (childCount > 0) {
                childCount--;
                if (m4980a(viewGroup.getChildAt(childCount))) {
                    return true;
                }
            }
            return false;
        }
        return false;
    }

    /* renamed from: f */
    public static void m4975f(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);
        }
    }

    /* renamed from: z */
    public static boolean m4955z(Context context) {
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(C0485a.alertDialogCenterButtons, typedValue, true);
        return typedValue.data != 0;
    }

    /* renamed from: b */
    public final void m4979b(Button button) {
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button.getLayoutParams();
        layoutParams.gravity = 1;
        layoutParams.weight = 0.5f;
        button.setLayoutParams(layoutParams);
    }

    /* renamed from: c */
    public int m4978c(int i) {
        TypedValue typedValue = new TypedValue();
        this.f113a.getTheme().resolveAttribute(i, typedValue, true);
        return typedValue.resourceId;
    }

    /* renamed from: d */
    public ListView m4977d() {
        return this.f119g;
    }

    /* renamed from: e */
    public void m4976e() {
        this.f114b.setContentView(m4971j());
        m4956y();
    }

    /* renamed from: g */
    public boolean m4974g(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.f94A;
        return nestedScrollView != null && nestedScrollView.m4442s(keyEvent);
    }

    /* renamed from: h */
    public boolean m4973h(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.f94A;
        return nestedScrollView != null && nestedScrollView.m4442s(keyEvent);
    }

    /* renamed from: i */
    public final ViewGroup m4972i(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;
    }

    /* renamed from: j */
    public final int m4971j() {
        int i = this.f104K;
        return (i != 0 && this.f110Q == 1) ? i : this.f103J;
    }

    /* renamed from: k */
    public void m4970k(int i, CharSequence charSequence, DialogInterface.OnClickListener onClickListener, Message message, Drawable drawable) {
        if (message == null && onClickListener != null) {
            message = this.f111R.obtainMessage(i, onClickListener);
        }
        if (i == -3) {
            this.f136x = charSequence;
            this.f137y = message;
            this.f138z = drawable;
        } else if (i == -2) {
            this.f132t = charSequence;
            this.f133u = message;
            this.f134v = drawable;
        } else if (i != -1) {
            throw new IllegalArgumentException("Button does not exist");
        } else {
            this.f128p = charSequence;
            this.f129q = message;
            this.f130r = drawable;
        }
    }

    /* renamed from: l */
    public void m4969l(View view) {
        this.f100G = view;
    }

    /* renamed from: m */
    public void m4968m(int i) {
        this.f96C = null;
        this.f95B = i;
        ImageView imageView = this.f97D;
        if (imageView != null) {
            if (i == 0) {
                imageView.setVisibility(8);
                return;
            }
            imageView.setVisibility(0);
            this.f97D.setImageResource(this.f95B);
        }
    }

    /* renamed from: n */
    public void m4967n(Drawable drawable) {
        this.f96C = drawable;
        this.f95B = 0;
        ImageView imageView = this.f97D;
        if (imageView != null) {
            if (drawable == null) {
                imageView.setVisibility(8);
                return;
            }
            imageView.setVisibility(0);
            this.f97D.setImageDrawable(drawable);
        }
    }

    /* renamed from: o */
    public void m4966o(CharSequence charSequence) {
        this.f118f = charSequence;
        TextView textView = this.f99F;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    /* renamed from: p */
    public final void m4965p(ViewGroup viewGroup, View view, int i, int i2) {
        View view2;
        Runnable runnableC0081e;
        View findViewById = this.f115c.findViewById(C0490f.scrollIndicatorUp);
        View findViewById2 = this.f115c.findViewById(C0490f.scrollIndicatorDown);
        if (Build.VERSION.SDK_INT < 23) {
            if (findViewById != null && (i & 1) == 0) {
                viewGroup.removeView(findViewById);
                findViewById = null;
            }
            if (findViewById2 != null && (i & 2) == 0) {
                viewGroup.removeView(findViewById2);
                findViewById2 = null;
            }
            if (findViewById == null && findViewById2 == null) {
                return;
            }
            if (this.f118f != null) {
                this.f94A.setOnScrollChangeListener(new C0078b(findViewById, findViewById2));
                view2 = this.f94A;
                runnableC0081e = new RunnableC0079c(findViewById, findViewById2);
            } else {
                ListView listView = this.f119g;
                if (listView != null) {
                    listView.setOnScrollListener(new C0080d(findViewById, findViewById2));
                    view2 = this.f119g;
                    runnableC0081e = new RunnableC0081e(findViewById, findViewById2);
                } else {
                    if (findViewById != null) {
                        viewGroup.removeView(findViewById);
                    }
                    if (findViewById2 == null) {
                        return;
                    }
                }
            }
            view2.post(runnableC0081e);
            return;
        }
        C0829h1.m2838Y(view, i, i2);
        if (findViewById != null) {
            viewGroup.removeView(findViewById);
        }
        if (findViewById2 == null) {
            return;
        }
        viewGroup.removeView(findViewById2);
    }

    /* renamed from: q */
    public void m4964q(CharSequence charSequence) {
        this.f117e = charSequence;
        TextView textView = this.f98E;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    /* renamed from: r */
    public void m4963r(int i) {
        this.f120h = null;
        this.f121i = i;
        this.f126n = false;
    }

    /* renamed from: s */
    public void m4962s(View view) {
        this.f120h = view;
        this.f121i = 0;
        this.f126n = false;
    }

    /* renamed from: t */
    public void m4961t(View view, int i, int i2, int i3, int i4) {
        this.f120h = view;
        this.f121i = 0;
        this.f126n = true;
        this.f122j = i;
        this.f123k = i2;
        this.f124l = i3;
        this.f125m = i4;
    }

    /* renamed from: u */
    public final void m4960u(ViewGroup viewGroup) {
        boolean z;
        Button button;
        Button button2 = (Button) viewGroup.findViewById(16908313);
        this.f127o = button2;
        button2.setOnClickListener(this.f112S);
        if (TextUtils.isEmpty(this.f128p) && this.f130r == null) {
            this.f127o.setVisibility(8);
            z = false;
        } else {
            this.f127o.setText(this.f128p);
            Drawable drawable = this.f130r;
            if (drawable != null) {
                int i = this.f116d;
                drawable.setBounds(0, 0, i, i);
                this.f127o.setCompoundDrawables(this.f130r, null, null, null);
            }
            this.f127o.setVisibility(0);
            z = true;
        }
        Button button3 = (Button) viewGroup.findViewById(16908314);
        this.f131s = button3;
        button3.setOnClickListener(this.f112S);
        if (TextUtils.isEmpty(this.f132t) && this.f134v == null) {
            this.f131s.setVisibility(8);
        } else {
            this.f131s.setText(this.f132t);
            Drawable drawable2 = this.f134v;
            if (drawable2 != null) {
                int i2 = this.f116d;
                drawable2.setBounds(0, 0, i2, i2);
                this.f131s.setCompoundDrawables(this.f134v, null, null, null);
            }
            this.f131s.setVisibility(0);
            z |= true;
        }
        Button button4 = (Button) viewGroup.findViewById(16908315);
        this.f135w = button4;
        button4.setOnClickListener(this.f112S);
        if (TextUtils.isEmpty(this.f136x) && this.f138z == null) {
            this.f135w.setVisibility(8);
        } else {
            this.f135w.setText(this.f136x);
            Drawable drawable3 = this.f138z;
            if (drawable3 != null) {
                int i3 = this.f116d;
                drawable3.setBounds(0, 0, i3, i3);
                this.f135w.setCompoundDrawables(this.f138z, null, null, null);
            }
            this.f135w.setVisibility(0);
            z |= true;
        }
        if (m4955z(this.f113a)) {
            if (z) {
                button = this.f127o;
            } else if (z) {
                button = this.f131s;
            } else if (z) {
                button = this.f135w;
            }
            m4979b(button);
        }
        if (z) {
            return;
        }
        viewGroup.setVisibility(8);
    }

    /* renamed from: v */
    public final void m4959v(ViewGroup viewGroup) {
        NestedScrollView nestedScrollView = (NestedScrollView) this.f115c.findViewById(C0490f.scrollView);
        this.f94A = nestedScrollView;
        nestedScrollView.setFocusable(false);
        this.f94A.setNestedScrollingEnabled(false);
        TextView textView = (TextView) viewGroup.findViewById(16908299);
        this.f99F = textView;
        if (textView == null) {
            return;
        }
        CharSequence charSequence = this.f118f;
        if (charSequence != null) {
            textView.setText(charSequence);
            return;
        }
        textView.setVisibility(8);
        this.f94A.removeView(this.f99F);
        if (this.f119g == null) {
            viewGroup.setVisibility(8);
            return;
        }
        ViewGroup viewGroup2 = (ViewGroup) this.f94A.getParent();
        int indexOfChild = viewGroup2.indexOfChild(this.f94A);
        viewGroup2.removeViewAt(indexOfChild);
        viewGroup2.addView(this.f119g, indexOfChild, new ViewGroup.LayoutParams(-1, -1));
    }

    /* renamed from: w */
    public final void m4958w(ViewGroup viewGroup) {
        View view = this.f120h;
        if (view == null) {
            view = this.f121i != 0 ? LayoutInflater.from(this.f113a).inflate(this.f121i, viewGroup, false) : null;
        }
        boolean z = view != null;
        if (!z || !m4980a(view)) {
            this.f115c.setFlags(131072, 131072);
        }
        if (!z) {
            viewGroup.setVisibility(8);
            return;
        }
        FrameLayout frameLayout = (FrameLayout) this.f115c.findViewById(C0490f.custom);
        frameLayout.addView(view, new ViewGroup.LayoutParams(-1, -1));
        if (this.f126n) {
            frameLayout.setPadding(this.f122j, this.f123k, this.f124l, this.f125m);
        }
        if (this.f119g != null) {
            ((LinearLayout.LayoutParams) ((C0173c.C0174a) viewGroup.getLayoutParams())).weight = 0.0f;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r6v10, types: [android.view.View] */
    /* renamed from: x */
    public final void m4957x(ViewGroup viewGroup) {
        ViewGroup viewGroup2;
        if (this.f100G != null) {
            viewGroup.addView(this.f100G, 0, new ViewGroup.LayoutParams(-1, -2));
            viewGroup2 = this.f115c.findViewById(C0490f.title_template);
        } else {
            this.f97D = (ImageView) this.f115c.findViewById(16908294);
            if ((!TextUtils.isEmpty(this.f117e)) && this.f109P) {
                TextView textView = (TextView) this.f115c.findViewById(C0490f.alertTitle);
                this.f98E = textView;
                textView.setText(this.f117e);
                int i = this.f95B;
                if (i != 0) {
                    this.f97D.setImageResource(i);
                    return;
                }
                Drawable drawable = this.f96C;
                if (drawable != null) {
                    this.f97D.setImageDrawable(drawable);
                    return;
                }
                this.f98E.setPadding(this.f97D.getPaddingLeft(), this.f97D.getPaddingTop(), this.f97D.getPaddingRight(), this.f97D.getPaddingBottom());
                this.f97D.setVisibility(8);
                return;
            }
            this.f115c.findViewById(C0490f.title_template).setVisibility(8);
            this.f97D.setVisibility(8);
            viewGroup2 = viewGroup;
        }
        viewGroup2.setVisibility(8);
    }

    /* JADX WARN: Code restructure failed: missing block: B:32:0x0092, code lost:
        if (r1 != null) goto L50;
     */
    /* JADX WARN: Code restructure failed: missing block: B:36:0x009d, code lost:
        if (r1 != null) goto L50;
     */
    /* JADX WARN: Code restructure failed: missing block: B:37:0x009f, code lost:
        r1.setVisibility(0);
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: y */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m4956y() {
        View findViewById;
        ListAdapter listAdapter;
        View findViewById2;
        View findViewById3 = this.f115c.findViewById(C0490f.parentPanel);
        int i = C0490f.topPanel;
        View findViewById4 = findViewById3.findViewById(i);
        int i2 = C0490f.contentPanel;
        View findViewById5 = findViewById3.findViewById(i2);
        int i3 = C0490f.buttonPanel;
        View findViewById6 = findViewById3.findViewById(i3);
        ViewGroup viewGroup = (ViewGroup) findViewById3.findViewById(C0490f.customPanel);
        m4958w(viewGroup);
        View findViewById7 = viewGroup.findViewById(i);
        View findViewById8 = viewGroup.findViewById(i2);
        View findViewById9 = viewGroup.findViewById(i3);
        ViewGroup m4972i = m4972i(findViewById7, findViewById4);
        ViewGroup m4972i2 = m4972i(findViewById8, findViewById5);
        ViewGroup m4972i3 = m4972i(findViewById9, findViewById6);
        m4959v(m4972i2);
        m4960u(m4972i3);
        m4957x(m4972i);
        boolean z = viewGroup.getVisibility() != 8;
        boolean z2 = (m4972i == null || m4972i.getVisibility() == 8) ? 0 : 1;
        boolean z3 = (m4972i3 == null || m4972i3.getVisibility() == 8) ? false : true;
        if (!z3 && m4972i2 != null && (findViewById2 = m4972i2.findViewById(C0490f.textSpacerNoButtons)) != null) {
            findViewById2.setVisibility(0);
        }
        if (z2) {
            NestedScrollView nestedScrollView = this.f94A;
            if (nestedScrollView != null) {
                nestedScrollView.setClipToPadding(true);
            }
            findViewById = (this.f118f == null && this.f119g == null) ? null : m4972i.findViewById(C0490f.titleDividerNoCustom);
        } else if (m4972i2 != null) {
            findViewById = m4972i2.findViewById(C0490f.textSpacerNoTitle);
        }
        ListView listView = this.f119g;
        if (listView instanceof RecycleListView) {
            ((RecycleListView) listView).m4954a(z2, z3);
        }
        if (!z) {
            View view = this.f119g;
            if (view == null) {
                view = this.f94A;
            }
            if (view != null) {
                m4965p(m4972i2, view, z2 | (z3 ? 2 : 0), 3);
            }
        }
        ListView listView2 = this.f119g;
        if (listView2 == null || (listAdapter = this.f101H) == null) {
            return;
        }
        listView2.setAdapter(listAdapter);
        int i4 = this.f102I;
        if (i4 > -1) {
            listView2.setItemChecked(i4, true);
            listView2.setSelection(i4);
        }
    }
}