package com.seewo.libvui.h;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.method.ScrollingMovementMethod;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.seewo.libmyousdk.model.DubboResponseInfo;
import com.seewo.libvui.f;
import com.seewo.libvui.g;
import i.a.a.a;

/* JADX INFO: compiled from: CustomStyleDialog.java */
/* JADX INFO: loaded from: classes.dex */
public class b extends Dialog {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private boolean f1874b;

    /* JADX INFO: compiled from: CustomStyleDialog.java */
    public static class a {
        Context a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        String f1875b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        String f1876c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        String f1877d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        String f1878e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        String f1879f;

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

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        LinearLayout f1881h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        int f1882i = -1;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        int f1883j = -1;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f1884k = -1;
        int l = -1;
        DialogInterface.OnClickListener m;
        DialogInterface.OnClickListener n;
        DialogInterface.OnClickListener o;
        DialogInterface.OnCancelListener p;
        DialogInterface.OnDismissListener q;
        boolean r;

        /* JADX INFO: renamed from: com.seewo.libvui.h.b$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: CustomStyleDialog.java */
        class ViewOnClickListenerC0051a implements View.OnClickListener {

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            private static final /* synthetic */ a.InterfaceC0131a f1885g = null;

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

            static {
                a();
            }

            ViewOnClickListenerC0051a(Dialog dialog) {
                this.f1886b = dialog;
            }

            private static /* synthetic */ void a() {
                i.a.b.b.b bVar = new i.a.b.b.b("CustomStyleDialog.java", ViewOnClickListenerC0051a.class);
                f1885g = bVar.f("method-execution", bVar.e(DubboResponseInfo.STATUS_OK, "onClick", "com.seewo.libvui.dialog.CustomStyleDialog$Builder$1", "android.view.View", "v", "", "void"), 243);
            }

            @Override // android.view.View.OnClickListener
            public void onClick(View view) throws Throwable {
                d.e.h.d.a.a.b.k().m(new com.seewo.libvui.h.a(new Object[]{this, view, i.a.b.b.b.c(f1885g, this, this, view)}).linkClosureAndJoinPoint(69648));
            }
        }

        /* JADX INFO: renamed from: com.seewo.libvui.h.b$a$b, reason: collision with other inner class name */
        /* JADX INFO: compiled from: CustomStyleDialog.java */
        class ViewOnClickListenerC0052b implements View.OnClickListener {

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            private static final /* synthetic */ a.InterfaceC0131a f1888g = null;

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

            static {
                a();
            }

            ViewOnClickListenerC0052b(Dialog dialog) {
                this.f1889b = dialog;
            }

            private static /* synthetic */ void a() {
                i.a.b.b.b bVar = new i.a.b.b.b("CustomStyleDialog.java", ViewOnClickListenerC0052b.class);
                f1888g = bVar.f("method-execution", bVar.e(DubboResponseInfo.STATUS_OK, "onClick", "com.seewo.libvui.dialog.CustomStyleDialog$Builder$2", "android.view.View", "v", "", "void"), 258);
            }

            @Override // android.view.View.OnClickListener
            public void onClick(View view) throws Throwable {
                d.e.h.d.a.a.b.k().m(new com.seewo.libvui.h.c(new Object[]{this, view, i.a.b.b.b.c(f1888g, this, this, view)}).linkClosureAndJoinPoint(69648));
            }
        }

        /* JADX INFO: compiled from: CustomStyleDialog.java */
        class c implements View.OnClickListener {

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            private static final /* synthetic */ a.InterfaceC0131a f1891g = null;

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

            static {
                a();
            }

            c(Dialog dialog) {
                this.f1892b = dialog;
            }

            private static /* synthetic */ void a() {
                i.a.b.b.b bVar = new i.a.b.b.b("CustomStyleDialog.java", c.class);
                f1891g = bVar.f("method-execution", bVar.e(DubboResponseInfo.STATUS_OK, "onClick", "com.seewo.libvui.dialog.CustomStyleDialog$Builder$3", "android.view.View", "v", "", "void"), 272);
            }

