package com.various.funny.sounds.audio

import android.app.Application
import com.various.funny.sounds.audio.db.MyRoomBase
import com.various.funny.sounds.audio.helper.ComUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class VariousFunnySounds : Application() {

    companion object {
        lateinit var appContext: VariousFunnySounds

    }


    override fun onCreate() {
        super.onCreate()
        appContext = this
        getData()
    }

    private fun getData() {
        val open = assets.open("resource_target.json")
        CoroutineScope(Dispatchers.IO).launch {
            if (MyRoomBase.dataBase.getNewBeanDao().getData().isEmpty()) {
                val fileString = ComUtils.getFileString(open)
                  ComUtils.parseJsonStr(fileString)
            }

        }


    }
}