package org.azavea.otm.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.webkit.WebView;

import org.azavea.otm.R;

public class SplashScreenActivity extends Activity {
	//http://mobituts.blogspot.com/2011/10/example-of-splash-screen-in-android.html
	private static final int STOP_SPLASH = 0;     
	private static final long SPLASH_TIME_MILLIS = 2000;  
  
    private Handler splashHandler = new Handler() {  
         @Override  
         public void handleMessage(Message msg) {  
              switch (msg.what) {  
                case STOP_SPLASH:  
                    Intent intent = new Intent(getApplicationContext(),   
                                            	TabLayout.class);  
                    startActivity(intent);  
                        SplashScreenActivity.this.finish();   
                    break;  
              }  
              super.handleMessage(msg);  
         }  
    };  
      
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_splash_screen);
        WebView wv = (WebView) findViewById(R.id.splash_webview);
        wv.loadUrl("file:///android_asset/splash_content.html");
        Message msg = new Message();  
        msg.what = STOP_SPLASH;  
        splashHandler.sendMessageDelayed(msg, SPLASH_TIME_MILLIS);  
    }  
}  

@@ -276,255 +276,66 @@
 y %7B%0A
-%09//http://mobituts.blogspot.com/2011/10/example-of-splash-screen-in-android.html%0A%09private static final int STOP_SPLASH = 0;     %0A%09private static final long SPLASH_TIME_MILLIS = 2000;  %0A  %0A    private Handler splashHandler = new Handler() %7B  %0A     
+    private static final long SPLASH_TIME_MILLIS = 2000;%0A%0A
     
@@ -343,24 +343,17 @@
 Override
-  %0A     
+%0A
     publ
@@ -364,481 +364,442 @@
 oid 
-handleMessage(Message msg) %7B  %0A              switch (msg.what) %7B  %0A                case STOP_SPLASH:  %0A                    Intent intent = new Intent(getApplicationContext(),   %0A                                            %09TabLayout.class);  %0A                    startActivity(intent);  %0A                        S
+onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A%0A        // render the splash screen%0A        setContentView(R.layout.activity_splash_screen);%0A        WebView wv = (WebView) findViewById(R.id.splash_webview);%0A        wv.loadUrl(%22file:///android_asset/splash_content.html%22);%0A%0A        // transition away from s
 plash
-S
+ s
 creen
-Activity.this.finish();   %0A                    break;  %0A              %7D  %0A              super.handleMessage(msg);  %0A         %7D  
+ when time elapses%0A        Handler splashDestroyer = new Handler() %7B
 %0A    
-%7D;
   
-%0A
       
-%0A    
 @Ove
@@ -803,19 +803,25 @@
 Override
+%0A
   
-%0A
+      
     publ
@@ -832,47 +832,36 @@
 oid 
-onCreate(Bundle savedInstanceState
+handleMessage(Message msg
 ) %7B
-  
 %0A   
@@ -869,111 +869,124 @@
     
-super.onCreate(savedInstanceState);  %0A        setContentView(R.layout.activity_splash_screen
+        App app = App.getAppInstance();%0A%0A                Intent intent = new Intent(app, TabLayout.class
 );%0A
+%0A
         
 WebV
@@ -985,203 +985,89 @@
     
-WebView wv = (WebView) findViewById(R.id.splash_webview);%0A        wv.loadUrl(%22file:///android_asset/splash_content.html%22);%0A        Message msg = new Message();  %0A        msg.what = STOP_SPLASH;  
+        startActivity(intent);%0A                finish();%0A            %7D%0A        %7D;
 %0A   
@@ -1077,21 +1077,23 @@
   splash
-Handl
+Destroy
 er.sendM
@@ -1110,12 +1110,68 @@
 yed(
-msg,
+Message.obtain(),%0A                                          
  SPL
@@ -1191,18 +1191,14 @@
 IS);
-  
 %0A    %7D
-  
 %0A%7D  

Clean up SplashScreenActivity