package com.gh.common.provider

import android.app.Dialog
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.common.callback.CancelListener
import com.gh.gamecenter.common.callback.ConfirmListener
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IDialogUtilsProvider

@Route(path = RouteConsts.provider.dialogUtils, name = "DialogUtils暴露服务")
class DialogUtilsProviderImpl : IDialogUtilsProvider {
    override fun showRegulationTestDialog(context: Context, confirm: () -> Unit, cancel: () -> Unit) {
        DialogUtils.showRegulationTestDialog(context, object : ConfirmListener {
            override fun onConfirm() {
                confirm.invoke()
            }
        }, object : CancelListener {
            override fun onCancel() {
                cancel.invoke()
            }
        })
    }

    override fun showWaitDialog(context: Context, string: String): Dialog = DialogUtils.showWaitDialog(context, string)

    override fun showUsageStatsDialog(context: Context, confirm: () -> Unit, cancel: () -> Unit) {
        DialogUtils.showUsageStatsDialog(context,
            { confirm.invoke() }, object :CancelListener{
            override fun onCancel() {
                cancel.invoke()
            }
        })
    }

    override fun showNoticeDialog(
        context: Context,
        title: String,
        content: String,
        confirm: () -> Unit
    ) {
        DialogUtils.showNoticeDialog(context, title, content
        ) { confirm.invoke() }
    }

    override fun showBindPhoneDialog(context: Context, confirm: () -> Unit): Dialog = DialogUtils.showBindPhoneDialog(context) { confirm.invoke() }

    override fun init(context: Context?) {
        // Do nothing
    }
}