package com.gh.gamecenter.category

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.entity.CategoryEntity

class CategoryListActivity : DownloadToolbarActivity() {

    companion object {
        fun getIntent(context: Context, categoryTitle: String, category: CategoryEntity, initTitle: String): Intent {
            val bundle = Bundle()
            if (category.data!!.isEmpty() || category.data!![0].name != "全部") {
                val plainCategory = CategoryEntity(id = category.id, name = "全部")
                ((category.data) as ArrayList).add(0, plainCategory)
            }
            bundle.putParcelable(EntranceConsts.KEY_DATA, category)
            bundle.putString(EntranceConsts.KEY_NAME, category.name)
            bundle.putString(EntranceConsts.KEY_CATEGORY_TITLE, categoryTitle)
            bundle.putString(EntranceConsts.KEY_CATEGORY_INIT_TITLE, initTitle)
            return getTargetIntent(
                context,
                CategoryListActivity::class.java,
                NewCategoryListFragment::class.java,
                bundle
            )
        }
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setToolbarMenu(R.menu.menu_download)
        updateStatusBarColor(R.color.background_white, R.color.background_white)
    }

    override fun showDownloadMenu(): Boolean {
        return true
    }

    override fun getActivityNameInChinese(): String {
        return "游戏分类详情"
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        updateStatusBarColor(R.color.background_white, R.color.background_white)
    }
}