package com.gh.gamecenter.energy

import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IEnergyTaskProvider

/**
 * 与光能模块桥接的桥
 */
object EnergyBridge {

    private val mEnergyTaskHelp by lazy {
        ARouter.getInstance().build(RouteConsts.provider.energyTask).navigation() as? IEnergyTaskProvider
    }

    @JvmStatic
    fun postEnergyTaskForShare(type: String, id: String, url: String) {
        mEnergyTaskHelp?.postEnergyTaskForShare(type, id, url)
    }

    fun postEnergyTask(action: String) {
        mEnergyTaskHelp?.postEnergyTask(action)
    }

    fun postInviteCodeTask(code: String, from: String, callback: (() -> Unit)?) {
        mEnergyTaskHelp?.postInviteCodeTask(code, from, callback)
    }

    fun postEnergyTask(action: String, id: String?) {
        mEnergyTaskHelp?.postEnergyTask(action, id)
    }

    @JvmStatic
    fun postEnergyTask(action: String, id: String, packageName: String) {
        mEnergyTaskHelp?.postEnergyTask(action, id, packageName)
    }

    fun postEnergyTask(action: String, id: String?, packageName: String?, url: String?) {
        mEnergyTaskHelp?.postEnergyTask(action, id, packageName, url)
    }

    fun getEnergyCenterIntent(context: Context?): Intent {
        return mEnergyTaskHelp?.getEnergyCenterIntent(context) ?: Intent(context, MainActivity::class.java)
    }

    fun getEnergyCenterIntent(context: Context?, initTabIndex: Int): Intent {
        return mEnergyTaskHelp?.getEnergyCenterIntent(context, initTabIndex) ?: Intent(
            context,
            MainActivity::class.java
        )
    }

    fun getEnergyHouseIntent(context: Context?, categoryId: String?): Intent {
        return mEnergyTaskHelp?.getEnergyHouseIntent(context, categoryId) ?: Intent(context, MainActivity::class.java)
    }

}