I have a registration screen, which compares the edittext text with the bank field, and this comparison is working normally.
What I would like to do is that if there was already the email field in the bank, the activity does not proceed.
Code:
mEmail = email.getText().toString();
new getUser().execute();
btnfincad.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (("".equals(email.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
} else if (("".equals(password.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
} else if (("".equals(nick.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
} else if (("".equals(number.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
} else if (("".equals(sexo.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
} else if (("".equals(data.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
} else if (("".equals(number.getText().toString().trim()))) {
Toast.makeText(PostCadastro.this, "Nenhum campo pode ser nulo !", Toast.LENGTH_LONG).show();
return;
}
mName = name.getText().toString();
mNick = nick.getText().toString();
mPassword = password.getText().toString();
mNumber = number.getText().toString();
mSexo = sexo.getText().toString();
mData = data.getText().toString();
mEmail = email.getText().toString();
My return
that does not work correctly is this:
protected void onPostExecute(final String result) {
super.onPostExecute(result);
try {
JSONObject json = new JSONObject(result);
JSONArray array = new JSONArray(json.getString("resource"));
for (int i = 0; i < array.length(); i++) {
JSONObject jsonObj = array.getJSONObject(i);
String email = jsonObj.getString("tx_email");
System.out.println(email);
if (mEmail.equals(email)) {
Toast.makeText(PostCadastro.this, "Email já existe", Toast.LENGTH_LONG).show();
return ;
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}