package sysu.androidclub.campusrichman;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
/**.
* Activity.
* @author
* @version 0.0.1 2010-7-29
*/
public class GreetingScene extends Activity{
/** Called when the activity is first created. */
ImageView animationView;
AlphaAnimation mAlphaAnimation;
boolean mActivityFinished=false;
/**.
* .
* @author
* @version 0.0.1 2010-7-29
* 0.0.2 2010-8-19
* .
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mAlphaAnimation=new AlphaAnimation(255,0);
mAlphaAnimation.setDuration(3000);
animationView=new ImageView(this);
animationView.setBackgroundColor(Color.WHITE);
animationView.setImageResource(R.drawable.greetingscene);
animationView.setScaleType(ScaleType.FIT_CENTER);
//
final Timer timer = new Timer();
TimerTask task1 = new TimerTask(){
public void run() {
runOnUiThread(new Runnable(){
public void run() {
if (!mActivityFinished)
{
animationView.startAnimation(mAlphaAnimation);
animationView.setVisibility(4);
cancel();
}
}
});
}
};
TimerTask task2 = new TimerTask(){
public void run() {
runOnUiThread(new Runnable(){
public void run() {
if (!mActivityFinished)
{
mActivityFinished=true;
Intent intent=new Intent();
intent.setClass(GreetingScene.this,GameBeginScene.class);
startActivity(intent);
GreetingScene.this.finish();
cancel();
}
}
});
}
};
timer.schedule(task1,1000,1);
timer.schedule(task2,4000,1);
setContentView(animationView);
}
}
|