            static final /* synthetic */ void b(c cVar, View view, i.a.a.a aVar) {
                DialogInterface.OnClickListener onClickListener = a.this.o;
                if (onClickListener != null) {
                    onClickListener.onClick(cVar.f1892b, -2);
                }
                cVar.f1892b.dismiss();
            }

            @Override // android.view.View.OnClickListener
            public void onClick(View view) throws Throwable {
                d.e.h.d.a.a.b.k().m(new d(new Object[]{this, view, i.a.b.b.b.c(f1891g, this, this, view)}).linkClosureAndJoinPoint(69648));
            }
        }

        public a(Context context) {
            this.a = context;
        }

        public b a() {
            LayoutInflater layoutInflater = (LayoutInflater) this.a.getSystemService("layout_inflater");
            b bVar = new b(this.a, g.SeewoDialog);
            b(layoutInflater.inflate(f.custom_dialog_layout, (ViewGroup) null), bVar);
            bVar.f1874b = this.r;
            return bVar;
        }

        protected void b(View view, Dialog dialog) {
            e(view);
            h(view);
            k(dialog, view);
            j(dialog, view);
            i(dialog, view);
            c(view);
            d(dialog);
            g(dialog);
            dialog.setContentView(view, new ViewGroup.LayoutParams(-1, -2));
            f(dialog);
        }

        protected void c(View view) {
            if (this.f1879f == null && this.f1877d == null && this.f1878e != null) {
                view.findViewById(com.seewo.libvui.e.neutralButton).setBackgroundResource(com.seewo.libvui.d.seewoos_single_btn_selector);
            }
            if (this.f1879f == null && this.f1877d == null && this.f1878e == null && this.f1880g == null) {
                view.findViewById(com.seewo.libvui.e.bottom_layout).setVisibility(8);
            }
        }

        protected void d(Dialog dialog) {
            DialogInterface.OnCancelListener onCancelListener = this.p;
            if (onCancelListener != null) {
                dialog.setOnCancelListener(onCancelListener);
            }
        }

        protected void e(View view) {
            ((TextView) view.findViewById(com.seewo.libvui.e.title)).setText(this.f1875b);
        }

        protected void f(Dialog dialog) {
            DisplayMetrics displayMetrics = this.a.getResources().getDisplayMetrics();
            Window window = dialog.getWindow();
            WindowManager.LayoutParams attributes = window.getAttributes();
            attributes.y = Math.round(displayMetrics.density * (-30.0f));
            window.setAttributes(attributes);
        }

        protected void g(Dialog dialog) {
            DialogInterface.OnDismissListener onDismissListener = this.q;
            if (onDismissListener != null) {
                dialog.setOnDismissListener(onDismissListener);
            }
        }

        protected void h(View view) {
            if (this.f1876c != null) {
                TextView textView = (TextView) view.findViewById(com.seewo.libvui.e.message);
                textView.setMovementMethod(ScrollingMovementMethod.getInstance());
                textView.setText(this.f1876c);
                return;
            }
            if (this.f1880g == null) {
                view.findViewById(com.seewo.libvui.e.message).setVisibility(8);
                return;
            }
            LinearLayout linearLayout = (LinearLayout) view.findViewById(com.seewo.libvui.e.content);
            this.f1881h = linearLayout;
            linearLayout.removeAllViews();
            if (this.f1882i == -1) {
                this.f1882i = this.f1881h.getPaddingLeft();
            }
            if (this.f1883j == -1) {
                this.f1883j = this.f1881h.getPaddingRight();
            }
            if (this.f1884k == -1) {
                this.f1884k = this.f1881h.getPaddingTop();
            }
            if (this.l == -1) {
                this.l = this.f1881h.getPaddingBottom();
            }
            this.f1881h.setPadding(this.f1882i, this.f1884k, this.f1883j, this.l);
            this.f1881h.addView(this.f1880g, new ViewGroup.LayoutParams(-1, -2));
            View view2 = this.f1880g;
            if (view2 instanceof ListView) {
                m((ListView) view2);
            }
        }

