use of cl.smartcities.isci.transportinspector.serverConnection.requests.pullRequests.LogoutRequest in project androidApp by InspectorIncognito.
the class TranSappAccountManager method logOut.
public static void logOut(final AccountLogOutListener listener) {
SocialAccountLoaderManager manager = new SocialAccountLoaderManager();
manager.unloadAccount();
if (account == null) {
listener.onLoggedOut();
return;
}
account.socialMediaAccount.logout();
LogoutRequest request = new LogoutRequest(new Request.RequestListener<String>() {
@Override
public void onRequestError() {
account = null;
listener.onError(new ServerStatusCode(ServerStatusCode.SERVER_ERROR));
listener.onLoggedOut();
}
@Override
public void onRequestResult(@NonNull String result) {
account = null;
try {
JSONObject data = new JSONObject(result);
int status = data.getInt("status");
if (status != ServerStatusCode.OK) {
listener.onError(new ServerStatusCode(status));
}
} catch (JSONException e) {
e.printStackTrace();
listener.onError(new ServerStatusCode(ServerStatusCode.PARSE_ERROR));
}
listener.onLoggedOut();
}
}, account);
if (Looper.myLooper() == null) {
Looper.prepare();
}
ServerController.sendRequest(request, null);
}
Aggregations