Hey I'am not that good in English sorry.(help)
I am trying using parse Object and dialog prompt. I want to get the value from the text Dialog and asking about it in parse to see if its equal.
If it's equal the dialog sending me to and activity matches the Logon User if it manager/student.
If the code that he writing didn't matches the code in the server i want him to try again but what's happening that the dialog doesn't stop its sending me to and activity matches with the logon even the code text doesn't matches.
This is the code i hope can helping me.
final EditText editText = (EditText) promptView.findViewById(R.id.editCodeSurvey);
// setup a dialog window
alertDialogBuilder.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String surveyCode = editText.getText().toString();
final ParseQuery<ParseObject> query = ParseQuery.getQuery("Field");
query.whereEqualTo("codeField", surveyCode);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e != null) {
e.printStackTrace();
} else if (list.size() == 0) {
// something went wrong
Toast.makeText(getApplicationContext(), "Make Sure The Code IS Correctly", Toast.LENGTH_SHORT).show();
}
//After Creating Dialog then we asking if the User that signed in is manager
if (parseUser.getBoolean("isManager")) {
//open manager Class
startActivity(new Intent(Login.this, ManagerScreen.class));
} else {
//open Student Class to fill the survey
startActivity(new Intent(Login.this, StudentField.class));
}
}
});
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
// create an alert dialog
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
}
}
});
}