package com.gh.gamecenter

import android.content.Context
import android.text.TextUtils
import com.bytedance.applog.AppLog
import com.bytedance.applog.GameReportHelper
import com.bytedance.applog.InitConfig
import com.bytedance.applog.util.UriConstants
import com.bytedance.hume.readapk.HumeSDK
import com.gh.gamecenter.common.constant.Config

import com.gh.gamecenter.common.exposure.meta.MetaUtil
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import android.text.TextUtils

object TeaHelper {

    @JvmStatic
    fun init(context: Context, channel: String) {
        val config = InitConfig("163824", channel)
        config.setUriConfig(UriConstants.DEFAULT)
        config.appName = "guanghuan1"
        config.setEnablePlay(true)
        config.setAutoStart(true)
        AppLog.init(context, config)

        AppLog.setOaidObserver {
            if (!TextUtils.isEmpty(it.id)) {
                HaloApp.getInstance().oaid = it.id
                MetaUtil.refreshMeta()
            }
            Utils.log("oaid is $it.id")
        }

        // gameReportHelper ?!
        GameReportHelper.onEventRegister("wechat", true)
        GameReportHelper.onEventPurchase("gift", "flower", "008", 1, "wechat", "¥", true, 1)
        Utils.log("init TeaHelper")
    }

    @JvmStatic
    fun teaChannel():String{
        var channel = HumeSDK.getChannel(HaloApp.getInstance());
        if (channel == null || TextUtils.isEmpty(channel.trim())) {
            channel = Config.DEFAULT_CHANNEL
        }
        return channel
    }

}