Skip to content

Commit

Permalink
#80 - Better messages on user exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Xero-Hige committed Jul 14, 2016
1 parent 2d95221 commit 8f2f019
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/ar/uba/fi/drtinder/UserHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ public static String #(String email, String password, Map<String, String> u
return #_FAILED;
} catch (HttpClientErrorException e) {
DrTinderLogger.writeLog(DrTinderLogger.NET_ERRO, "Client error: " + e.getMessage());
if (e.getStatusCode().value() == 401) {
return #_USEREXIST;
}
return #_FAILED;
} catch (ResourceAccessException e) {
DrTinderLogger.writeLog(DrTinderLogger.NET_WARN, "Failed to connect: " + e.getMessage());
Expand All @@ -288,9 +291,6 @@ public static String #(String email, String password, Map<String, String> u
int statusCode = response.getStatusCode().value();

if (statusCode != 201) {
if (statusCode == 401) {
return #_USEREXIST;
}
String errorMessage = "Failed login post: "
+ response.getStatusCode().value()
+ " " + response.getStatusCode().getReasonPhrase();
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/ar/uba/fi/drtinder/UserProfileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ private class CreateUserTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... voids) {
mResult = UserHandler.#(mEmail, mPasswd, getUserdataMap());
UserHandler.uploadProfilePicture(mProfileImage, UserHandler.getToken());
if (mResult.equals(UserHandler.#_SUCCESS)) {
UserHandler.uploadProfilePicture(mProfileImage, UserHandler.getToken());
}
return mResult.equals(UserHandler.#_SUCCESS);
}

Expand All @@ -490,6 +492,12 @@ protected void onPostExecute(final Boolean success) {
enableButtons();
return;
}
if (mResult.equals(UserHandler.#_USEREXIST)) {
Utility.showMessage("El email ya esta registrado. Elija otro",
Utility.getViewgroup(mContext), "Ok");
enableButtons();
return;
}
assert false; //DEBUG: should not reach here
}
mContext.finish();
Expand Down

0 comments on commit 8f2f019

Please # to comment.