MyApplication.kt 1.21 KB
package com.huaheng.wmspda

import android.app.Activity
import android.app.Application
import android.content.Context
import com.huaheng.wmspda.activity.ActivityCollector
import com.huaheng.wmspda.activity.BaseActivity
import com.huaheng.wmspda.bean.resp.Warehouse
import com.huaheng.wmspda.util.CrashHandler
import com.huaheng.wmspda.util.WmsSpf

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        context = applicationContext
        init()
    }

    /**
     * 初始化设置
     */
    fun init() {
        //语音
//        SoundUtils.getInstance(this);
        //奔溃日志
        CrashHandler.instance.init(this);
    }

    companion object {
        const val KEY_DEFAULT_ACTIVITY = "default_activity"
        lateinit var context: Context

        //debug模式开关,可显示更多调试信息
        var debug = false
        var warehouse: Warehouse? = null

        fun getCurrentActivity(): BaseActivity<*> {
            return ActivityCollector.activities[0]
        }

        fun setDefaultActivity() {
            val activity: Activity = getCurrentActivity()
            WmsSpf.saveData(KEY_DEFAULT_ACTIVITY, activity.javaClass.getName())
        }
    }
}