InfiniteProgress not showing in simulator or on android

28 views
Skip to first unread message

howud...@gmail.com

unread,
Jun 29, 2016, 7:25:04 PM6/29/16
to CodenameOne Discussions
the below code (using slow network connection) makes the simulator and android tablet dim, but the spinner never shows

        public void onbtnLoginCommand(com.codename1.ui.events.ActionEvent ev, Command cmd) {
// show a wait dialog
InfiniteProgress prog = new InfiniteProgress();
Dialog dlg = prog.showInifiniteBlocking();
dlg.setTitle("Logging On");
login();

dlg.dispose();
}

protected void login() {
ConnectionRequest r = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
json = new JSONParser().parseJSON(new InputStreamReader(input));
}
@Override
protected void postResponse() {
MessageBox.OK("yay", "it worked");
}
};
r.setUrl(GLOBALS.BASEURL + "/validateLogin");
r.setPost(true);
r.addArgument("user", gui_Text_Field_UserName.getText());
r.addArgument("password", gui_Text_Field_Password.getText());
NetworkManager.getInstance().addToQueueAndWait(r);
}
protected void loadCurrentActivity() {
ConnectionRequest r = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
// parse it
}
@Override
protected void postResponse() {
//display it
}
};
r.setUrl(GLOBALS.BASEURL + "/getCurrentActivity");
r.setPost(true);
r.addArgument("hash", GLOBALS.employee.getPassword());
NetworkManager.getInstance().addToQueueAndWait(r);
}
protected void loadStats() {
ConnectionRequest r = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
// parse it
}
@Override
protected void postResponse() {
//display it
}
};
r.setUrl(GLOBALS.BASEURL + "/getStats");
r.setPost(true);
r.addArgument("hash", GLOBALS.employee.getPassword());
NetworkManager.getInstance().addToQueueAndWait(r);
}

Also if I need to then do a sequence of network calls, what is the best way to handle that?  onbtnLoginCommand is in the EDT as is postResponse().  do I just chain them all together in subsequent readResponse()?  Where do I call loadCurrentActivity and loadStats()?

Shai Almog

unread,
Jun 30, 2016, 12:07:12 AM6/30/16
to CodenameOne Discussions, howud...@gmail.com
Are you using a blank theme?
If so you need to define the infinite progress image.

This varies and is somewhat tricky since you also need to dispose this on error

Peter Carlson

unread,
Jun 30, 2016, 12:11:45 AM6/30/16
to Shai Almog, CodenameOne Discussions

No,  I am using the business green and tan theme

Shai Almog

unread,
Jul 1, 2016, 12:59:52 AM7/1/16
to CodenameOne Discussions, shai....@gmail.com, howud...@gmail.com
You didn't disable the includeNativeBool flag in that theme right?
Did you set the infiniteImage theme constant to something?

howud...@gmail.com

unread,
Jul 4, 2016, 10:52:43 AM7/4/16
to CodenameOne Discussions, shai....@gmail.com, howud...@gmail.com
This is easily reproduced:
new project
theme:business
template: hello world (bare bones)
add the following code to start()
        com.codename1.ui.Button gui_Button_1 = new com.codename1.ui.Button();
        hi.addComponent(gui_Button_1);
com.codename1.ui.Command cmd_btnLogin = new com.codename1.ui.Command("Login") {
public void actionPerformed(com.codename1.ui.events.ActionEvent ev) {
onbtnLoginCommand(ev, this);
}
};
gui_Button_1.setCommand(cmd_btnLogin);


add the following function:
public void onbtnLoginCommand(com.codename1.ui.events.ActionEvent ev, Command cmd) {
// show a wait dialog
InfiniteProgress prog = new InfiniteProgress();
Dialog dlg = prog.showInifiniteBlocking();
dlg.setTitle("Logging On");
// dlg.dispose();
}


Run in simulator = no image

Shai Almog

unread,
Jul 5, 2016, 12:37:36 AM7/5/16
to CodenameOne Discussions, shai....@gmail.com, howud...@gmail.com
Your sample opens the progress dialog and closes it immediately without letting it show. The progress dialog is not modal and doesn't block the execution thread.

howud...@gmail.com

unread,
Jul 5, 2016, 11:31:59 AM7/5/16
to CodenameOne Discussions, shai....@gmail.com, howud...@gmail.com
I quite disagree with you.  the dialog is shown, and since I dont call dispose, the dialog continues to show, it just doesn't show the spinner.  dispose is commented out

Shai Almog

unread,
Jul 6, 2016, 1:27:13 AM7/6/16
to CodenameOne Discussions, shai....@gmail.com, howud...@gmail.com
Sorry didn't see the comment out section.
It's because of the setTitle() call. It messes up the height calculations for the dialog.
Reply all
Reply to author
Forward
0 new messages