package com.renitha.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;

import com.renitha.Pref.Pref;
import com.renitha.R;

public class LauncherActivity extends AppCompatActivity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_launcher);
        new Handler().postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                Pref pref = Pref.getInstance(LauncherActivity.this);
                finish();
                if (pref.getIsLogin())
                {
                    if(pref.getLoginType().equals("Customer")) {
                        Intent intent = new Intent(LauncherActivity.this, ViewCustomerComplaints.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        overridePendingTransition(R.anim.enter, R.anim.exit);
                        startActivity(intent);
                    }
                    else if(pref.getLoginType().equals("User")) {
                        Intent intent = new Intent(LauncherActivity.this, ViewUserComplaints.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        overridePendingTransition(R.anim.enter, R.anim.exit);
                        startActivity(intent);
                    }
                }
                else
                {
                    Intent intent = new Intent(LauncherActivity.this, LoginTypeActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    overridePendingTransition(R.anim.enter, R.anim.exit);
                    startActivity(intent);
                }
            }
        }, 3000);
    }
}
