package w.soulofpluto.stockauditean;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;


 /*
  Create by Ramesh Babu
 */

public class SplashActivity extends AppCompatActivity{
    PreferenceManager preferenceManager;

    //5351
    //A123456

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState){
        setContentView(R.layout.activity_splash);
        preferenceManager = new PreferenceManager(this);
        //FirebaseApp.initializeApp(this);
        //FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
        runOnUiThread(this::splashMethod);
        super.onCreate(savedInstanceState);
    }

    public void splashMethod(){
        Handler handler = new Handler();
        Runnable runnable = () -> {
           if(preferenceManager.isLogged()){
              startActivity(new Intent(SplashActivity.this, HomeActivity.class));
              finish();
           }else{
              startActivity(new Intent(SplashActivity.this, Login.class));
              finish();
           }
        };
        handler.postDelayed(runnable, 2500);
    }
}
