package com.gh.gamecenter.teenagermode

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.utils.updateStatusBarColor

class TeenagerModeActivity : BaseActivity() {

    private var mContainerFragment: Fragment? = null

    override fun getLayoutId() = R.layout.activity_amway

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        updateStatusBarColor(R.color.background_white, R.color.background_white)
        mContainerFragment = supportFragmentManager.findFragmentByTag(TeenagerModeFragment::class.java.name)
            ?: TeenagerModeFragment().with(intent.extras)
        if (mContainerFragment?.isAdded == false) {
            supportFragmentManager.beginTransaction()
                .replace(R.id.placeholder, mContainerFragment!!, TeenagerModeFragment::class.java.name)
                .commitAllowingStateLoss()
        }
    }

    override fun preventRecreateFragmentByFragmentManager(): Boolean = true

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

    companion object {

        const val TYPE = "type"
        const val TYPE_ENABLE = "enable"
        const val TYPE_DISABLE = "disable"
        const val TYPE_CHANGE_PWD = "change_pwd"

        @JvmStatic
        fun getIntent(context: Context): Intent {
            return Intent(context, TeenagerModeActivity::class.java)
        }
    }
}