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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
| bt_login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Log.i("setOnClickListenner", "on est dans le setClickListenner, on va lançé attemp_Login_fORM");
//showProgress(true);
// Reset errors.
et_email.setError(null);
et_password.setError(null);
// Store values at the time of the login attempt.
String email = et_email.getText().toString();
String password = et_password.getText().toString();
email_current = email;
password_current = password;
boolean cancel_email = false;
boolean cancel_password = false;
// Check Email syntaxe
// + Gérer le cas où l'email comporte un seule ou rien comme caractère
// On vérifie que le champ email_login n'est pas vide
if (TextUtils.isEmpty(email)) {
et_email.setError("Veuillez renseigner votre email svp");
et_email.setError("Champ requis.");
cancel_email = true;
isRightSyntaxEmail = false;
Log.i("Syntaxe email", "email vide");
focusView = et_email;
}
else if (!isEmailSyntaxValid(email)) {
et_email.setError("La syntaxe de l'email est incorrect");
cancel_email = true;
isRightSyntaxEmail = false;
Log.i("Syntaxe email", "Syntaxe email incorrect");
focusView = et_email;
}
else {
et_email.setError(null);
cancel_email = false;
isRightSyntaxEmail = true;
focusView = et_password;
Log.i("Syntaxe email", "Syntaxe email correct");
}
if (TextUtils.isEmpty(password)) {
et_password.setError("Veuillez renseigner votre mot de passe svp");
cancel_password = true;
isRightSyntaxPassword = false;
Log.i("Syntaxe password", "password vide");
focusView = et_password;
}
else if (!isPasswordSyntaxValid(password)) {
et_password.setError("La syntaxe du mot de passe est incorrect (8) A-Z, a-z, 0-9, @#-_");
Log.d("Syntaxe password", "Syntaxe password incorrect, le mauvais password entré est "+password);
cancel_password = true;
isRightSyntaxPassword = false;
focusView = et_password;
}
else {
et_password.setError(null);
cancel_password = false;
isRightSyntaxPassword = true;
focusView = null;
Log.i("Syntaxe password", "Syntaxe password correct");
}
// Si les champs sont incorrects et comportent des erreurs
if (cancel_email || cancel_password) {
isRightSyntaxBoth = false;
if (cancel_email) {
Log.d("email if(...)", "email comporte des erreurs");
focusView = et_email;
}
else if (cancel_password) {
Log.d("password if(...)", "password comporte des erreurs");
focusView = et_password;
}
else {
Log.e("cancel probleme", "probleme de variable boolean cancel");
}
//focusView.requestFocus();
Log.e("cancel Login_FORM()", "Il y a des erreurs dans la loginform(), cancel_email vaut --> "+String.valueOf(cancel_email)
+" cancel_password vaut --> "+String.valueOf(cancel_password));
}
else // les champs sont correct et ne comportent pas d'erreur
{
Log.d("onClickListenner", "if(isRightSyntaxBoth vaut true) La syntaxe des 2 champs est correct");
isRightSyntaxBoth = true;
Log.d("onClickListenner", "on lance le service rétrofit de concordance ");
Log.d("onClickListenner", "la valeur des paramètres sont email: "+email+" password : "+password);
// On fait notre CALL ProcessRTFIsEmailMatchToPassword(email, password); // On lance le service retrofit pour verifier le couple
Log.d("CALL RETROFIT", "Le call retrofit est lançé");
// Create an instance own RestAdapter and of own Login API Service
LoginService.LoginApp_Service login_service = getComplexClient1(LoginActivity.this);
Log.d("email/mdp send to call", " email --> "+email+" password --> "+password);
Call<Integer> call = login_service.isEmailMatchToPassword(email, password);
call.enqueue(new Callback<Integer>() {
@Override
public void onResponse(Call<Integer> call, Response<Integer> response)
{
Log.d("PURE RESPONSE DATA", response.body().toString());
if (response.isSuccessful())
{
Log.i("Retrofit EmailMatchPass", "On a bien reçu la requête du service retrofit isEmailMatchToPassword()");
onResponseTest(response);
if (response.body().equals(1))
{
Log.d("Sucess RESPONSE STR--> ", response.body().toString());
isEmailMatchToPassword = true;
Log.d("isEmailMatchToPassword", isEmailMatchToPassword.toString());
editor.putBoolean("isEmailLoginMatchtoPwd", true);
editor.commit();
Log.d("onClickListenner", "if (isEmailMatchToPassword) L'email et pass concordent avec ceux en bdd");
Intent intent = new Intent(LoginActivity.this, MainTabbedActivity.class);
//registerIntegerent.putExtra("Email", et_email.getText());
//registerIntegerent.putExtra("PwdHash", et_password.getText()); // A implémenter
startActivity(intent);
}
else if (response.body().equals(0))
{
Log.d("Type/CLass OF response", response.body().getClass().toString());
Log.d("Echec RESPONSE STR--> ", "response=false");
isEmailMatchToPassword = false;
Log.d("isEmailMatchToPassword", isEmailMatchToPassword.toString());
editor.putBoolean("isEmailLoginMatchtoPwd", false);
editor.commit();
et_email.setError("identifiants incorrects");
et_password.setError("identifiants incorrects");
}
else
{
Log.d("Type/CLass OF response", response.body().getClass().toString());
Log.d("NULL RESPONSE STR--> ", "response=NULL");
isEmailMatchToPassword = Boolean.valueOf(response.body().toString());
Log.d("isEmailMatchToPassword", isEmailMatchToPassword.toString());
Log.e("onClickListenner", "if (isEmailMatchToPassword) L'email et pass ne concordent pas avec ceux en bdd");
editor.putBoolean("isEmailLoginMatchtoPwd", false);
editor.commit();
}
}
else
{
// error response, no access to resource?
isEmailMatchToPassword = false;
Log.e("Call email match pass", "Pas de réponse, le service retrofit isEmailMatchToPassword() n'a pas accès aux ressources");
onCallFinish();
}
}
@Override
public void onFailure(Call<Integer> call, Throwable t)
{
// something went completely south (like no Integerernet connection)
// java.io.EOFException response null
Log.e("ProcessEmail onFailure ", "une erreur s'est produite lors du call isEmailMatchToPassword -- > car onFailure() called"+t.toString());
if (t instanceof JsonEncodingException) {
// pas de connexion Integerernet
Log.e("onFailure ERROR", "Problème de JsonConverter--> " + t.toString());
}
if (t instanceof IOException) {
Log.e("new except° non traitée", t.toString());
}
onCallFinish();
}
public void onResponseTest(Response<Integer> response) {
// On fait un traitement avec la reponse
Log.d("RESPONSE--> ", response.toString());
Log.d("RESPONSE-BODY--> ", response.body().toString());
Log.d("RESPONSE-BODY-STR--> ", response.body().toString());
Log.d("RESPONSE-HEADER--> ", response.headers().toString());
Log.d("RESPONSE-Integer--> ", response.message().toString());
//Log.d("RESPONSE-ERRORBODY--> ", response.errorBody().toString()); // Erreur !! ?
Log.d("RESPONSE-RAW--> ", response.raw().toString());
}
public void onCallFinish() {
}
});
}
}
}); |
Partager