0

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();
         }
     }
       }
   });
 }
rici
  • 234,347
  • 28
  • 237
  • 341
  • Where dies the variable *parseUser* come from? To prevent any starting of new activities in case the input is wrong, put *return;* after display the "Make Sure The Code IS Correctly"-toast. – Capricorn Sep 23 '15 at 12:37
  • its coming from parse sql server i have table there that include user's .. – David Tuvia Sep 23 '15 at 13:37
  • thx about the return but i have tried it..its working but when i press ok button and the code is not correctly the dialog closed up and i wont him to closing – David Tuvia Sep 23 '15 at 13:43
  • Then check this question: http://stackoverflow.com/questions/2620444/how-to-prevent-a-dialog-from-closing-when-a-button-is-clicked it explains how to prevent a dialog from closing although one of the buttons is clicked. – Capricorn Sep 23 '15 at 13:45
  • Thx verry much for helping – David Tuvia Sep 24 '15 at 20:46

0 Answers0