Skip to content

Instantly share code, notes, and snippets.

@CVertex
Last active August 29, 2015 13:58
Show Gist options
  • Select an option

  • Save CVertex/9949073 to your computer and use it in GitHub Desktop.

Select an option

Save CVertex/9949073 to your computer and use it in GitHub Desktop.
if (ApiErrorCodeChecker.isCommon(code)) {
final boolean shouldLogout = ApiErrorCodeChecker.doesRequireLogout(code);
final boolean shouldShowMessage = ApiErrorCodeChecker.shouldShowMessage(code);
final boolean shouldGoUnderMaintenance = code == ApiErrorCode.UnderMaintenance;
if (shouldShowMessage) {
if (shouldLogout || shouldGoUnderMaintenance) {
// On pressing Ok, user should be shown the "Service unavailable" message or the user should be logged out
AlertDialogHelper.showOk(context, result.getMessage(), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (shouldLogout) {
AuthenticationManager.INSTANCE.clearInfo(context);
result.setResultWasHandled(true);
}
if (shouldGoUnderMaintenance) {
MaintenanceModeManager.INSTANCE.notifyServiceIsUnderMaintenance();
result.setResultWasHandled(true);
}
}
});
result.setResultWasHandled(true);
} else {
// Just show message and don't handle the result
AlertDialogHelper.showOk(context, result.getMessage());
}
} else if (shouldLogout) {
AuthenticationManager.INSTANCE.clearInfo(context);
result.setResultWasHandled(true);
}
else if (shouldGoUnderMaintenance) {
MaintenanceModeManager.INSTANCE.notifyServiceIsUnderMaintenance();
result.setResultWasHandled(true);
}
}
@CVertex

CVertex commented Apr 3, 2014

Copy link
Copy Markdown
Author

@indyfromoz Hi there!

@indyfromoz

Copy link
Copy Markdown

Hmmm, How will this work? via comments? I can't edit the gist

@indyfromoz

Copy link
Copy Markdown

We are missing -

ImportantMessageQueue.INSTANCE.add(result.getMessage());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment