package com.seewo.ota.update.device.ui;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.cvte.vman.impl.FwUpgradeManager;
import com.seewo.ota.R;
import g.a.h0;
import g.a.i0;
import g.a.x0;

/* JADX INFO: compiled from: UpdateConfirmDialog.kt */
/* JADX INFO: loaded from: classes.dex */
public final class s extends Dialog implements h0 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final /* synthetic */ h0 f2320b;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private String f2322g;

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private DialogInterface.OnClickListener f2325j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private TextView f2326k;
    private TextView l;
    private Button m;
    private Button n;
    private final a o;

    /* JADX INFO: compiled from: UpdateConfirmDialog.kt */
    public static final class a extends CountDownTimer {
        a() {
            super(30000L, 1000L);
        }

        @Override // android.os.CountDownTimer
        public void onFinish() {
            if (s.this.isShowing()) {
                s.this.dismiss();
            }
            s.this.b().onClick(s.this, -1);
        }

        @Override // android.os.CountDownTimer
        public void onTick(long j2) {
            long j3 = j2 / ((long) FwUpgradeManager.TYPE_FW_CVTE_CAMERA);
            TextView textView = s.this.f2326k;
            if (textView != null) {
                textView.setText(String.valueOf(j3));
            } else {
                f.z.d.k.p("countDownTime");
                throw null;
            }
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public s(Context context) {
        WindowManager.LayoutParams attributes;
        super(context);
        f.z.d.k.e(context, "context");
        this.f2320b = i0.a(x0.c());
        this.f2322g = "";
        this.f2324i = "";
        this.f2325j = new DialogInterface.OnClickListener() { // from class: com.seewo.ota.update.device.ui.o
            @Override // android.content.DialogInterface.OnClickListener
            public final void onClick(DialogInterface dialogInterface, int i2) {
                s.i(dialogInterface, i2);
            }
        };
        this.o = new a();
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        Window window = getWindow();
        if (window != null && (attributes = window.getAttributes()) != null) {
            attributes.height = -1;
            attributes.width = -1;
            attributes.gravity = 17;
        }
        window.setType(2002);
    }

    private final void c() {
        View viewInflate = getLayoutInflater().inflate(R.layout.dialog_update_confirm, (ViewGroup) null);
        String string = this.f2321f != 0 ? viewInflate.getContext().getString(this.f2321f) : this.f2322g;
        String string2 = this.f2323h != 0 ? viewInflate.getContext().getString(this.f2323h) : this.f2324i;
        setTitle(string);
        setContentView(viewInflate);
        View viewFindViewById = viewInflate.findViewById(R.id.countDownTime);
        f.z.d.k.d(viewFindViewById, "findViewById(R.id.countDownTime)");
        this.f2326k = (TextView) viewFindViewById;
        View viewFindViewById2 = viewInflate.findViewById(R.id.content);
        f.z.d.k.d(viewFindViewById2, "findViewById(R.id.content)");
        this.l = (TextView) viewFindViewById2;
        View viewFindViewById3 = viewInflate.findViewById(R.id.confirm);
        f.z.d.k.d(viewFindViewById3, "findViewById(R.id.confirm)");
        this.m = (Button) viewFindViewById3;
        View viewFindViewById4 = viewInflate.findViewById(R.id.cancel);
        f.z.d.k.d(viewFindViewById4, "findViewById(R.id.cancel)");
        this.n = (Button) viewFindViewById4;
        f.z.d.k.d(string2, "contentText");
        l(string2);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void g(s sVar, View view) {
        f.z.d.k.e(sVar, "this$0");
        sVar.f2325j.onClick(sVar, -1);
        sVar.dismiss();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void h(s sVar, View view) {
        f.z.d.k.e(sVar, "this$0");
        sVar.f2325j.onClick(sVar, -2);
        sVar.dismiss();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void i(DialogInterface dialogInterface, int i2) {
    }

    private final void l(String str) {
        TextView textView = this.l;
        if (textView == null) {
            f.z.d.k.p("contentView");
            throw null;
        }
        textView.setVisibility(str.length() == 0 ? 8 : 0);
        TextView textView2 = this.l;
        if (textView2 != null) {
            textView2.setText(str);
        } else {
            f.z.d.k.p("contentView");
            throw null;
        }
    }

    public final DialogInterface.OnClickListener b() {
        return this.f2325j;
    }

    @Override // android.app.Dialog, android.content.DialogInterface
    public void dismiss() {
        super.dismiss();
        this.o.cancel();
    }

    @Override // g.a.h0
    public f.w.g getCoroutineContext() {
        return this.f2320b.getCoroutineContext();
    }

    public final void j(String str) {
        f.z.d.k.e(str, "<set-?>");
        this.f2324i = str;
    }

    public final void k(int i2) {
        this.f2323h = i2;
    }

    public final void m(DialogInterface.OnClickListener onClickListener) {
        f.z.d.k.e(onClickListener, "<set-?>");
        this.f2325j = onClickListener;
    }

    public final void n(int i2) {
        this.f2321f = i2;
    }

    @Override // android.app.Dialog
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        c();
        TextView textView = this.f2326k;
        if (textView == null) {
            f.z.d.k.p("countDownTime");
            throw null;
        }
        textView.setText("30000");
        Button button = this.m;
        if (button == null) {
            f.z.d.k.p("confirm");
            throw null;
        }
        button.setOnClickListener(new View.OnClickListener() { // from class: com.seewo.ota.update.device.ui.q
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                s.g(this.f2318b, view);
            }
        });
        Button button2 = this.n;
        if (button2 != null) {
            button2.setOnClickListener(new View.OnClickListener() { // from class: com.seewo.ota.update.device.ui.p
                @Override // android.view.View.OnClickListener
                public final void onClick(View view) {
                    s.h(this.f2317b, view);
                }
            });
        } else {
            f.z.d.k.p("cancel");
            throw null;
        }
    }

    @Override // android.app.Dialog
    public void show() {
        super.show();
        this.o.start();
    }
}
