【发布时间】:2017-05-23 11:36:30
【问题描述】:
我在 postResponse 中调用了“new NewForm(res).show()”,但尽管连接成功,但看不到特定的表单。我发现如果我注释掉'cr.setDisposeOnCompletion(d)',那么它工作正常。 但是如果发生任何异常等等,无限的进展就会无限运行。这是一个错误吗?它发生在我更新到新的 cn1 库更新之后。如果你想看这个项目,它在这里: https://drive.google.com/file/d/0B8ATnICIY2S8LUdta0F5NXYzamM/view?usp=sharing
Button checkButton = new Button("Check");
checkButton.addActionListener(e -> {
ConnectionCheck cc = new ConnectionCheck(theme);
cc.connectionCheckMethod();
});
ConnectionCheck 类
public class ConnectionCheck {
Resources res;
Dialog d;
public ConnectionCheck(Resources res) {
this.res = res;
}
public void connectionCheckMethod() {
ConnectionRequest cr = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jsonp = new JSONParser();
Map<String, Object> parser = jsonp.parseJSON(new InputStreamReader(input));
System.out.println("bibek " + parser);
}
@Override
protected void postResponse() {
new NewForm(res).show();
// d.dispose();
}
@Override
protected void handleErrorResponseCode(int code, String message) {
System.out.println("login ErrorResponseCode " + code + "msg: " + message);
// d.dispose();
}
@Override
protected void handleException(Exception err) {
System.out.println("login Exception " + err);
// d.dispose();
}
@Override
protected void handleIOException(IOException err) {
System.out.println("login IOException " + err);
// d.dispose();
}
@Override
protected void handleRuntimeException(RuntimeException err) {
System.out.println("login RuntimeException " + err);
// d.dispose();
}
};
cr.setPost(true);
cr.setUrl("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo");
cr.setTimeout(30000);
cr.addRequestHeader("Accept", "application/json");
InfiniteProgress ip = new InfiniteProgress();
d = ip.showInifiniteBlocking();
cr.setDisposeOnCompletion(d); //if this line is commented, the newForm is shown
NetworkManager.getInstance().addToQueueAndWait(cr);
}
}
NewForm 类
public class NewForm extends Form{
public NewForm(Resources res){
setTitle("new Form");
add(new Label("new Form"));
}
}
【问题讨论】:
标签: codenameone