package com.gh.gamecenter.csj

import android.app.Activity
import android.content.Context
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.therouter.router.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.ICsjAdProvider

@com.therouter.inject.ServiceProvider
class CsjAdProviderImpl : ICsjAdProvider {
    override fun initSDK(context: Context, id: String, oaid: String) {
        CsjAdHelper.init(context, id, oaid)
    }

    override fun requestSplashAd(
        activity: Activity,
        slotId: String,
        adViewWidthInPx: Int,
        adViewHeightInPx: Int,
        adViewWidthInDp: Float,
        adViewHeightInDp: Float,
        startAdContainer: ViewGroup,
        timeout: Int,
        onAdShowAction: () -> Unit,
        onAdClickAction: () -> Unit,
        callback: (isSuccess: Boolean) -> Unit,
    ) {
        CsjAdHelper.requestSplashAd(
            activity,
            slotId,
            adViewWidthInPx,
            adViewHeightInPx,
            adViewWidthInDp,
            adViewHeightInDp,
            startAdContainer,
            timeout,
            onAdShowAction,
            onAdClickAction,
            callback,
        )
    }

    override fun requestFlowAd(
        fragment: Fragment,
        containerView: ViewGroup,
        slotId: String,
        expressViewAcceptedSize: Float,
        onAdShowAction: () -> Unit,
        onAdClickAction: () -> Unit,
        callback: (isSuccess: Boolean) -> Unit,
    ) {
        CsjAdHelper.requestFlowAd(fragment, containerView, slotId, expressViewAcceptedSize, onAdShowAction, onAdClickAction, callback)
    }

    override fun requestBannerAd(
        fragment: Fragment,
        containerView: ViewGroup,
        slotId: String,
        expressViewWidthInDp: Float,
        expressViewHeightInDp: Float,
        onAdShowAction: () -> Unit,
        onAdClickAction: () -> Unit,
        callback: (isSuccess: Boolean) -> Unit
    ) {
        CsjAdHelper.requestBannerAd(fragment, containerView, slotId, expressViewWidthInDp, expressViewHeightInDp, onAdShowAction, onAdClickAction, callback)
    }

    override fun requestFullScreenAd(
        fragment: Fragment,
        slotId: String,
        onAdShowAction: () -> Unit,
        onAdClickAction: () -> Unit,
        callback: (isSuccess: Boolean) -> Unit
    ) {
        CsjAdHelper.requestFullScreenAd(fragment, slotId, onAdShowAction, onAdClickAction, callback)
    }

    override fun updateThemeStatus(context: Context, isDarkMode: Boolean) {
        CsjAdHelper.updateThemeStatus(isDarkMode)
    }

    override fun cancelSplashAd(context: Context) {
        // 穿山甲没有 cancel 的方法提供...
    }

    override fun shouldEnableSDK(channel: String): Boolean {
        return true
    }

}
