package com.example.projekta

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity

class SplashActivity : AppCompatActivity() {

    private val PREF_NAME = "LOGIN"
    private val KEY_LOGIN = "isLogin"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)

        Handler(Looper.getMainLooper()).postDelayed({

            val sharedPref = getSharedPreferences(PREF_NAME, MODE_PRIVATE)
            val isLogin = sharedPref.getBoolean(KEY_LOGIN, false)

            if (isLogin) {
                startActivity(Intent(this, MenuActivity::class.java))
            } else {
                startActivity(Intent(this, SignInActivity::class.java))
            }

            finish()

        }, 2000)
    }
}