package com.naijab.nextzytimeline.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.naijab.nextzytimeline.R;
import com.naijab.nextzytimeline.base.BaseMvpActivity;
import com.naijab.nextzytimeline.ui.main.MainActivity;

public class SplashScreenActivity extends BaseMvpActivity<SplashScreenActivityInterface.Presenter>
        implements SplashScreenActivityInterface.View {

    private static final long DELAY_TIME = 1000;

    @Override
    public SplashScreenActivityInterface.Presenter createPresenter() {
        return SplashScreenActivityPresenter.create();
    }

    @Override
    public int getLayoutView() {
        return R.layout.splash_screen;
    }

    @Override
    public void bindView() {
    }

    @Override
    public void setupInstance() {
        goToMainActivity();
    }

    @Override
    public void setupView() {
    }

    @Override
    public void initialize() {
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
    }

    // TODO rannable ==> rannable
    private void delayHandler(Runnable rannable) {
        Handler handler = new Handler();
        handler.postDelayed(rannable, DELAY_TIME);
    }

    private void goToMainActivity() {
        // TODO When user has minimize the application before this code was called.
        // TODO It will force the device to open MainActivity. That's annoyed to user
        delayHandler(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
                overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
            }
        });
    }
}


@@ -436,43 +436,113 @@
 ate 
-static final long DELAY_TIME
+Handler handler;%0A    private Runnable runnable;%0A    private long delayTime;%0A    private long time
  = 1000
+L
 ;%0A%0A 
@@ -1294,421 +1294,99 @@
  %7D%0A%0A
-    // TODO rannable ==%3E rannable%0A    private void delayHandler(Runnable rannable) %7B%0A        Handler handler = new Handler();%0A        handler.postDelayed(rannable, DELAY_TIME);%0A    %7D%0A%0A    private void goToMainActivity() %7B%0A        // TODO When user has minimize the application before this code was called.%0A        // TODO It will force the device to open MainActivity. That's annoyed to user%0A        delayHandler(
+%0A    private void goToMainActivity() %7B%0A        handler = new Handler();%0A        runnable = 
 new 
@@ -1402,30 +1402,8 @@
 ) %7B%0A
-            @Override%0A
     
@@ -1685,16 +1685,377 @@
        %7D
+;%0A    %7D%0A%0A    @Override%0A    public void onResume() %7B%0A        super.onResume();%0A        delayTime = time;%0A        handler.postDelayed(runnable, delayTime);%0A        time = System.currentTimeMillis();%0A    %7D%0A%0A    public void onPause() %7B%0A        super.onPause();%0A        handler.removeCallbacks(runnable);%0A        time = delayTime - (System.currentTimeMillis() - time
 );%0A    %7D

Edit delay time