package app.furmeet.events.brasilfurfest

import android.content.Intent
import android.os.Bundle
import app.furmeet.events.brasilfurfest.helper.resourcesAliased
import app.furmeet.events.brasilfurfest.notification.NotificationFirer
import app.furmeet.events.brasilfurfest.schedule.RoomPartyPreviewerActivity
import app.furmeet.events.brasilfurfest.schedule.managers.FullUpdateCheckerCancellable
import com.adlerosn.brasilfurfest.R

//Entry point
class MainActivity : TranslatableAppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        FullUpdateCheckerCancellable(baseContext).run { NotificationFirer().fire(baseContext) }
        resourcesAliased = this.resources
        when {
            (this.intent != null) && (this.intent?.data?.path?.startsWith("/app/roomparty")
                    ?: false) ->
                startActivity(Intent(this, RoomPartyPreviewerActivity::class.java).apply {
                    data = this@MainActivity.intent?.data
                    flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_TASK_ON_HOME
                })
            else ->
                startActivity(Intent(this, SplashActivity::class.java).apply {
                    flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_TASK_ON_HOME
                })
        }
        finish()
    }
}
