| Reply | « Previous Thread | Next Thread » |
|
I have an application which is big enough to take some time to load on older Nokia phones, load time is around 25 seconds, and instead of static loading screen I would like to have a progress bar displaying the load progress.
The situation is like this. There is a loading canvas screen, that is first shown. Then the loading of all other data starts. In the canvas class there is a timer thread that sleeps ~500ms and calls repaint and serviceRepaints [these get called properly]. However the screen is never repainted, and I suspect the problem is that main thread that is responsible for redraw events is loading classes and thus never repaints the screen.. How can it be implemented properly, I have seen ie. games that during initial load have a progress bar that shows the progress of the game loading... Sorry for the long description, and thanks for any help. |
|
Never mind this, it was just my silly mistake. it's working now
|
|
Hi Wedge_!
Could tou give me some ideas about creating and using that progress bar?? Thank you. |
|
basically, say you have a Canvas c, and a timer t, and a timertask tt:
tt: private void run(){ c.repaint(); } c: private int count = 0; protected void paint(Graphics g){ g.setColor(white); g.drawRect(5, getHeight() / 2 - 10, getWidth() - 10, 20); g.setColor(black); g.drawRect(5, getHeight() / 2 - 10, (getWidth - 10) * count / 100, 20) count++; } and in your midlet : Display.getDisplay(this).setCurrent(c); t.schedule(tt, 0, period); it will show a progress bar that will move by 1% every 'period' milisecond |
|
Basically my problem was that I wasn't allowing time for the screen to be shown, and it just showed 100% when game was loaded and immediately jumped to next (main menu) screen.
So what I did is in canvas of load screen I have a tiny tiny wait state before I start loading classes, this forces the canvas visible before starting the loading of classes. And when you want to update loading bar, remember to call serviceRepaints() after repaint to force repaint of canvas, no need to timers or anything there as the thread that loads all classes is the one requesting of update for progress bar and waits serviceRepaints() to complete before continuing class loading... Hope this helps |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|