@Override public void onRetry() { dexcomShareApi.deleteContact(getSessionId(), contactId).enqueue(this); } });
@Override public void onRun() throws Throwable { long timestamp = mFeedModel.getLatestTimestamp(mUserId); final Call<FeedResponse> feed; if (mUserId == null) { feed = mApiService.feed(timestamp); } else { feed = mApiService.userFeed(mUserId, timestamp); } Response<FeedResponse> response = feed.execute(); if (response.isSuccess()) { Post oldest = handleResponse(response.body()); mEventBus.post(new FetchedFeedEvent(true, mUserId, oldest)); } else { throw new NetworkException(response.code()); } }
private <T> void enqueue(String tag, Call<T> call, ApiCallback<T> apiCallback) { // cancel any outstanding request with the same tag Call pendingRequest = mPendingCalls.remove(tag); if (pendingRequest != null) { pendingRequest.cancel(); } // send a new request mPendingCalls.put(tag, call); apiCallback.setCall(call); call.enqueue(apiCallback); }
@Override public void call(final Subscriber<? super Response<T>> subscriber) { // Since Call is a one-shot type, clone it for each new subscriber. final Call<T> call = originalCall.clone(); // Attempt to cancel the call if it is still in-flight on unsubscription. subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { call.cancel(); } })); if (subscriber.isUnsubscribed()) { return; } try { Response<T> response = call.execute(); if (!subscriber.isUnsubscribed()) { subscriber.onNext(response); } } catch (Throwable t) { Exceptions.throwIfFatal(t); if (!subscriber.isUnsubscribed()) { subscriber.onError(t); } return; } if (!subscriber.isUnsubscribed()) { subscriber.onCompleted(); } } }
@Override public void call() { call.cancel(); } }));
@Subscribe public void onCancelAllEvent(CancelAllEvent event) { for (Call call : mPendingCalls.values()) { call.cancel(); } mPendingCalls.clear(); }
@Override public void onRetry() { dexcomShareApi.getContacts(getSessionId()).enqueue(this); } });
public Response<Comment> commentIssue(String issue, Comment comment) throws IOException { return jiraEndPoints.commentIssue(issue, comment).execute(); }
@Override public void onRetry() { dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(this); } });
public Response<CommentResponse> getCommentsOfIssue(String issue) throws IOException { return jiraEndPoints.getCommentsOfIssue(issue).execute(); }
@Override public void onRetry() { dexcomShareApi.createContact(getSessionId(), followerName, followerEmail).enqueue(this); } });
public Response<Map<String, Object>> serverInfo() throws IOException { return jiraEndPoints.serverInfo().execute(); }
@Override public void onRetry() { dexcomShareApi.createInvitationForContact(getSessionId(), contactId, invitationPayload).enqueue(this); } });
public Response<Object> getIssue(String issue) throws IOException { return jiraEndPoints.getIssue(issue).execute(); }
@Override public void onRetry() { dexcomShareApi.getContacts(getSessionId()).enqueue(this); } });
@Override public void onRun() throws Throwable { Post post = mPostModel.loadByClientIdAndUserId(mClientId, mUserId); if (post != null && !post.isPending()) { // looks like post probably arrived from somewhere else. Good Job! mEventBus.post(new UpdatedPostEvent(post)); return; } Response<NewPostResponse> response = mApiService.sendPost(mText, mClientId, mUserId) .execute(); if (response.isSuccess()) { NewPostResponse body = response.body(); body.getPost().setPending(false); mPostModel.save(body.getPost()); mUserModel.save(body.getUser()); mEventBus.post(new UpdatedPostEvent(body.getPost())); } else { throw new NetworkException(response.code()); } }
@Override public void onRetry() { dexcomShareApi.uploadBGRecords(getSessionId(), bg).enqueue(this); } });
private String updateAuthenticationParams() throws IOException { sessionId = dexcomShareApi.getSessionId(new ShareAuthenticationBody(password, username).toMap()).execute().body(); dexcomShareApi.authenticatePublisherAccount(sessionId, serialNumber, new ShareAuthenticationBody(password, username).toMap()).execute().body(); dexcomShareApi.StartRemoteMonitoringSession(sessionId, serialNumber).execute(); String assignment = dexcomShareApi.checkMonitorAssignment(sessionId, serialNumber).execute().body(); if ((assignment != null) && (!assignment.equals("AssignedToYou"))) { dexcomShareApi.updateMonitorAssignment(sessionId, serialNumber).execute(); } return sessionId; }
@Override public void onRetry() { dexcomShareApi.createInvitationForContact(getSessionId(), contactId, invitationPayload).enqueue(this); } });