Skip to content

Commit

Permalink
Don't throw exception when session couldn't be created on server
Browse files Browse the repository at this point in the history
  • Loading branch information
czorek committed Dec 10, 2018
1 parent fb86238 commit e875e6d
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/main/java/pl/llp/aircasting/sync/FixedSessionUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,34 @@ public void init() {
}

public boolean create(final Session session) {
try {
if (canUpload()) {
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
performCreateSession(session);
if (canUpload()) {
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... voids) {
performCreateSession(session);

return true;
}
}.execute();
return (true);
} else {
ToastHelper.show(context, R.string.fixed_session_creation_failed, Toast.LENGTH_LONG);
return (false);
}
} catch (SessionSyncException exception) {
return true;
}
}.execute();
return (true);
} else {
ToastHelper.show(context, R.string.fixed_session_creation_failed, Toast.LENGTH_LONG);
return (false);
}
}

private void performCreateSession(Session session) throws SessionSyncException {
private void performCreateSession(Session session) {
HttpResult<CreateSessionResponse> result = fixedSessionDriver.create(session);

Status status = result.getStatus();
if (status == Status.ERROR || status == Status.FAILURE)
throw new SessionSyncException("Session creation failed");
CreateSessionResponse createSessionResponse = result.getContent();
try {
if (status == Status.ERROR || status == Status.FAILURE) {
throw new SessionSyncException("Session creation failed");
}
} catch (SessionSyncException e) {
ToastHelper.show(context, R.string.fixed_session_creation_failed, Toast.LENGTH_LONG);
}
// CreateSessionResponse createSessionResponse = result.getContent();
}

private boolean canUpload() {
Expand Down

0 comments on commit e875e6d

Please sign in to comment.