package rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto

import android.app.Dialog
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import rowedto.jockeyedto.sheetedto.atticedto.Moneyedto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Atedto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Slantedto

abstract class Crossingedto<T : ViewBinding> : AppCompatActivity() {

    protected abstract val binding: T


    lateinit var launcher: Overalledto

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        launcher = Overalledto(this)
        setContentView(binding.root)

        Slantedto.event("page_${javaClass.simpleName}")
        Atedto.addActivity(this)
        initView()
        initListener()
    }

    protected abstract fun initView()

    protected open fun initListener() {}


    fun finishToMain() {
        if (this !is Moneyedto && !Atedto.isActivityInStack(Moneyedto::class.java)) {
            startActivity(Intent(this, Moneyedto::class.java))
        }
        finish()
    }

    var dialog: Dialog? = null
    override fun onDestroy() {
        super.onDestroy()
        Atedto.removeActivity(this)
        if (dialog != null) {
            dialog?.dismiss()
            dialog = null
        }
    }

}