简体   繁体   English

解析json数据时可以看到以前的选项卡组件-cn1

[英]Previous tab components are visible on parsing the json datas - cn1

There are a couple of tabs in a screen. 屏幕中有几个选项卡。 Each tab with its own connectionRequest. 每个选项卡都有其自己的connectionRequest。 But when any tab is selected, the components of the previous tab flashes before new tab components are seen. 但是,当选择任何选项卡时,上一个选项卡的组件会在看到新的选项卡组件之前闪烁。 How can I solve this. 我该如何解决。 Using addShowListener in each tab has its own issue. 在每个选项卡中使用addShowListener都有其自己的问题。 It shows blank screen. 它显示空白屏幕。 Please have a look at the video here 请在这里观看视频

Here if you go from home tab to service tab, service tab components are seen and it starts to parse the json data(loader is seen). 在这里,如果您从主页选项卡转到服务选项卡,则会看到服务选项卡组件,并且开始解析json数据(可见加载程序)。 Then the components from home screen is seen before the parsed data is shown in service tab component. 然后,在解析的数据显示在“服务”选项卡组件中之前,可以看到来自主屏幕的组件。

Tabs tabs = new Tabs(Component.BOTTOM);
tabs.addTab("Home", calendarIcon, homeContainer);
tabs.addTab("Book", calendarIcon3, quickBookingContainer);
tabs.addTab("Servicing", calendarIcon1, servicingContainer);
tabs.addTab("History", calendarIcon2, serviceHistoryContainer);

add(BorderLayout.CENTER, tabs);

tabs.addSelectionListener((int oldSelected, int newSelected) -> {
    if (newSelected == 0) {
        //connectionRequest for parsing json data
        homeContainerRequest(homeContainer, res);
    } else if (newSelected == 1) {
        quickBookingContainerRequest(quickBookingContainer, res);
    } else if (newSelected == 2) {
        serviceRequest(serviceContainer, res);
    } else if (newSelected == 3) {
        serviceHistoryRequest(serviceHistoryContainer, res);
    } 
});


public void homeContainerRequest(Container homeContainer, Resources res){
    ConnectionRequest con = new ConnectionRequest(url, false) {

        @Override
        protected void readResponse(InputStream input) throws IOException {
            JSONParser jp = new JSONParser();
            Map parser = jp.parseJSON(new InputStreamReader(input));
            _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
            _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
        }
    };
    con.setFailSilently(true);
    con.addRequestHeader("accept", "application/json");
    NetworkManager.getInstance().addToQueue(con);
}

public void quickBookingContainerRequest(Container quickBookingContainer, Resources res){
    ConnectionRequest con = new ConnectionRequest(url1, false) {

        @Override
        protected void readResponse(InputStream input) throws IOException {
            JSONParser jp = new JSONParser();
            Map parser = jp.parseJSON(new InputStreamReader(input));
            _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
            _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
        }
    };
    con.setFailSilently(true);
    con.addRequestHeader("accept", "application/json");
    NetworkManager.getInstance().addToQueue(con);
}

public void serviceHistoryRequest(Container serviceHistoryContainer, Resources res){
    ConnectionRequest con = new ConnectionRequest(url2, false) {

        @Override
        protected void readResponse(InputStream input) throws IOException {
            JSONParser jp = new JSONParser();
            Map parser = jp.parseJSON(new InputStreamReader(input));
            _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
            _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
        }
    };
    con.setFailSilently(true);
    con.addRequestHeader("accept", "application/json");
    NetworkManager.getInstance().addToQueue(con);
}

I'm guessing it relates to the animation and excessive repaint calls. 我猜它与动画和过多的重画调用有关。 Try using tabs.setAnimateTabSelection(false) . 尝试使用tabs.setAnimateTabSelection(false)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM