package com.zxbw.modulemain.activity

import android.text.TextUtils
import android.util.Log
import android.view.View
import com.umeng.analytics.MobclickAgent
import com.zx.ad.AdManager
import com.zx.ad.callback.SplashAdListener
import com.zxbw.modulemain.R
import com.zxbw.modulemain.contract.SplashContract
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.router.RounterApi
import com.zxhl.cms.router.RounterBus
import com.zxhl.cms.utils.JumpUtils
import kotlinx.android.synthetic.main.activity_splash.*

class SplashBackgroundActivity: BaseActivity() {

    override fun onClick(v: View?) {
    }

    override fun layoutID(): Int = R.layout.activity_layout_splash_backound

    private var mPresenter: SplashContract.Presenter? = null


    override fun init() {

            initSplashAd()


    }

    private fun initSplashAd() {

        AdManager.loadSplashAd(this,id_splash_view,object : SplashAdListener {
            override fun onAdShow() {

            }

            override fun onAdSkip() {
                finish()
            }

            override fun onError(errorMsg: String?) {
                jumpMainPage()
            }
        })
    }

     fun jumpMainPage() {
        val user = SettingPreference.getUserInfoData()
        val token = SettingPreference.getUserToken()
        if (user == null && TextUtils.isEmpty(token)) {
            JumpUtils.loginJump()
        } else {
            JumpUtils.activityJump(
                RounterBus.getRounter(RounterApi::class.java).getIntentActivityMain()
            )
        }
        finish()
    }




}