        protected void i(Dialog dialog, View view) {
            if (this.f1879f == null) {
                view.findViewById(com.seewo.libvui.e.negativeButton).setVisibility(8);
            } else {
                ((TextView) view.findViewById(com.seewo.libvui.e.negativeButton)).setText(this.f1879f);
                view.findViewById(com.seewo.libvui.e.negativeButton).setOnClickListener(new c(dialog));
            }
        }

        protected void j(Dialog dialog, View view) {
            if (this.f1878e == null) {
                view.findViewById(com.seewo.libvui.e.neutralButton).setVisibility(8);
                return;
            }
            ((TextView) view.findViewById(com.seewo.libvui.e.neutralButton)).setText(this.f1878e);
            if (this.n != null) {
                view.findViewById(com.seewo.libvui.e.neutralButton).setOnClickListener(new ViewOnClickListenerC0052b(dialog));
            }
        }

        protected void k(Dialog dialog, View view) {
            if (this.f1877d == null) {
                view.findViewById(com.seewo.libvui.e.positiveButton).setVisibility(8);
                return;
            }
            ((TextView) view.findViewById(com.seewo.libvui.e.positiveButton)).setText(this.f1877d);
            if (this.m != null) {
                view.findViewById(com.seewo.libvui.e.positiveButton).setOnClickListener(new ViewOnClickListenerC0051a(dialog));
            }
        }

        public a l(View view) {
            this.f1880g = view;
            return this;
        }

        public void m(ListView listView) {
            ListAdapter adapter = listView.getAdapter();
            if (adapter == null) {
                return;
            }
            int count = adapter.getCount();
            int measuredHeight = 0;
            for (int i2 = 0; i2 < count; i2++) {
                View view = adapter.getView(i2, null, listView);
                view.measure(0, 0);
                measuredHeight += view.getMeasuredHeight();
            }
            ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
            layoutParams.height = measuredHeight + (listView.getDividerHeight() * (count - 1));
            listView.setLayoutParams(layoutParams);
        }

        public a n(int i2) {
            this.f1876c = (String) this.a.getText(i2);
            return this;
        }

        public a o(String str) {
            this.f1876c = str;
            return this;
        }

        public a p(int i2, DialogInterface.OnClickListener onClickListener) {
            q((String) this.a.getText(i2), onClickListener);
            return this;
        }

        public a q(String str, DialogInterface.OnClickListener onClickListener) {
            this.f1879f = str;
            this.o = onClickListener;
            return this;
        }

        public a r(int i2, DialogInterface.OnClickListener onClickListener) {
            s((String) this.a.getText(i2), onClickListener);
            return this;
        }

        public a s(String str, DialogInterface.OnClickListener onClickListener) {
            this.f1878e = str;
            this.n = onClickListener;
            return this;
        }

        public a t(DialogInterface.OnDismissListener onDismissListener) {
            this.q = onDismissListener;
            return this;
        }

        public a u(int i2) {
            this.l = i2;
            return this;
        }

        public a v(int i2) {
            this.f1884k = i2;
            return this;
        }

        public a w(int i2, DialogInterface.OnClickListener onClickListener) {
            x((String) this.a.getText(i2), onClickListener);
            return this;
        }

        public a x(String str, DialogInterface.OnClickListener onClickListener) {
            this.f1877d = str;
            this.m = onClickListener;
            return this;
        }

        public a y(int i2) {
            this.f1875b = (String) this.a.getText(i2);
            return this;
        }

        public a z(String str) {
            this.f1875b = str;
            return this;
        }
    }

    protected b(Context context, int i2) {
        super(context, i2);
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i2, KeyEvent keyEvent) {
        return this.f1874b || super.onKeyDown(i2, keyEvent);
    }
}
