view src/uk/ac/qmul/eecs/ccmi/activities/CcmiSplashActivity.java @ 0:e0ee6ac3a45f

first import
author Fiore Martin <fiore@eecs.qmul.ac.uk>
date Thu, 13 Dec 2012 20:00:21 +0000
parents
children
line wrap: on
line source
/*  
 CCmI Diagram Editor for Android 
  
 Copyright (C) 2012  Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package uk.ac.qmul.eecs.ccmi.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * Splash screen Activity. Shows the splash screen for {@code SPLASH_DELAY} millisecond 
 * and then starts the main Activity 
 */
public class CcmiSplashActivity extends Activity {
	/**
	 * number of millisecond the splash is displayed before starting the main Activity 
	 */
	public static final int SPLASH_DELAY = 2000;
	private long ms=0;
	private boolean splashActive = true;
	private boolean paused=false;
	
	/** Called when the activity is first created. */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_screen);
		Thread t = new Thread() {
			@Override
			public void run() {
				try {
					while (splashActive && ms < SPLASH_DELAY) {
						if(!paused)
							ms=ms+100;
						sleep(100);
					}
				} catch(Exception e) {e.printStackTrace();}
				finally {
					Intent intent = new Intent(CcmiSplashActivity.this, CcmiEditorAppActivity.class);
					startActivity(intent);
					finish();
				}
			}
		};
		t.start();
	}
	
	/**
	 * Pressing the back button on the splash screen doesn't kill the activity. The user must wait for the 
	 * main activity to be displayed before exiting the application. 
	 */
	@Override
	public void onBackPressed() {}
}