package com.gh.gamecenter.gamecollection.square

import android.os.Bundle
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.common.util.GameCollectionSquareBrowseTaskHelper
import com.gh.gamecenter.R

class GameCollectionSquareActivity : BaseActivity() {
    override fun getLayoutId(): Int {
        return R.layout.activity_amway
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        DisplayUtils.transparentStatusBar(this)

        val containerFragment = supportFragmentManager.findFragmentByTag(
            GameCollectionSquareFragment::class.java.name
        )
            ?: GameCollectionSquareFragment().with(intent.extras)
        supportFragmentManager.beginTransaction()
            .replace(R.id.placeholder, containerFragment, GameCollectionSquareFragment::class.java.name)
            .commitAllowingStateLoss()
    }

    override fun finish() {
        GameCollectionSquareBrowseTaskHelper.run {
            if (intent.getBooleanExtra(KEY_IS_FORM_BROWSE_TASK, false)) {
                disableBrowseTimeCount()
                unregisterActivityLifecycleCallbacks()
            }
        }
        super.finish()
    }
}