jeudi 28 mars 2019

How can solve this if clause problem in my project?

There is a project that I am doing, that search bus ticket beside two city and show it to user. It don't have problem when user searching ticket only go. There is also searching for going and return bus ticket. When it searching for going and return it happen problem. It don't show error message if going or return time is empty one of them.

I added code to check size of array that I get from web server. But after it that show if there is ticket in going time and don't show error for returning time(that doesn't have ticket). Also if going time don't have ticket and returning time has ticket. In that time It show returning time ticket in both screen. It should show error message in going time.

 else if (object.getString(MyConstants.SERVICE_STATUS).equals(MyConstants.SERVICE_RESPONSE_STATUS_SUCCESS)) {

                            JSONArray result = object.getJSONArray(MyConstants.SERVICE_RESULT);
                            if (result.length()>0) {
                                JSONArray resultGoing = result.getJSONObject(0).getJSONArray("going");
                                sendVoyagesArrayBroadcast(owner + MyConstants.DIRECTION_GOING, resultGoing);}
            /* if user choose going and return this part work*/                    if (has_return) {
                                    if (result.length() > 1) {
                                        JSONArray resultReturn = result.getJSONObject(1).getJSONArray("round");
                                        sendVoyagesArrayBroadcast(owner + MyConstants.DIRECTION_RETURN, resultReturn);
                                    }

                                }

                        } else if (object.getString(MyConstants.SERVICE_STATUS).equals(MyConstants.SERVICE_RESPONSE_STATUS_FAİLURE)) {

                            sendVoyagesErrorBroadcast(owner, MyConstants.ERROR_SERVER);
                        }

Aucun commentaire:

Enregistrer un commentaire