package com.blstream.studybox.activities;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class SplashScreenActivity extends AppCompatActivity {

    private static final int SPLASH_DISPLAY_LENGTH = 3000;
    private static Handler   splashHandler;
    private static Runnable  splashRunnable;
    private static boolean   splashRunning;

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

        if (null == splashHandler) {
            splashHandler = new Handler();
        }

        if (null == splashRunnable) {
            splashRunnable = initializeSplashRunnable(DecksActivity.class);
        }

        if (!splashRunning) {
            initializeSplashScreen(SPLASH_DISPLAY_LENGTH);
        }
    }

    private Runnable initializeSplashRunnable(final Class<?> destination) {
        return new Runnable() {
            @Override
            public void run() {
                Intent mainIntent = new Intent(SplashScreenActivity.this, destination);
                SplashScreenActivity.this.startActivity(mainIntent);
                SplashScreenActivity.this.finish();
            }
        };
    }

    private void initializeSplashScreen(int delay) {
        splashHandler.postDelayed(splashRunnable, delay);
        splashRunning = true;
    }

    @Override
    public void onBackPressed() {
        if (splashRunning) {
            splashHandler.removeCallbacks(splashRunnable);
            splashRunning = false;
        }

        super.onBackPressed();
    }
}

@@ -172,33 +172,8 @@
 dle;
-%0Aimport android.util.Log;
 %0A%0Apu
@@ -1411,24 +1411,25 @@
 rue;%0A    %7D%0A%0A
+%0A
     @Overrid
@@ -1439,32 +1439,28 @@
    p
-ublic void onBackPressed
+rotected void onStop
 () %7B
@@ -1548,32 +1548,99 @@
 nable);%0A        
+%7D%0A        splashHandler = null;%0A        splashRunnable = null;%0A    
     splashRunnin
@@ -1649,27 +1649,16 @@
 = false;
-%0A        %7D%0A
 %0A       
@@ -1670,19 +1670,12 @@
 r.on
-BackPressed
+Stop
 ();%0A

update to splash screen