How to display a "wait screen"?

6 messages - 1655 views

Hello,

 

I would like to know if there is any way to display a message to show to the user that the phone is processing or waiting for data?

 

I tried the following code in my frame

public boolean onMessage(Object identifier, Object[] arguments) {
    if("search".equals(identifier)) {
        Kuix.alert("Please wait");
        String s = (String) arguments[0];
        productSearch.search(s);
        return false;
    }
    return true;
}

But it seems that Kuix waits the end of the onMessage function to change the screen.

 

Do I do something wrong?

Try:

Kuix.alert("...");

Kuix.getCanvas().revalidateAsSoonAsPossible();

...

if you're doing any lengthy operation, you should be doing it on a secondary thread, and not locking the UI/event thread the way you are in your example.

here's one way to do it, which shows an alert that the user cannot close until the threaded operation is finished, when it closes itself:

Popup pop = Kuix.showPopupBox(null, -1, "searching...", null, null, null, null, null);

new Thread(new Runnable() {

    public void run() {

        /** your search that may take a few seconds **/

        pop.remove();

    }

}).start();

 

Yes, I'd agree. BTW just to avoid confusion, I assume pandora meant "final PopupBox pop ...".

Thank you for your replies.

I tried both solutions and both work great. But I would like to know which one I should use. Does it depends on something particulary? The first solution seems to be more readable. What is the advantage to choose the second solution knowing that I am waiting for data (I mean I am not processing data, I am just waiting for the server response).

Thank you!

there are two problems with the first solution:

1) the user can press "ok" of the alert and close it, even though the search is still waiting for response

2) it doesn't run the time-intensive search on a secondary thread, locking all operations on the UI and potentially crashing the entire application

it's very important to do things like network calls, RMS activity, etc on a secondary thread, on some phones it will lock the entire application hard if you don't.  i know my solution is a little less readable, but it is more appropriate for your particular case