package com.grkj.iscs_mc

import android.app.Application
import android.content.Context
import androidx.multidex.MultiDex
import com.grkj.iscs_mc.model.Token
import com.grkj.iscs_mc.util.FileUtil
import com.grkj.iscs_mc.util.FileUtil.LOG_DIR
import com.grkj.iscs_mc.util.NetApi
import com.grkj.iscs_mc.util.NetHttpManager
import com.grkj.iscs_mc.util.SPUtils
import com.grkj.iscs_mc.util.log.LogUtil

class MyApplication : Application() {

    companion object {
        var instance: MyApplication? = null
    }

    override fun onCreate() {
        super.onCreate()
        instance = this
//        LogUtil.init(instance!!, FileUtil.ROOT_APP + FileUtil.LOG_DIR)
        // 路径：sdcard/Android/data/com.grkj.iscs/files/iscs/log
        LogUtil.init(this, "${FileUtil.getRootFolder(this)?.absolutePath}$LOG_DIR")

        NetHttpManager.getInstance().initCtx(this)

        NetApi.logout()
        SPUtils.clearLoginUser(this)
        Token.clear(this)

        LogUtil.i("App start")
    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(base)
    }
}