I would like to check the user existence and return the result, however the onResponse() does not implement before returning the isUserExist, could anyone can advise how to fix? :)
// Check existence of email address
private boolean verifyEmail(String email) {
isUserExist = false;
loginURL = Uri.parse(loginURL).buildUpon()
.appendQueryParameter("email",email)
.build().toString();
GsonRequest<StaffUser> gsonRequest = new GsonRequest<StaffUser>(loginURL, StaffUser.class, null,
new Response.Listener<StaffUser>() {
@Override
public void onResponse(StaffUser response) {
if (response != null) {
Log.i(TAG, "staffUserId: " + response.getStaffUserId());
isUserExist = true;
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO: Handle error
Log.e(TAG, "VolleyError: " + error);
}
}
);
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(gsonRequest);
return isUserExist;
}