package com.hh.arome.activity

import android.os.Handler
import android.os.Looper
import com.hh.arome.R
import com.hh.arome.utils.CommonUtils
import com.hh.lib_base.BaseApplication
import com.hh.lib_base.activity.BaseActivity
import com.hh.lib_base.manager.ActivityManager
import com.hh.lib_base.utils.ImageLoaderUtils
import com.hh.lib_base.utils.StringUtils
import com.hh.lib_common.local.AppLocalConfigHandler
import com.hh.lib_common.local.IAppLocalConfig
import kotlinx.android.synthetic.main.activity_splash.*

class SplashActivity : BaseActivity() {
    var localConfig: IAppLocalConfig? = null
    val mHandle:Handler = Handler(Looper.getMainLooper())
    override fun getLayoutId(): Int {
        return R.layout.activity_splash
    }

    override fun initView() {}
    override fun initData() {
        localConfig = AppLocalConfigHandler.create(applicationContext, IAppLocalConfig::class.java)
        val splashImageUrl = localConfig?.getSplashImageUrl("")
        if (StringUtils.isNotNull(splashImageUrl)) {
            ImageLoaderUtils.loadImage( splashImageUrl,iv_bg)
        }
        mHandle.removeCallbacksAndMessages(null)
        mHandle.postDelayed(Runnable {
            ActivityManager.keepMainActivity(MainActivity::class.java)
            startActivityAndFinish(MainActivity::class.java)
        },1000)
    }

    override fun initEvent() {}
}