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.entity.GameEntity

class CheckDownloadHandler : ChainHandler() {

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

    }
}