×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    14

    Repainting progress bar (while loading app)

    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.

  2. #2
    Registered User
    Join Date
    Nov 2003
    Posts
    14
    Never mind this, it was just my silly mistake. it's working now

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    Re: Repainting progress bar (while loading app)

    Hi Wedge_!
    Could tou give me some ideas about creating and using that progress bar??

    Thank you.

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Repainting progress bar (while loading app)

    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

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    14

    Re: Repainting progress bar (while loading app)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •