package com.gh.gamecenter.home.skip

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.GameEntity

class PackageSkipActivity : BaseActivity() {

    override fun getLayoutId(): Int = R.layout.activity_amway

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val containerFragment = supportFragmentManager.findFragmentByTag(PackageSkipFragment::class.java.name)
            ?: PackageSkipFragment().with(intent.extras)
        // 若 placeholder 外层为 RelativeLayout 的话，会出现莫名的偏移
        supportFragmentManager.beginTransaction()
            .replace(R.id.placeholder, containerFragment, PackageSkipFragment::class.java.name)
            .commitAllowingStateLoss()
        DisplayUtils.setStatusBarColor(this, R.color.transparent, !mIsDarkModeOn)
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        DisplayUtils.setStatusBarColor(this, R.color.transparent, !mIsDarkModeOn)
    }

    companion object {
        @JvmStatic
        fun getIntent(context: Context, games: List<GameEntity>): Intent {
            val intent = Intent(context, PackageSkipActivity::class.java)
            intent.putParcelableArrayListExtra(GameEntity::class.java.name, ArrayList(games))
            return intent
        }
    }
}