地图& connectionRequest问题无限进展

时间:2018-01-08 04:06:01

标签: codenameone

我在表单中有一个地图组件,用于显示用户的位置。单击提交按钮时,所有信息都将发送到服务器。但是,如果我在连接方法中保持无限进展,则不显示,地图消失,只有黑色透明层覆盖屏幕。我该如何解决?但是如果在多部分代码中注释了无限的进展,它就可以工作。 (PS。我已在Android设备上测试过它)

视频: https://www.youtube.com/watch?v=jBCji4rq-4I

public CheckIn(Resources res) throws IOException {
    super(new BorderLayout());
    setScrollableY(true);

    selectDialog = new Container();
    selectDialog.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    selectDialog.setScrollableY(true);
    add(BorderLayout.CENTER, selectDialog);

    Label nameLabel = new Label("Name");
    Label timeLabel = new Label("Time");
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    selectDialog.add(nameLabel);
    selectDialog.add(timeLabel);

    //map container
    cnt = new MapContainer();
    cnt.setCameraPosition(new Coord(lat, lng));
    cnt.addMarker(
            EncodedImage.createFromImage(markerImg, false),
            new Coord(lat, lng),
            "marker",
            "Optional long description",
            evt -> {
                ToastBar.showMessage("You clicked the marker", FontImage.MATERIAL_PLACE);
            }
    );
    cnt.zoom(new Coord(lat, lng), 15);
    selectDialog.add( cnt);

    Button submitButton = new Button("Submit");
    submitButton.addActionListener(g -> {
        acc.uploadConnection("225", "17", "in", null, res, selectedOutles, selfiePath, lat + "", lng + "");
    }
}

uploadConnection:

public void uploadConnection(String userId, String outletId, String checkType, Dialog selectDialogg, Resources res, String selectedOutles, String picture,
        String lat, String lng) {
    MultipartRequest request = new MultipartRequest() {
        @Override
        protected void readResponse(InputStream input) throws IOException {
            JSONParser jp = new JSONParser();
            Map<String, Object> parser = jp.parseJSON(new InputStreamReader(input, "UTF-8"));
            System.out.println("parser " + parser);

            msg = (String) parser.get("message");
            statusCheck = (String) parser.get("status");
        }

        @Override
        protected void postResponse() {
            if(d != null){
                d.dispose();
            }
            if (statusCheck.equals("true")) {
                Preferences.set("SelectedShop", selectedOutles);
                Preferences.set("SelectedId", outletId);\
                Dialog.show("Warning", msg + " ", "ok", null);\
            } else {
                Dialog.show("Warning", msg + " ", "ok", null);\
            }
            if (checkType.equals("out")) {
                Preferences.delete("SelectedShop");
            }
        }

        @Override
        protected void handleErrorResponseCode(int code, String message) {
            System.out.println("login ErrorResponseCode " + code + "msg: " + message);
        }

        @Override
        protected void handleException(Exception err) {
            System.out.println("login Exception " + err);
        }

        @Override
        protected void handleIOException(IOException err) {
            System.out.println("login IOExceptionnn " + err);
            Dialog.show("Warning", "Check your network connection", "ok", null);
        }

        @Override
        protected void handleRuntimeException(RuntimeException err) {
            System.out.println("login RuntimeException " + err);
        }

    };
    request.setUrl(AllUrls.attendenceCheckUrl);
    request.setPost(true);
    request.setTimeout(80000);
    request.addArgument("userId", userId);
    request.addArgument("outletId", outletId);
    request.addArgument("checkType", checkType);
    if (lat == null) {
        request.addArgument("lat", "");
        request.addArgument("long", "");
    } else {
        request.addArgument("lat", lat);
        request.addArgument("long", lng);
    }
    if (picture != null && !picture.equals("")) {
        try {
            request.addData("image", picture, "image/jpeg");
            request.setFilename("image", "myPicture.jpg");
        } catch (IOException err) {
            System.out.println("bibek " + err);
        }
    }
    request.addRequestHeader("Accept", "application/json");
    InfiniteProgress ip = new InfiniteProgress();
    d = ip.showInifiniteBlocking();
    request.setDisposeOnCompletion(d);
    NetworkManager.getInstance().addToQueue(request);
}

1 个答案:

答案 0 :(得分:0)

无限进展是一个Dialog,在我们的z-order更新特别是原生地图非常糟糕之后,他们不会像对等组件那样顺利地行事(在我们的辩护中,这在以前任何一个都不是很好)。

我建议只对整个用户界面进行着色,例如:

getLayeredPane().getUnselectedStyle().setBgColor(0); 
getLayeredPane().getUnselectedStyle().setBgTransparency(120); 

您只需将无限进度组件放入分层窗格即可创建相同的效果。