package com.gh.gamecenter

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.base.DownloadToolbarActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.updateStatusBarColor
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.game.GameFragment

/**
 * 板块
 */
class BlockActivity : DownloadToolbarActivity() {

    companion object {
        fun getIntent(context: Context,
                      blockData: SubjectRecommendEntity,
                      exposureSourceList: ArrayList<ExposureSource>? = null,
                      entrance: String): Intent {
            val args = Bundle()
            args.putParcelable(EntranceConsts.KEY_BLOCK_DATA, blockData)
            if (exposureSourceList != null) {
                args.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
            }
            args.putString(EntranceConsts.KEY_ENTRANCE, entrance)
            return getTargetIntent(context, BlockActivity::class.java, GameFragment::class.java, args)
        }
    }

    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 provideNormalIntent(): Intent {
        return getTargetIntent(this, BlockActivity::class.java, GameFragment::class.java, intent?.extras)
    }

    override fun showDownloadMenu(): Boolean {
        return true
    }

    override fun getActivityNameInChinese(): String {
        return "板块"
    }

    override fun getBusinessId(): Pair<String, String> {
        return Pair(
            targetFragment?.arguments?.getParcelable<SubjectRecommendEntity>(EntranceConsts.KEY_BLOCK_DATA)?.link ?: "",
            ""
        )
    }

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