package com.gh.gamecenter.servers

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.base.DownloadToolbarActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.updateStatusBarColor
import com.gh.gamecenter.feature.exposure.ExposureEvent

class GameServerTestActivity : DownloadToolbarActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setToolbarMenu(R.menu.menu_download)
        updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
    }

    override fun showDownloadMenu() = true

    override fun provideNormalIntent(): Intent {
        return getTargetIntent(this, GameServerTestActivity::class.java, GameServersTestFragment::class.java)
    }

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

    companion object {
        fun getIntent(context: Context, id: String, title: String, entrance: String, traceEvent: ExposureEvent?): Intent {
            val bundle = Bundle()
            bundle.putString(GameServersTestFragment.TEST_COLUMN_ID, id)
            bundle.putString(GameServersTestFragment.TEST_TITLE, title)
            bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
            traceEvent?.source?.let {
                if (it is ArrayList) {
                    bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, it)
                } else {
                    bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, ArrayList(it))
                }
            }

            return getTargetIntent(
                context,
                GameServerTestActivity::class.java,
                GameServersTestFragment::class.java,
                bundle
            )
        }
    }

}