jeudi 11 avril 2019

How to compare two values with if statement in android

i try to compare two values with in if statement when one value get from server using retrofit and another value get from another fragment, if Toast is used outer if statement then show both variable values but if i try to compare those value into if statement it is not working. Both values are same but compiler go to else part, what i do

public void getUserProfileData() {
    progressBar.setVisibility(View.VISIBLE);
    Api.getClient().getUserProfile(MainActivity.userId, new Callback<UserProfileResponse>() {
                @Override
                public void success(UserProfileResponse userProfileResponse, Response response) {
                    progressBar.setVisibility(View.GONE);
                    userEmail=userProfileResponse.getEmail();
                    String s = "";
                    if (!userProfileResponse.getLandmark().equalsIgnoreCase("")) {
                        s = ", " + userProfileResponse.getLandmark();
                    }
                    if (userProfileResponse.getFlat().equalsIgnoreCase("")) {
                        addressCheckBox.setChecked(false);
                        addressCheckBox.setVisibility(View.GONE);
                        fillAddress.setVisibility(View.VISIBLE);
                    }else {
                        address = userProfileResponse.getName()
                                + ", "
                                + userProfileResponse.getFlat()
                                + s
                                + ", " + userProfileResponse.getLocality()
                                + ", " + userProfileResponse.getCity()
                                + ", " + userProfileResponse.getState()
                                + ", " + userProfileResponse.getPincode()
                                + "\n" + userProfileResponse.getMobile();
                        addressCheckBox.setText(address);
                        mobileNo = userProfileResponse.getMobile();
                        pinCompare = userProfileResponse.getPincode();


                        //Toast.makeText(getActivity(), pincode + pinCompare, Toast.LENGTH_SHORT).show();


                        if ( !(pincode ==null) && !(pincode ==null)){
                            if(pincode.equals(pinCompare)){           //is it correct code?
                                Toast.makeText(getActivity(), pincode + pinCompare, Toast.LENGTH_SHORT).show();
                            }else {
                                Toast.makeText(getActivity(), "failed", Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                }

Aucun commentaire:

Enregistrer un commentaire