package com.composition.android.ad.csj.impl

import android.content.Context
import com.bytedance.sdk.openadsdk.TTAdConfig
import com.bytedance.sdk.openadsdk.TTAdConstant
import com.bytedance.sdk.openadsdk.TTAdSdk
import com.bytedance.sdk.openadsdk.TTCustomController
import com.composition.android.lib.ad.AdManager
import com.composition.android.lib.ad.interfaces.Initialize
import com.composition.android.lib.ad.util.adLogE

/**
 * @classname:
 * @author: LiuXiaoLong
 * @date: 2022/9/13
 * description:穿山甲广告SDK初始化
 */
class CSJInitialize(var appId: String) : Initialize {

    override fun init(context: Context) {

        TTAdSdk.init(context, TTAdConfig.Builder()
            .appId(appId)
            .useTextureView(true)
            .appName(context.packageName)
            .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK)
            .allowShowNotify(true)
            .debug(AdManager.instance.isDebug)
            .supportMultiProcess(false)
            .asyncInit(true)
            .needClearTaskReset()
            .customController(object : TTCustomController() {
                override fun getMacAddress(): String {
                    return ""
                }

                override fun isCanUsePhoneState(): Boolean {
                    return false
                }

                override fun isCanUseAndroidId(): Boolean {
                    return false
                }


            })
            .build(), object : TTAdSdk.InitCallback {
            override fun success() {
                adLogE(AdManager.TAG, "穿山甲广告SDK初始化完成 ---- 版本号:${TTAdSdk.getAdManager().sdkVersion}")
            }

            override fun fail(p0: Int, p1: String?) {
                adLogE(AdManager.TAG, "穿山甲广告SDK初始化失败：${p1}")

            }

        })

    }


}