-
-
Save hanleyhansen/e7a4916c42d3ca065c99 to your computer and use it in GitHub Desktop.
onSuccess();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onSuccess(JSONObject response) { | |
if (progress != null) { | |
progress.dismiss(); | |
progress = null; | |
} | |
String responseString = response.toString(); | |
GsonBuilder gsonb = new GsonBuilder(); | |
Gson gson = gsonb.create(); | |
ResponseLogin results = gson.fromJson(responseString, ResponseLogin.class); | |
if (results.status.equals("ERROR")) { | |
ResponseError error = gson.fromJson(responseString, ResponseError.class); | |
if (error.response.message != null) { | |
Utils.DisplayDialog(STAuthorizationActivity.this, getString(R.string.error_dialog_title), error.response.message); | |
return; | |
} | |
} | |
int userId = Integer.valueOf(results.response.userid); | |
String token = results.response.token; | |
if (token != null && token.length() > 0 && userId > 0) { | |
STRestClient.setToken(getBaseContext(),token); | |
// logged in | |
Intent mIntent = new Intent(); | |
mIntent.putExtra("userid", userId); | |
mIntent.putExtra("token", token); | |
if (results.response.subscribed != null) { | |
mIntent.putExtra("subscribed", !results.response.subscribed.equalsIgnoreCase("0")); | |
} | |
if (results.response.remaining != null) { | |
mIntent.putExtra("remaining", results.response.remaining); | |
} | |
setResult(RESULT_OK, mIntent); | |
finish(); | |
overridePendingTransition(R.anim.fadein, R.anim.fadeout); | |
} else { | |
Utils.DisplayDialog(STAuthorizationActivity.this, getString(R.string.alert_bad_login_title), getString(R.string.alert_bad_login_message)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment