package com.zxhl.aprileye

import android.app.Application
import android.text.TextUtils
import com.tencent.bugly.crashreport.CrashReport
import com.umeng.commonsdk.UMConfigure
import com.umeng.socialize.PlatformConfig
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.Config
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.base.BaseChildApplication
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.MiitHelper
import com.zxhl.cms.utils.Utils

/**
 * @author (wangXuewei)
 * @datetime 2022-08-05 11:16 GMT+8
 * @detail :
 */
class AppLi : BaseChildApplication() {

    override fun onCreate() {
        super.onCreate()
        AppContext.init(applicationContext)
    }

    private fun getOaid() {
        MiitHelper(appIdsUpdater).getDeviceIds(AppContext.mAppContext)
    }

    private val appIdsUpdater: MiitHelper.AppIdsUpdater =
        MiitHelper.AppIdsUpdater { ids ->
            if (!TextUtils.isEmpty(ids)) {
                SettingPreference.setOaid(ids)
                EventUtils.onEvent("tab_imp", "获取到oaid$ids")
            }
        }


    fun initAppConfig() {
        UMConfigure.init(AppContext.get(), UMConfigure.DEVICE_TYPE_PHONE, "")
        Utils.checkDebugMode(AppContext.get())
        PlatformConfig.setWeixin(Constant.WX_APPID, Constant.WX_APPKEY)
        PlatformConfig.setWXFileProvider("com.tencent.sample2.fileprovider");
        Config.init(AppContext.get())
        //初始化bugly
        CrashReport.initCrashReport(AppContext.get(), "f9fb9a9ef5", false);
        getOaid()
    }
}