package com.gh.common.provider

import androidx.fragment.app.FragmentActivity
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.core.provider.IUpdateManagerProvider
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.update.UpdateHelper

@com.therouter.inject.ServiceProvider
class UpdateManagerProviderImpl: IUpdateManagerProvider {
    override fun checkUpdate(activity: FragmentActivity, ignoreSuppressOption: Boolean) {
        val dialog = DialogUtils.showWaitDialog(activity, "检查更新中...")

        UpdateHelper.getUpdate(ignoreSuppressOption) {
            dialog.dismiss()

            if (UpdateHelper.isUpdateValid(ignoreSuppressOption)) {
                UpdateHelper.showUpdateDialog(activity) {
                    // Do nothing
                }
            } else {
                ToastUtils.toast("您的光环助手已是最新版本")
            }
        }
    }
}