package com.gh.common.chain

import android.content.Context
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.common.utils.safelyGetInRelease
import com.gh.gamecenter.feature.entity.GameEntity

class CheckDownloadHandler : DownloadChainHandler() {

    override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
        val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
        DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
            if (hasNext()) {
                getNext()?.handleRequest(context, gameEntity, asVGame)
            } else {
                processEndCallback?.invoke(asVGame, isSubscribe)
            }
        }

    }
}