package com.develop.foodcooking

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import com.develop.food.base.api.FoodRepository
import com.develop.food.base.common.CURRENT_LANGUAGE
import com.develop.food.base.common.LANGUAGE_SETTING
import com.develop.food.base.data.DataFactory
import com.develop.food.base.http.observeStatus
import com.develop.food.base.ui.BaseActivity
import com.develop.food.base.utils.MmkvUtils
import com.develop.food.base.router.navigateTo
import com.develop.foodcooking.databinding.ActivityMainBinding
import com.develop.food.base.router.Screens
import com.develop.food.base.utils.ConfigUtils
import com.develop.food.base.utils.SerialportLibUtils
import com.develop.food.base.utils.SettingKeyBoardUtils
import com.develop.food.base.utils.TopResumedActivityHolder
import com.develop.food.base.utils.TuyaUtils
import com.develop.food.base.widgets.RecipeUpdateDialog
import com.google.gson.Gson

class MainActivity : BaseActivity<ActivityMainBinding>() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)



        var tuyaConfig = ConfigUtils.loadTuyaConfig()
        if (tuyaConfig != null) {
            TuyaUtils.mAk = tuyaConfig.get("ak")
            TuyaUtils.mPid = tuyaConfig.get("pid")
            TuyaUtils.mUid = tuyaConfig.get("uid")
            TuyaUtils.initSDK(this, "1.0.0")
        }

        if (MmkvUtils.getBool("isFirstIn")) {
            navigateTo(Screens.Main.ENTRANCE_CHOSEN)
        } else {
//            //设置语言
//            val list = DataFactory.createLanguageDataV2(resources)
//            var listStr = mutableListOf<String>()
//            listStr.add("en")
//            for (i in 1..list.size) {
//                if (list[i - 1].value.lowercase() != "en") {
//                    listStr.add(list[i - 1].value.lowercase())
//                }
//            }
//            //获取配置语言，然后设置系统语言，首语言默认英语
//            SerialportLibUtils.getAddLocale(listStr)
//
//            //设置键盘语言
//            SettingKeyBoardUtils.setTingKeyBoard(
//                this,
//                MmkvUtils.getString(CURRENT_LANGUAGE)?.lowercase() ?: "en"
//            )
            navigateTo(Screens.Setting.ANIMATION)
        }



        finish()
    }




    override fun createViewBinding(inflater: LayoutInflater): ActivityMainBinding {
        return ActivityMainBinding.inflate(layoutInflater)
    }
}