@Override public void onConnectionError(ConnectionErrorResponse connectionErrorResponse) { ConnectionUtils.connectionError(this, connectionErrorResponse, TAG); mWaitDialog.dismiss(); if (ConnectionUtils.checkConnectionId(connectionErrorResponse, InternetMenu.mLogoutURL)) { Toast.makeText(Login.this, "Server couldn't logout", Toast.LENGTH_LONG).show(); logout(); } }
@Override public void onConnectionSuccessful(ConnectionSuccessfulResponse connectionSuccessfulResponse) throws JSONException { ConnectionUtils.connectionSuccessful(Login.this, connectionSuccessfulResponse); mWaitDialog.dismiss(); if (ConnectionUtils.checkConnectionId(connectionSuccessfulResponse, InternetMenu.mLogoutURL)) { Toast.makeText( Login.this, connectionSuccessfulResponse.getJSONObject().getString(ConnectionUtils.returnMessage), Toast.LENGTH_LONG) .show(); logout(); } else if (ConnectionUtils.checkConnectionId( connectionSuccessfulResponse, InternetMenu.mLoginURL)) { String password = connectionSuccessfulResponse.getJSONObject().getString(InternetMenu.PASSWORD_KEY); String sessionToken = connectionSuccessfulResponse.getJSONObject().getString(InternetMenu.SESSION_TOKEN_KEY); String userId = connectionSuccessfulResponse.getJSONObject().getString(InternetMenu.USER_ID_KEY); String accountMessage = connectionSuccessfulResponse.getJSONObject().getString(InternetMenu.ACCOUNT_MESSAGE_KEY); if (mRememberSession) { mDbHelper.createLogin(InternetMenu.USER_ID_KEY, userId); mDbHelper.createLogin(InternetMenu.SESSION_TOKEN_KEY, sessionToken); } if (mPasswordOperation == PASSWORD_OPERATION_SAVE) { mDbHelper.putLogin(InternetMenu.PASSWORD_KEY, password); } mReturnSession = new HashMap<String, String>(); mReturnSession.put(InternetMenu.USER_ID_KEY, userId); mReturnSession.put(InternetMenu.SESSION_TOKEN_KEY, sessionToken); Bundle bundle = new Bundle(); bundle.putSerializable(InternetMenu.LOGIN_KEY, mReturnSession); bundle.putString(InternetMenu.ACCOUNT_MESSAGE_KEY, accountMessage); Intent intent = new Intent(); intent.putExtras(bundle); setResult(RESULT_OK, intent); finish(); } else if (ConnectionUtils.checkConnectionId( connectionSuccessfulResponse, InternetMenu.mRecoverPasswordURL)) { Toast.makeText( Login.this, connectionSuccessfulResponse.getJSONObject().getString(ConnectionUtils.returnMessage), Toast.LENGTH_LONG) .show(); } }