package u8;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.lang.ref.WeakReference;
import rm.n0;

/* loaded from: classes.dex */
public final class n {

    /* renamed from: a, reason: collision with root package name */
    private String f37011a;

    /* renamed from: b, reason: collision with root package name */
    private WeakReference f37012b;

    public n(String str) {
        this.f37011a = str;
    }

    private final AlertDialog b(Context context, String str) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        View inflate = LayoutInflater.from(context).inflate(h7.j.f21108w, (ViewGroup) null);
        ((TextView) inflate.findViewById(h7.i.L)).setText(str);
        builder.setView(inflate);
        builder.setCancelable(false);
        AlertDialog create = builder.create();
        kotlin.jvm.internal.t.f(create, "create(...)");
        return create;
    }

    public final AlertDialog a(Context context) {
        String str = this.f37011a;
        if (str == null) {
            str = "";
        }
        return b(context, str);
    }

    public final n0 c() {
        AlertDialog alertDialog;
        WeakReference weakReference = this.f37012b;
        if (weakReference == null || (alertDialog = (AlertDialog) weakReference.get()) == null) {
            return null;
        }
        alertDialog.dismiss();
        return n0.f34904a;
    }

    public final void d(Context context, String message) {
        kotlin.jvm.internal.t.g(message, "message");
        c();
        WeakReference weakReference = new WeakReference(b(context, message));
        AlertDialog alertDialog = (AlertDialog) weakReference.get();
        if (alertDialog != null) {
            alertDialog.show();
        }
        this.f37012b = weakReference;
    }

    public /* synthetic */ n(String str, int i10, kotlin.jvm.internal.k kVar) {
        this((i10 & 1) != 0 ? null : str);
    }
}
