package com.zztrapp.zztrapp.ui.mine.activity;

import android.content.Intent;
import android.os.Handler;
import android.view.View;

import com.zztrapp.zztrapp.base.BaseActivity;
import com.zztrapp.zztrapp.databinding.ActivitySplashBinding;
import com.zztrapp.zztrapp.ui.MainActivity;
import com.zztrapp.zztrapp.utilcode.util.SPUtils;

public class SplashActivity extends BaseActivity {

    private ActivitySplashBinding binding;

    @Override
    public View getLayoutId() {
        return binding.getRoot();
    }

    @Override
    protected void initBinding() {
        binding = ActivitySplashBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void init() {
        mImmersionBar.reset();
        mImmersionBar.fullScreen(true).init();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                new Handler().postDelayed(new Runnable() {
                    public void run() {//耗时操作
                        boolean isLogin = SPUtils.getInstance().getBoolean("isLogin", false);
                        if (isLogin) {
                            startActivity(new Intent(SplashActivity.this, MainActivity.class));
                            finish();
                            overridePendingTransition(0, 0);
                        } else {
                            SPUtils.getInstance().put("isLogin", false);
                            startActivity(new Intent(SplashActivity.this, LoginActivity.class));
                            finish();
                            overridePendingTransition(0, 0);
                        }
                    }
                }, 2000);

            }
        });
    }

    @Override
    protected void initOnClick() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        binding = null;
    }
}