package com.gh.gamecenter.savegame

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.gh.common.util.NewFlatLogUtils
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.utils.updateStatusBarColor
import com.therouter.router.Route

@Route(
    path = RouteConsts.activity.gameArchiveListActivity,
    description = "游戏存档"
)
class GameArchiveListActivity : BaseActivity_TabLayout() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setNavigationTitle("游戏存档")
        mDividerLineView?.visibility = View.VISIBLE
        updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
    }

    override fun initFragmentList(fragments: MutableList<Fragment>?) {
        fragments?.add(GameArchiveListInstalledFragment())
        fragments?.add(GameArchiveListRecommendFragment())
    }

    override fun initTabTitleList(tabTitleList: MutableList<String>?) {
        tabTitleList?.add("在玩")
        tabTitleList?.add("推荐游戏")
    }

    override fun onPageSelected(position: Int) {
        super.onPageSelected(position)
        NewFlatLogUtils.logGameArchivePageShow(if (position == 0) "已安装游戏" else "推荐游戏")
        SensorsBridge.trackEvent("CloudSaveGameTopicTabSelected", "tab_name", if (position == 0) "已安装游戏" else "推荐游戏")
    }

    override fun isAutoResetViewBackgroundEnabled() = true

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
    }

    companion object {
        @JvmStatic
        fun getIntent(context: Context): Intent {
            return Intent(context, GameArchiveListActivity::class.java)
        }
    }

}