package com.bc_chat.account

import android.content.Intent
import com.bc_chat.account.task.SplashTask
import com.bc_chat.bc_base.entity.SplashAndAdImage
import com.bc_chat.bc_base.entity.SplashImage
import com.zhaohaoting.framework.abs.BaseNoActionBarActivity
import com.zhaohaoting.framework.abs.contract.BaseContract
import com.zhaohaoting.framework.requset.NetWorkCallBack

/**
 * author：Created by zhaohaoting on 2019/3/19
 * email：526309416@qq.com
 * desc：
 */
class SplashActivity : BaseNoActionBarActivity<BaseContract.BasePresenter>() {

    override fun initPresenter(): BaseContract.BasePresenter? = null

    override fun getLayoutResId(): Int = R.layout.activity_splash

    override fun onInit() {
        setLightMode(resources.getColor(R.color.transparent), false, true)
        taskHelper.execute<Any>(SplashTask(), object : NetWorkCallBack<SplashAndAdImage>() {
            override fun onPostExecuteFailure(task: Any, exception: Exception) {
                super.onPostExecuteFailure(task, exception)
                enterGuide(SplashAndAdImage())
            }

            override fun onPostExecuteSuccess(task: Any, splashImages: SplashAndAdImage?) {
                enterGuide(splashImages)
            }
        })
    }

    private fun enterGuide(splashImages: SplashAndAdImage?) {
        val intent = Intent(this, GuideActivity::class.java)
        intent.putExtra("splashImages", splashImages)
        startActivity(intent)
        finish()
    }
}