package com.mints.goodmoney.manager

import android.app.Activity
import android.app.Application
import android.view.ViewGroup
import com.bianxianmao.sdk.BDAdvanceButtonAd
import com.bianxianmao.sdk.manager.BDAdvanceConfig
import com.bianxianmao.sdk.manager.BDManager
import com.mints.goodmoney.BuildConfig
import com.mints.goodmoney.common.Constant

/**
 * 描述：变现猫
 * 作者：孟崔广
 */
object BxmManager {

    const val APP_ID = "3b08a06c36a04eb7ad31ee31547b9e69"

    const val BUTTON_AD_SPOT_ID = "807020001003"

    private var bdAdvanceButtonAd: BDAdvanceButtonAd? = null

    /**
     * 初始化
     */
    fun initBxm(application: Application) {
        BDAdvanceConfig.getInstance()
                .setAppName(Constant.MINTS_APP_NAME)
                .setDebug(BuildConfig.DEBUG)
                .enableAudit(false)

        BDManager.getStance()
                .init(application, APP_ID)
    }

    /**
     * 获取Button广告
     */
    fun loadButtonAd(activity: Activity?, viewGroup: ViewGroup) {
        if (activity == null) return

        try {
            if (bdAdvanceButtonAd == null) {
                bdAdvanceButtonAd = BDAdvanceButtonAd(activity, viewGroup, BUTTON_AD_SPOT_ID)
            }
            bdAdvanceButtonAd?.loadAd()
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    fun onDestory() {
        bdAdvanceButtonAd = null
    }
}