package com.gh.gamecenter.personalhome.border

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.common.constant.EntranceConsts
import com.gh.gamecenter.R

/**
 * 头像挂件
 */
class AvatarBorderActivity : 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(AvatarBorderFragment::class.java.name)
            ?: AvatarBorderFragment().with(intent.extras)
        // 若 placeholder 外层为 RelativeLayout 的话，会出现莫名的偏移
        supportFragmentManager.beginTransaction()
            .replace(R.id.placeholder, containerFragment, AvatarBorderFragment::class.java.name)
            .commitAllowingStateLoss()
    }

    override fun isAutoResetViewBackgroundEnabled(): Boolean = true

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        DisplayUtils.setLightStatusBar(this, !mIsDarkModeOn)
    }

    companion object {
        fun getIntent(context: Context, categoryId: String? = null): Intent {
            return Intent(context, AvatarBorderActivity::class.java).apply {
                categoryId?.let {
                    putExtra(EntranceConsts.KEY_CATEGORY_ID, it)
                }
            }
        }
    }

}