package com.gh.gamecenter

import android.content.Intent
import com.gh.gamecenter.common.constant.EntranceConsts
import com.halo.assistant.fragment.WebFragment

class SingletonWebActivity : WebActivity() {

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)

        if (intent?.extras?.getString(EntranceConsts.KEY_URL)
            == targetFragment.arguments?.getString(EntranceConsts.KEY_URL)
        ) {
            // 同样的地址，不理会
        } else {
            if (targetFragment is WebFragment) {
                targetFragment.arguments?.putString(
                    EntranceConsts.KEY_URL, intent?.extras?.getString(
                        EntranceConsts.KEY_URL
                    )
                )
                (targetFragment as WebFragment).reload()
            }
        }
    }

    override fun provideNormalIntent(): Intent {
        return getTargetIntent(this, SingletonWebActivity::class.java, WebFragment::class.java)
    }

}