@Override public void success(TokenRefreshResponse tokenResponse, Response response) { onEventSent(); getCredentials().refreshToken = tokenResponse.refreshToken; getCredentials().accessToken = tokenResponse.accessToken; if (null != callback) { callback.onSuccess(getCredentials()); } } });
/** * Refresh access/refresh tokens, using the current refresh token. * * @param callback the callback success and failure callback */ public void refreshTokens(final ApiCallback<Credentials> callback) { final String description = "refreshTokens"; TokenRefreshParams params = new TokenRefreshParams(); params.refresh_token = getCredentials().refreshToken; mApi.tokenRefresh(params) .enqueue(new RestAdapterCallback<TokenRefreshResponse>(description, mUnsentEventsManager, callback, null) { @Override public void success(TokenRefreshResponse tokenResponse, Response response) { onEventSent(); getCredentials().refreshToken = tokenResponse.refreshToken; getCredentials().accessToken = tokenResponse.accessToken; if (null != callback) { callback.onSuccess(getCredentials()); } } }); }
/** * Update this user's own display name. * * @param newName the new name * @param callback the callback if the call succeeds */ public void updateDisplayname(final String newName, final ApiCallback<Void> callback) { // privacy //final String description = "updateDisplayname newName : " + newName; final String description = "update display name"; // TODO Do not create a User for this User user = new User(); user.displayname = newName; // don't retry if the network comes back // let the user chooses what he want to do mApi.displayname(getCredentials().userId, user) .enqueue(new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() { @Override public void onRetry() { updateDisplayname(newName, callback); } })); }
/** * Update this user's own avatar URL. * * @param newUrl the new name * @param callback the callback if the call succeeds */ public void updateAvatarUrl(final String newUrl, final ApiCallback<Void> callback) { // privacy //final String description = "updateAvatarUrl newUrl : " + newUrl; final String description = "updateAvatarUrl"; // TODO Do not create a User for this User user = new User(); user.setAvatarUrl(newUrl); mApi.avatarUrl(getCredentials().userId, user) .enqueue(new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() { @Override public void onRetry() { updateAvatarUrl(newUrl, callback); } })); }