Bonjour,

Je suis entrain de faire les conditions pour l'inscription dans mon application mais je ne sais pas si je m'y prend bien ou non.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    if(login.getText().toString().length()>=5){
       if(email.isValid(){
             if(password.isValidPassword(){
                  //http POST etc....
 
              }else{
 
                   AlertDialog.Builder ErrorMSg = new AlertDialog.Builder(this);
                   TextView Error = new TextView(this);
                   Error.setText("Password not correct !");
                   Error.setGravity(Gravity.CENTER_HORIZONTAL);
                   ErrorMSg.setView(Error);
                   }
 
                }
        }else{
              AlertDialog.Builder ErrorMSg = new AlertDialog.Builder(this);
              TextView Error = new TextView(this);
              Error.setText("Email not correct!");
              Error.setGravity(Gravity.CENTER_HORIZONTAL);
              ErrorMSg.setView(Error);
        }
 
    } else{
 
    AlertDialog.Builder ErrorMSg = new AlertDialog.Builder(this);
     TextView Error = new TextView(this);
     Error.setText("Login must contains more than 5 characters");
     Error.setGravity(Gravity.CENTER_HORIZONTAL);
     ErrorMSg.setView(Error);
    }

Cela vous semble correct ? je veux dire le fait de mettre des if en cascade et des alertDialogues ?


Merci.