package com.ael;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import java.util.Timer;
import java.util.TimerTask;
public class SplashScreen extends Canvas
{
private Display display;
private Displayable next;
private Timer timer = new Timer();
private int delay;
public SplashScreen(Display display, Displayable next, int delay)
{
this.display = display;
this.next = next;
this.delay = delay;
display.setCurrent( this );
}
protected void keyPressed( int keyCode )
{
dismiss();
}
protected void paint( Graphics g )
{
Image image = Utilities.getSplashScreen();
setFullScreenMode(true);
Image thumbnail = Utilities.getAdjustedImage(image, getWidth(), getHeight());
g.drawImage(thumbnail, 0, 0, 0);
}
protected void pointerPressed( int x, int y )
{
dismiss();
}
// called automatically when the Canvas is put on screen
protected void showNotify()
{
// CountDown started after delay secs
timer.schedule( new CountDown(), delay );
}
private void dismiss()
{
timer.cancel();
display.setCurrent( next );
}
private class CountDown extends TimerTask
{
public void run(){
dismiss();
}
}
}