/*
* Android Mobile Physical Therapy Exercise Documenter
* Copyright (C) 2010 http://www.amptedapp.com/
* 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 com.AMPTedApp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
/**
* The SplashScreen that is displayed when the application launches.
*
* @author Jared Hatfield
*/
public class SplashScreen extends Activity {
/**
* A flag to indicate the flash screen should close.
*/
protected boolean display = true;
/**
* The amount of time the splash screen should be displayed.
*/
protected int timer = 5000;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
// SplashScreen thread
Thread splashTread = new Thread() {
/**
* Wait to remove
*/
@Override
public void run() {
try {
int waited = 0;
while (display && (waited < timer)) {
sleep(100);
if (display) {
waited += 100;
}
}
} catch (InterruptedException e) {
// If something bad happened, it is not important.
} finally {
// Close the SplashScreen Activity
finish();
// Launch the main activity
startActivity(new Intent("com.AMPTedApp.AMPTed"));
// We stop the thread by falling off the end
}
}
};
splashTread.start();
}
/**
* If a touch is detected, close the splash screen.
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
display = false;
}
return true;
}
}
|